Sample application 5 used in IEEE Transactions on Intelligent Transportation Systems is added.
This commit is contained in:
1
scripts/sample_app5/.gitignore
vendored
Normal file
1
scripts/sample_app5/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
output
|
1
scripts/sample_app5/ai_trainer/.gitignore
vendored
Normal file
1
scripts/sample_app5/ai_trainer/.gitignore
vendored
Normal file
@ -0,0 +1 @@
|
||||
*.class
|
23
scripts/sample_app5/ai_trainer/README.md
Normal file
23
scripts/sample_app5/ai_trainer/README.md
Normal file
@ -0,0 +1,23 @@
|
||||
# Configure Simulation Settings
|
||||
|
||||
Firstly, edit config.json file in a way to declare the configuration of the simulation process used to collect training data
|
||||
|
||||
# Preparing Training Data
|
||||
|
||||
Invoke following command to convert collected data format for weka models
|
||||
|
||||
```
|
||||
./generate_training_data.sh
|
||||
```
|
||||
|
||||
This command creates *.arff files under the simulation results folder
|
||||
|
||||
# Generating Classification and Regression Models
|
||||
|
||||
Invoke following command to generate related weka models
|
||||
|
||||
```
|
||||
./generate_weka_models.sh
|
||||
```
|
||||
|
||||
This script creates weka model files under the simulation results folder. When you are done with training, you can move these files to ../config/weka/ folder
|
208
scripts/sample_app5/ai_trainer/WekaModelCreator.java
Normal file
208
scripts/sample_app5/ai_trainer/WekaModelCreator.java
Normal file
@ -0,0 +1,208 @@
|
||||
import java.io.FileReader;
|
||||
import java.text.DateFormat;
|
||||
import java.text.SimpleDateFormat;
|
||||
import java.util.Calendar;
|
||||
import java.util.Date;
|
||||
import java.util.concurrent.TimeUnit;
|
||||
|
||||
import org.json.simple.JSONObject;
|
||||
import org.json.simple.parser.JSONParser;
|
||||
|
||||
import weka.classifiers.Evaluation;
|
||||
import weka.classifiers.bayes.NaiveBayes;
|
||||
import weka.classifiers.functions.LinearRegression;
|
||||
import weka.classifiers.functions.MultilayerPerceptron;
|
||||
import weka.classifiers.functions.SMO;
|
||||
import weka.classifiers.functions.SMOreg;
|
||||
import weka.core.Instances;
|
||||
import weka.core.converters.ConverterUtils.DataSource;
|
||||
|
||||
public class WekaModelCreator {
|
||||
private static final String[] targets = {"edge","cloud_rsu","cloud_gsm"};
|
||||
|
||||
public static void main(String[] args) throws Exception {
|
||||
String dataPath = "";
|
||||
String classifier = "";
|
||||
String regressor = "";
|
||||
|
||||
JSONParser parser = new JSONParser();
|
||||
try
|
||||
{
|
||||
Object object = parser.parse(new FileReader(args[0]));
|
||||
|
||||
//convert Object to JSONObject
|
||||
JSONObject jsonObject = (JSONObject)object;
|
||||
|
||||
//Reading the String
|
||||
dataPath = (String) jsonObject.get("sim_result_folder");
|
||||
classifier = (String) jsonObject.get("classifier");
|
||||
regressor = (String) jsonObject.get("regressor");
|
||||
}
|
||||
catch(Exception e)
|
||||
{
|
||||
e.printStackTrace();
|
||||
System.exit(1);
|
||||
}
|
||||
|
||||
System.out.println("######### TRAINING FOR " + dataPath + " #########");
|
||||
for(int i=0; i<targets.length; i++) {
|
||||
handleClassify("train", targets[i], classifier, dataPath);
|
||||
handleRegression("train", targets[i], regressor, dataPath);
|
||||
}
|
||||
|
||||
System.out.println("######### EVALUATION FOR " + dataPath + " #########");
|
||||
for(int i=0; i<targets.length; i++) {
|
||||
handleClassify("evaluate", targets[i], classifier, dataPath);
|
||||
handleRegression("evaluate", targets[i], regressor, dataPath);
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleRegression(String action, String target, String method, String dataFolder) throws Exception {
|
||||
if(action.equals("train")) {
|
||||
DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
Date startDate = Calendar.getInstance().getTime();
|
||||
String now = df.format(startDate);
|
||||
System.out.println("Training " + method + " for " + target + " started at " + now);
|
||||
|
||||
DataSource edgeRegressionSource = new DataSource(dataFolder + "/" + target + "_regression_train.arff");
|
||||
Instances edgeRegressionDataset = edgeRegressionSource.getDataSet();
|
||||
edgeRegressionDataset.setClassIndex(edgeRegressionDataset.numAttributes()-1);
|
||||
|
||||
if(method.equals("LinearRegression")) {
|
||||
LinearRegression lr = new LinearRegression();
|
||||
lr.buildClassifier(edgeRegressionDataset);
|
||||
weka.core.SerializationHelper.write(dataFolder + "/lr_" + target + ".model", lr);
|
||||
}
|
||||
else if(method.equals("SMOreg")) {
|
||||
SMOreg smoreg = new SMOreg();
|
||||
smoreg.buildClassifier(edgeRegressionDataset);
|
||||
weka.core.SerializationHelper.write(dataFolder + "/smoreg_" + target + ".model", smoreg);
|
||||
}
|
||||
|
||||
Date endDate = Calendar.getInstance().getTime();
|
||||
now = df.format(endDate);
|
||||
System.out.println("Training " + method + " for " + target + " fisished at " + now + ". It took " + getTimeDifference(startDate, endDate));
|
||||
}
|
||||
else if(action.equals("evaluate")) {
|
||||
System.out.println("Evaluation " + method + " for " + target + " started");
|
||||
|
||||
DataSource edgeRegressionSource = new DataSource(dataFolder + "/" + target + "_regression_test.arff");
|
||||
Instances edgeRegressionDataset = edgeRegressionSource.getDataSet();
|
||||
edgeRegressionDataset.setClassIndex(edgeRegressionDataset.numAttributes()-1);
|
||||
|
||||
if(method.equals("LinearRegression")) {
|
||||
LinearRegression lr = (LinearRegression) weka.core.SerializationHelper.read(dataFolder + "/lr_" + target + ".model");
|
||||
Evaluation lrEval = new Evaluation(edgeRegressionDataset);
|
||||
lrEval.evaluateModel(lr, edgeRegressionDataset);
|
||||
System.out.println("LinearRegression");
|
||||
System.out.println(lrEval.toSummaryString());
|
||||
}
|
||||
else if(method.equals("SMOreg")) {
|
||||
SMOreg smoreg = (SMOreg) weka.core.SerializationHelper.read(dataFolder + "/smoreg_" + target + ".model");
|
||||
Evaluation svmregEval = new Evaluation(edgeRegressionDataset);
|
||||
svmregEval.evaluateModel(smoreg, edgeRegressionDataset);
|
||||
System.out.println("SMOreg");
|
||||
System.out.println(svmregEval.toSummaryString());
|
||||
}
|
||||
|
||||
System.out.println("Evaluation " + method + " for " + target + " fisished");
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
public static void handleClassify(String action, String target, String method, String dataFolder) throws Exception {
|
||||
if(action.equals("train")) {
|
||||
DateFormat df = new SimpleDateFormat("dd/MM/yyyy HH:mm:ss");
|
||||
Date startDate = Calendar.getInstance().getTime();
|
||||
String now = df.format(startDate);
|
||||
System.out.println("Training " + method + " for " + target + " started at " + now);
|
||||
|
||||
DataSource classifierSource = new DataSource(dataFolder + "/" + target + "_classifier_train.arff");
|
||||
Instances classifierDataset = classifierSource.getDataSet();
|
||||
classifierDataset.setClassIndex(classifierDataset.numAttributes()-1);
|
||||
|
||||
if(method.equals("NaiveBayes")) {
|
||||
NaiveBayes nb = new NaiveBayes();
|
||||
nb.buildClassifier(classifierDataset);
|
||||
weka.core.SerializationHelper.write(dataFolder + "/nb_" + target + ".model", nb);
|
||||
}
|
||||
else if(method.equals("SMO")) {
|
||||
SMO smo = new SMO();
|
||||
smo.buildClassifier(classifierDataset);
|
||||
weka.core.SerializationHelper.write(dataFolder + "/smo_" + target + ".model", smo);
|
||||
}
|
||||
else if(method.equals("MultilayerPerceptron")) {
|
||||
MultilayerPerceptron mlp = new MultilayerPerceptron();
|
||||
mlp.setLearningRate(0.1);
|
||||
//mlp.setMomentum(0.2);
|
||||
mlp.setTrainingTime(1000);
|
||||
//mlp.setHiddenLayers("3");
|
||||
mlp.buildClassifier(classifierDataset);
|
||||
weka.core.SerializationHelper.write(dataFolder + "/mlp_" + target + ".model", mlp);
|
||||
}
|
||||
|
||||
Date endDate = Calendar.getInstance().getTime();
|
||||
now = df.format(endDate);
|
||||
System.out.println("Training " + method + " for " + target + " fisished at " + now + ". It took " + getTimeDifference(startDate, endDate));
|
||||
}
|
||||
else if(action.equals("evaluate")) {
|
||||
System.out.println("Evaluation " + method + " for " + target + " started");
|
||||
|
||||
DataSource edgeClassifierSource = new DataSource(dataFolder + "/" + target + "_classifier_test.arff");
|
||||
Instances classifierDataset = edgeClassifierSource.getDataSet();
|
||||
classifierDataset.setClassIndex(classifierDataset.numAttributes()-1);
|
||||
|
||||
if(method.equals("NaiveBayes")) {
|
||||
NaiveBayes nb = (NaiveBayes) weka.core.SerializationHelper.read(dataFolder + "/nb_" + target + ".model");
|
||||
Evaluation nbEval = new Evaluation(classifierDataset);
|
||||
nbEval.evaluateModel(nb, classifierDataset);
|
||||
System.out.println(nbEval.toSummaryString());
|
||||
System.out.println(nbEval.toMatrixString());
|
||||
System.out.println(nbEval.toClassDetailsString());
|
||||
}
|
||||
else if(method.equals("SMO")) {
|
||||
SMO smo = (SMO) weka.core.SerializationHelper.read(dataFolder + "/smo_" + target + ".model");
|
||||
Evaluation smoEval = new Evaluation(classifierDataset);
|
||||
smoEval.evaluateModel(smo, classifierDataset);
|
||||
System.out.println(smoEval.toSummaryString());
|
||||
System.out.println(smoEval.toMatrixString());
|
||||
System.out.println(smoEval.toClassDetailsString());
|
||||
}
|
||||
else if(method.equals("MultilayerPerceptron")) {
|
||||
MultilayerPerceptron mlp = (MultilayerPerceptron) weka.core.SerializationHelper.read(dataFolder + "/mlp_" + target + ".model");
|
||||
Evaluation mlpEval = new Evaluation(classifierDataset);
|
||||
mlpEval.evaluateModel(mlp, classifierDataset);
|
||||
System.out.println(mlpEval.toSummaryString());
|
||||
System.out.println(mlpEval.toMatrixString());
|
||||
System.out.println(mlpEval.toClassDetailsString());
|
||||
}
|
||||
|
||||
System.out.println("Evaluation " + method + " for " + target + " fisished");
|
||||
System.out.println("");
|
||||
}
|
||||
}
|
||||
|
||||
private static String getTimeDifference(Date startDate, Date endDate){
|
||||
String result = "";
|
||||
long duration = endDate.getTime() - startDate.getTime();
|
||||
|
||||
long diffInMilli = TimeUnit.MILLISECONDS.toMillis(duration);
|
||||
long diffInSeconds = TimeUnit.MILLISECONDS.toSeconds(duration);
|
||||
long diffInMinutes = TimeUnit.MILLISECONDS.toMinutes(duration);
|
||||
long diffInHours = TimeUnit.MILLISECONDS.toHours(duration);
|
||||
long diffInDays = TimeUnit.MILLISECONDS.toDays(duration);
|
||||
|
||||
if(diffInDays>0)
|
||||
result += diffInDays + ((diffInDays>1 == true) ? " Days " : " Day ");
|
||||
if(diffInHours>0)
|
||||
result += diffInHours % 24 + ((diffInHours>1 == true) ? " Hours " : " Hour ");
|
||||
if(diffInMinutes>0)
|
||||
result += diffInMinutes % 60 + ((diffInMinutes>1 == true) ? " Minutes " : " Minute ");
|
||||
if(diffInSeconds>0)
|
||||
result += diffInSeconds % 60 + ((diffInSeconds>1 == true) ? " Seconds" : " Second");
|
||||
if(diffInMilli>0 && result.isEmpty())
|
||||
result += diffInMilli + ((diffInMilli>1 == true) ? " Milli Seconds" : " Milli Second");
|
||||
|
||||
return result;
|
||||
}
|
||||
}
|
10
scripts/sample_app5/ai_trainer/config.json
Normal file
10
scripts/sample_app5/ai_trainer/config.json
Normal file
@ -0,0 +1,10 @@
|
||||
{
|
||||
"sim_result_folder": "/home/cagatay/Projects/git-repos/EdgeCloudSim/scripts/sample_app5/output/18-10-2019_21-16/default_config",
|
||||
"num_iterations": 10,
|
||||
"train_data_ratio": 80,
|
||||
"min_vehicle": 100,
|
||||
"max_vehicle": 2200,
|
||||
"vehicle_step_size": 100,
|
||||
"classifier": "MultilayerPerceptron",
|
||||
"regressor": "LinearRegression"
|
||||
}
|
133
scripts/sample_app5/ai_trainer/data_convertor.py
Normal file
133
scripts/sample_app5/ai_trainer/data_convertor.py
Normal file
@ -0,0 +1,133 @@
|
||||
import pandas as pd
|
||||
import json
|
||||
import sys
|
||||
|
||||
if len (sys.argv) != 5:
|
||||
print('invalid arguments. Usage:')
|
||||
print('python data_conventor.py config.json [edge|cloud_rsu|cloud_gsm] [classifier|regression] [train|test]')
|
||||
sys.exit(1)
|
||||
|
||||
with open(sys.argv[1]) as json_data_file:
|
||||
data = json.load(json_data_file)
|
||||
|
||||
target = sys.argv[2]
|
||||
method = sys.argv[3]
|
||||
datatype = sys.argv[4]
|
||||
|
||||
print("conversion started with args " + target + ", " + method + ", " + datatype)
|
||||
|
||||
sim_result_folder = data["sim_result_folder"]
|
||||
num_iterations = data["num_iterations"]
|
||||
train_data_ratio = data["train_data_ratio"]
|
||||
min_vehicle = data["min_vehicle"]
|
||||
max_vehicle = data["max_vehicle"]
|
||||
vehicle_step_size = data["vehicle_step_size"]
|
||||
|
||||
def getDecisionColumnName(target):
|
||||
if target == "edge":
|
||||
COLUMN_NAME = "EDGE"
|
||||
elif target == "cloud_rsu":
|
||||
COLUMN_NAME = "CLOUD_VIA_RSU"
|
||||
elif target == "cloud_gsm":
|
||||
COLUMN_NAME = "CLOUD_VIA_GSM"
|
||||
return COLUMN_NAME
|
||||
|
||||
def getClassifierColumns(target):
|
||||
if target == "edge":
|
||||
result = ["NumOffloadedTask", "TaskLength", "WLANUploadDelay", "WLANDownloadDelay", "AvgEdgeUtilization", "Result"]
|
||||
elif target == "cloud_rsu":
|
||||
result = ["NumOffloadedTask", "WANUploadDelay", "WANDownloadDelay", "Result"]
|
||||
elif target == "cloud_gsm":
|
||||
result = ["NumOffloadedTask", "GSMUploadDelay", "GSMDownloadDelay", "Result"]
|
||||
return result
|
||||
|
||||
def getRegressionColumns(target):
|
||||
if target == "edge":
|
||||
result = ["TaskLength", "AvgEdgeUtilization", "ServiceTime"]
|
||||
elif target == "cloud_rsu":
|
||||
result = ["TaskLength", "WANUploadDelay", "WANDownloadDelay", "ServiceTime"]
|
||||
elif target == "cloud_gsm":
|
||||
result = ["TaskLength", "GSMUploadDelay", "GSMDownloadDelay", "ServiceTime"]
|
||||
return result
|
||||
|
||||
def znorm(column):
|
||||
column = (column - column.mean()) / column.std()
|
||||
return column
|
||||
|
||||
data_set = []
|
||||
|
||||
testDataStartIndex = (train_data_ratio * num_iterations) / 100
|
||||
|
||||
for ite in range(num_iterations):
|
||||
for vehicle in range(min_vehicle, max_vehicle+1, vehicle_step_size):
|
||||
if (datatype == "train" and ite < testDataStartIndex) or (datatype == "test" and ite >= testDataStartIndex):
|
||||
file_name = sim_result_folder + "/ite" + str(ite + 1) + "/" + str(vehicle) + "_learnerOutputFile.cvs"
|
||||
df = [pd.read_csv(file_name, na_values = "?", comment='\t', sep=",")]
|
||||
df[0]['VehicleCount'] = vehicle
|
||||
#print(file_name)
|
||||
data_set += df
|
||||
|
||||
data_set = pd.concat(data_set, ignore_index=True)
|
||||
data_set = data_set[data_set['Decision'] == getDecisionColumnName(target)]
|
||||
|
||||
if method == "classifier":
|
||||
targetColumns = getClassifierColumns(target)
|
||||
else:
|
||||
targetColumns= getRegressionColumns(target)
|
||||
|
||||
if datatype == "train":
|
||||
print ("##############################################################")
|
||||
print ("Stats for " + target + " - " + method)
|
||||
print ("Please use relevant information from below table in java side:")
|
||||
train_stats = data_set[targetColumns].describe()
|
||||
train_stats = train_stats.transpose()
|
||||
print(train_stats)
|
||||
print ("##############################################################")
|
||||
|
||||
#print("balancing " + target + " for " + method)
|
||||
|
||||
#BALANCE DATA SET
|
||||
if method == "classifier":
|
||||
df0 = data_set[data_set['Result']=="fail"]
|
||||
df1 = data_set[data_set['Result']=="success"]
|
||||
|
||||
#size = min(len(df0[df0['VehicleCount']==max_vehicle]), len(df1[df1['VehicleCount']==min_vehicle]))
|
||||
|
||||
size = len(df0[df0['VehicleCount']==max_vehicle]) // 2
|
||||
|
||||
df1 = df1.groupby('VehicleCount').apply(lambda x: x if len(x) < size else x.sample(size))
|
||||
df0 = df0.groupby('VehicleCount').apply(lambda x: x if len(x) < size else x.sample(size))
|
||||
|
||||
data_set = pd.concat([df0, df1], ignore_index=True)
|
||||
else:
|
||||
data_set = data_set[data_set['Result'] == 'success']
|
||||
|
||||
#size = min(len(data_set[data_set['VehicleCount']==min_vehicle]), len(data_set[data_set['VehicleCount']==max_vehicle]))
|
||||
|
||||
size = len(data_set[data_set['VehicleCount']==max_vehicle]) // 3
|
||||
data_set = data_set.groupby('VehicleCount').apply(lambda x: x if len(x.index) < size else x.sample(size))
|
||||
|
||||
#EXTRACT RELATED ATTRIBUTES
|
||||
df = pd.DataFrame(columns=targetColumns)
|
||||
for column in targetColumns:
|
||||
if column == 'Result' or column == 'ServiceTime':
|
||||
df[column] = data_set[column]
|
||||
else:
|
||||
df[column] = znorm(data_set[column])
|
||||
|
||||
f = open(sim_result_folder + "/" + target + "_" + method + "_" + datatype + ".arff", 'w')
|
||||
f.write('@relation ' + target + '\n\n')
|
||||
for column in targetColumns:
|
||||
if column == 'Result':
|
||||
f.write('@attribute class {fail,success}\n')
|
||||
else:
|
||||
f.write('@attribute ' + column + ' REAL\n')
|
||||
f.write('\n@data\n')
|
||||
df.to_csv(f, header=False, index=False)
|
||||
f.close()
|
||||
|
||||
print ("##############################################################")
|
||||
print ("Operation completed!")
|
||||
print (".arff file is generated for weka.")
|
||||
print ("##############################################################")
|
||||
|
14
scripts/sample_app5/ai_trainer/generate_training_data.sh
Normal file
14
scripts/sample_app5/ai_trainer/generate_training_data.sh
Normal file
@ -0,0 +1,14 @@
|
||||
#!/bin/sh
|
||||
|
||||
python data_convertor.py config.json edge classifier train
|
||||
python data_convertor.py config.json edge classifier test
|
||||
python data_convertor.py config.json edge regression train
|
||||
python data_convertor.py config.json edge regression test
|
||||
python data_convertor.py config.json cloud_rsu classifier train
|
||||
python data_convertor.py config.json cloud_rsu classifier test
|
||||
python data_convertor.py config.json cloud_rsu regression train
|
||||
python data_convertor.py config.json cloud_rsu regression test
|
||||
python data_convertor.py config.json cloud_gsm classifier train
|
||||
python data_convertor.py config.json cloud_gsm classifier test
|
||||
python data_convertor.py config.json cloud_gsm regression train
|
||||
python data_convertor.py config.json cloud_gsm regression test
|
4
scripts/sample_app5/ai_trainer/generate_weka_models.sh
Normal file
4
scripts/sample_app5/ai_trainer/generate_weka_models.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
|
||||
javac -classpath "./json-simple-1.1.1.jar:../../../lib/weka.jar:../../../lib/mtj-1.0.4.jar" WekaModelCreator.java
|
||||
java -classpath ".:./json-simple-1.1.1.jar:../../../lib/weka.jar:../../../lib/mtj-1.0.4.jar" WekaModelCreator config.json
|
BIN
scripts/sample_app5/ai_trainer/json-simple-1.1.1.jar
Normal file
BIN
scripts/sample_app5/ai_trainer/json-simple-1.1.1.jar
Normal file
Binary file not shown.
4
scripts/sample_app5/compile.sh
Normal file
4
scripts/sample_app5/compile.sh
Normal file
@ -0,0 +1,4 @@
|
||||
#!/bin/sh
|
||||
rm -rf ../../bin
|
||||
mkdir ../../bin
|
||||
javac -classpath "../../lib/cloudsim-4.0.jar:../../lib/commons-math3-3.6.1.jar:../../lib/colt.jar:../../lib/weka.jar:../../lib/mtj-1.0.4.jar" -sourcepath ../../src ../../src/edu/boun/edgecloudsim/applications/vec_ai_app/VehicularMainApp.java -d ../../bin
|
51
scripts/sample_app5/config/applications.xml
Normal file
51
scripts/sample_app5/config/applications.xml
Normal file
@ -0,0 +1,51 @@
|
||||
<?xml version="1.0"?>
|
||||
<applications>
|
||||
<application name="TRAFFIC_MANAGEMENT">
|
||||
<usage_percentage>30</usage_percentage>
|
||||
<prob_cloud_selection>0</prob_cloud_selection>
|
||||
<delay_sensitivity>0.5</delay_sensitivity>
|
||||
<max_delay_requirement>0.5</max_delay_requirement>
|
||||
<poisson_interarrival>3</poisson_interarrival>
|
||||
<active_period>3600</active_period>
|
||||
<idle_period>1</idle_period>
|
||||
<data_upload>20</data_upload>
|
||||
<data_download>20</data_download>
|
||||
<task_length>3000</task_length>
|
||||
<required_core>1</required_core>
|
||||
<vm_utilization_on_edge>6</vm_utilization_on_edge>
|
||||
<vm_utilization_on_cloud>1.2</vm_utilization_on_cloud>
|
||||
<vm_utilization_on_mobile>0</vm_utilization_on_mobile>
|
||||
</application>
|
||||
<application name="DANGER_ASSESSMENT">
|
||||
<usage_percentage>35</usage_percentage>
|
||||
<prob_cloud_selection>0</prob_cloud_selection>
|
||||
<delay_sensitivity>0.8</delay_sensitivity>
|
||||
<max_delay_requirement>1</max_delay_requirement>
|
||||
<poisson_interarrival>5</poisson_interarrival>
|
||||
<active_period>3600</active_period>
|
||||
<idle_period>1</idle_period>
|
||||
<data_upload>40</data_upload>
|
||||
<data_download>20</data_download>
|
||||
<task_length>10000</task_length>
|
||||
<required_core>1</required_core>
|
||||
<vm_utilization_on_edge>20</vm_utilization_on_edge>
|
||||
<vm_utilization_on_cloud>4</vm_utilization_on_cloud>
|
||||
<vm_utilization_on_mobile>0</vm_utilization_on_mobile>
|
||||
</application>
|
||||
<application name="INFOTAINMENT">
|
||||
<usage_percentage>35</usage_percentage>
|
||||
<prob_cloud_selection>0</prob_cloud_selection>
|
||||
<delay_sensitivity>0.25</delay_sensitivity>
|
||||
<max_delay_requirement>1.5</max_delay_requirement>
|
||||
<poisson_interarrival>15</poisson_interarrival>
|
||||
<active_period>3600</active_period>
|
||||
<idle_period>1</idle_period>
|
||||
<data_upload>20</data_upload>
|
||||
<data_download>80</data_download>
|
||||
<task_length>20000</task_length>
|
||||
<required_core>1</required_core>
|
||||
<vm_utilization_on_edge>40</vm_utilization_on_edge>
|
||||
<vm_utilization_on_cloud>8</vm_utilization_on_cloud>
|
||||
<vm_utilization_on_mobile>0</vm_utilization_on_mobile>
|
||||
</application>
|
||||
</applications>
|
53
scripts/sample_app5/config/default_config.properties
Normal file
53
scripts/sample_app5/config/default_config.properties
Normal file
@ -0,0 +1,53 @@
|
||||
#default config file
|
||||
simulation_time=60
|
||||
warm_up_period=3
|
||||
file_log_enabled=true
|
||||
deep_file_log_enabled=false
|
||||
|
||||
#logging is disabled if it is 0
|
||||
vm_load_check_interval=0.025
|
||||
|
||||
#logging is disabled if it is 0
|
||||
location_check_interval=0.005
|
||||
|
||||
#logging is disabled if it is 0
|
||||
ap_delay_check_interval=0.1
|
||||
|
||||
min_number_of_mobile_devices=100
|
||||
max_number_of_mobile_devices=1800
|
||||
mobile_device_counter_size=100
|
||||
|
||||
wan_propogation_delay=0.15
|
||||
gsm_propogation_delay=0.16
|
||||
lan_internal_delay=0.01
|
||||
wlan_bandwidth=10
|
||||
man_bandwidth=1000
|
||||
wan_bandwidth=50
|
||||
gsm_bandwidth=20
|
||||
|
||||
#all the host on cloud runs on a single datacenter
|
||||
number_of_host_on_cloud_datacenter=1
|
||||
number_of_vm_on_cloud_host=20
|
||||
core_for_cloud_vm=2
|
||||
mips_for_cloud_vm=75000
|
||||
ram_for_cloud_vm=8000
|
||||
storage_for_cloud_vm=125000
|
||||
|
||||
#each mobile device has one host which serves one VM
|
||||
#all the host runs on a single datacenter due to the out of memory (oom) issue
|
||||
core_for_mobile_vm=1
|
||||
mips_for_mobile_vm=1000
|
||||
ram_for_mobile_vm=1800
|
||||
storage_for_mobile_vm=32000
|
||||
|
||||
#use ',' for multiple values
|
||||
#orchestrator_policies=AI_TRAINER,RANDOM,PREDICTIVE,MAB,AI_BASED
|
||||
orchestrator_policies=RANDOM,PREDICTIVE,GAME_THEORY,MAB,AI_BASED
|
||||
|
||||
#use ',' for multiple values
|
||||
simulation_scenarios=ITS_SCENARIO
|
||||
|
||||
#mean waiting time in seconds
|
||||
attractiveness_L1_mean_waiting_time=480
|
||||
attractiveness_L2_mean_waiting_time=240
|
||||
attractiveness_L3_mean_waiting_time=120
|
1364
scripts/sample_app5/config/edge_devices.xml
Normal file
1364
scripts/sample_app5/config/edge_devices.xml
Normal file
File diff suppressed because it is too large
Load Diff
BIN
scripts/sample_app5/config/weka/lr_cloud_gsm.model
Normal file
BIN
scripts/sample_app5/config/weka/lr_cloud_gsm.model
Normal file
Binary file not shown.
BIN
scripts/sample_app5/config/weka/lr_cloud_rsu.model
Normal file
BIN
scripts/sample_app5/config/weka/lr_cloud_rsu.model
Normal file
Binary file not shown.
BIN
scripts/sample_app5/config/weka/lr_edge.model
Normal file
BIN
scripts/sample_app5/config/weka/lr_edge.model
Normal file
Binary file not shown.
BIN
scripts/sample_app5/config/weka/mlp_cloud_gsm.model
Normal file
BIN
scripts/sample_app5/config/weka/mlp_cloud_gsm.model
Normal file
Binary file not shown.
BIN
scripts/sample_app5/config/weka/mlp_cloud_rsu.model
Normal file
BIN
scripts/sample_app5/config/weka/mlp_cloud_rsu.model
Normal file
Binary file not shown.
BIN
scripts/sample_app5/config/weka/mlp_edge.model
Normal file
BIN
scripts/sample_app5/config/weka/mlp_edge.model
Normal file
Binary file not shown.
60
scripts/sample_app5/matlab/getConfiguration.m
Normal file
60
scripts/sample_app5/matlab/getConfiguration.m
Normal file
@ -0,0 +1,60 @@
|
||||
%--------------------------------------------------------------
|
||||
%description
|
||||
% returns a value according to the given argumentssss
|
||||
%--------------------------------------------------------------
|
||||
function [ret_val] = getConfiguration(argType)
|
||||
if(argType == 1)
|
||||
ret_val = 'D:\sim_results';
|
||||
elseif(argType == 2)
|
||||
ret_val = 60; %simulation time (in minutes)
|
||||
elseif(argType == 3)
|
||||
ret_val = 2; %Number of iterations
|
||||
elseif(argType == 4)
|
||||
ret_val = 2; %x tick interval for number of mobile devices
|
||||
elseif(argType == 5)
|
||||
ret_val = {'AI_BASED','MAB','GAME_THEORY','PREDICTIVE','RANDOM'};
|
||||
elseif(argType == 6)
|
||||
ret_val = {'ML-based','MAB-based','Game-based','SMA-based','random'};
|
||||
elseif(argType == 7)
|
||||
ret_val=[6 3 11 11]; %position of figure
|
||||
%ret_val=[6 3 9 9]; %position of figure
|
||||
elseif(argType == 8)
|
||||
ret_val = [13 12 12]; %font fize for x/y label, lengend and x/y axis
|
||||
elseif(argType == 9)
|
||||
ret_val = 'Number of Vehicles'; %Common text for x axis
|
||||
elseif(argType == 10)
|
||||
ret_val = 100; %min number of mobile device
|
||||
elseif(argType == 11)
|
||||
ret_val = 100; %step size of mobile device count
|
||||
elseif(argType == 12)
|
||||
ret_val = 1800; %max number of mobile device
|
||||
elseif(argType == 17)
|
||||
ret_val = 0; %return 1 if you want to add 10^n text at x axis
|
||||
elseif(argType == 18)
|
||||
ret_val = 1; %return 1 if you want to save figure as pdf
|
||||
elseif(argType == 19)
|
||||
ret_val = 1; %return 1 if you want to plot errors
|
||||
elseif(argType == 20)
|
||||
ret_val=0; %return 1 if graph is plotted colerful
|
||||
elseif(argType == 21)
|
||||
ret_val=[0.55 0 0]; %color of first line
|
||||
elseif(argType == 22)
|
||||
ret_val=[0 0.15 0.6]; %color of second line
|
||||
elseif(argType == 23)
|
||||
ret_val=[0 0.23 0]; %color of third line
|
||||
elseif(argType == 24)
|
||||
ret_val=[0.6 0 0.6]; %color of fourth line
|
||||
elseif(argType == 25)
|
||||
ret_val=[0.08 0.08 0.08]; %color of fifth line
|
||||
elseif(argType == 26)
|
||||
ret_val=[0 0.8 0.8]; %color of sixth line
|
||||
elseif(argType == 27)
|
||||
ret_val=[0.8 0.4 0]; %color of seventh line
|
||||
elseif(argType == 28)
|
||||
ret_val=[0.8 0.8 0]; %color of eighth line
|
||||
elseif(argType == 40)
|
||||
ret_val={'-k*','-ko','-ks','-kv','-kp','-kd','-kx','-kh'}; %line style (marker) of the colerless line
|
||||
elseif(argType == 50)
|
||||
ret_val={'-k*','-ko','-ks','-kv','-kp','-kd','-kx','-kh'}; %line style (marker) of the colerfull line
|
||||
end
|
||||
end
|
113
scripts/sample_app5/matlab/plotApDelay.m
Normal file
113
scripts/sample_app5/matlab/plotApDelay.m
Normal file
@ -0,0 +1,113 @@
|
||||
function [] = plotApDelay()
|
||||
folderPath = getConfiguration(1);
|
||||
numOfSimulations = getConfiguration(3);
|
||||
stepOfxAxis = getConfiguration(4);
|
||||
startOfMobileDeviceLoop = getConfiguration(10);
|
||||
stepOfMobileDeviceLoop = getConfiguration(11);
|
||||
endOfMobileDeviceLoop = getConfiguration(12);
|
||||
numOfMobileDevices = (endOfMobileDeviceLoop - startOfMobileDeviceLoop)/stepOfMobileDeviceLoop + 1;
|
||||
placeTypes = {'AP 1 (60 km/h)','Ap 4 (40 km/h)','AP 11 (20 km/h)'};
|
||||
|
||||
results = zeros(size(placeTypes,2),numOfMobileDevices);
|
||||
|
||||
for s=1:numOfSimulations
|
||||
indexCounter = 1;
|
||||
for i=startOfMobileDeviceLoop:stepOfMobileDeviceLoop:endOfMobileDeviceLoop
|
||||
try
|
||||
filePath1 = strcat(folderPath,'\ite',int2str(s),'\SIMRESULT_ITS_SCENARIO_AI_BASED_',int2str(i),'DEVICES_AP_UPLOAD_DELAY.log');
|
||||
filePath2 = strcat(folderPath,'\ite',int2str(s),'\SIMRESULT_ITS_SCENARIO_AI_BASED_',int2str(i),'DEVICES_AP_DOWNLOAD_DELAY.log');
|
||||
readData1 = dlmread(filePath1,';',60,0);
|
||||
readData2 = dlmread(filePath2,';',60,0);
|
||||
|
||||
for j=1:size(placeTypes,2)
|
||||
results(j,indexCounter) = results(j,indexCounter) + mean(readData1(:,j+1)) + mean(readData2(:,j+1));
|
||||
end
|
||||
catch err
|
||||
error(err)
|
||||
end
|
||||
indexCounter = indexCounter + 1;
|
||||
end
|
||||
end
|
||||
results = results/numOfSimulations;
|
||||
|
||||
types = zeros(1,numOfMobileDevices);
|
||||
for i=1:numOfMobileDevices
|
||||
types(i)=startOfMobileDeviceLoop+((i-1)*stepOfMobileDeviceLoop);
|
||||
end
|
||||
|
||||
hFig = figure;
|
||||
pos=getConfiguration(7);
|
||||
fontSizeArray = getConfiguration(8);
|
||||
set(hFig, 'Units','centimeters');
|
||||
set(hFig, 'Position',pos);
|
||||
set(0,'DefaultAxesFontName','Times New Roman');
|
||||
set(0,'DefaultTextFontName','Times New Roman');
|
||||
set(0,'DefaultAxesFontSize',fontSizeArray(3));
|
||||
|
||||
if(getConfiguration(20) == 1)
|
||||
for i=stepOfxAxis:stepOfxAxis:numOfMobileDevices
|
||||
xIndex=startOfMobileDeviceLoop+((i-1)*stepOfMobileDeviceLoop);
|
||||
|
||||
markers = {':k*',':ko',':ks',':kv'};
|
||||
for j=1:size(placeTypes,2)
|
||||
plot(xIndex, results(j,i),char(markers(j)),'MarkerFaceColor',getConfiguration(20+j),'color',getConfiguration(20+j));
|
||||
hold on;
|
||||
end
|
||||
end
|
||||
|
||||
for j=1:size(placeTypes,2)
|
||||
plot(types, results(j,:),':k','color',getConfiguration(20+j),'LineWidth',1.5);
|
||||
hold on;
|
||||
end
|
||||
|
||||
set(gca,'color','none');
|
||||
else
|
||||
markers = {'-k*','-ko','-ks','-kv'};
|
||||
for j=1:size(placeTypes,2)
|
||||
plot(types, results(j,:),char(markers(j)),'MarkerFaceColor','w','LineWidth',1.4);
|
||||
hold on;
|
||||
end
|
||||
|
||||
%set(gcf, 'Position',getConfiguration(28));
|
||||
end
|
||||
|
||||
lgnd = legend(placeTypes,'Location','NorthWest');
|
||||
if(getConfiguration(20) == 1)
|
||||
set(lgnd,'color','none');
|
||||
end
|
||||
|
||||
if(getConfiguration(20) == 1)
|
||||
set(lgnd,'color','none');
|
||||
end
|
||||
|
||||
if(getConfiguration(17) == 0)
|
||||
manualXAxisCoefficent = 1;
|
||||
end
|
||||
|
||||
hold off;
|
||||
axis square
|
||||
xlabel(getConfiguration(9));
|
||||
set(gca,'XTick', startOfMobileDeviceLoop + stepOfMobileDeviceLoop:(stepOfxAxis*stepOfMobileDeviceLoop):endOfMobileDeviceLoop);
|
||||
set(gca,'XTickLabel', startOfMobileDeviceLoop + stepOfMobileDeviceLoop/manualXAxisCoefficent:(stepOfxAxis*stepOfMobileDeviceLoop)/manualXAxisCoefficent:endOfMobileDeviceLoop/manualXAxisCoefficent);
|
||||
ylabel('Average Network Delay (sec)');
|
||||
set(gca,'XLim',[startOfMobileDeviceLoop-5 endOfMobileDeviceLoop+5]);
|
||||
|
||||
if(getConfiguration(17) == 1)
|
||||
xlim = get(gca,'XLim');
|
||||
ylim = get(gca,'YLim');
|
||||
text(1.02 * xlim(2), 0.165 * ylim(2), 'x 10^2');
|
||||
end
|
||||
|
||||
set(get(gca,'Xlabel'),'FontSize',fontSizeArray(1));
|
||||
set(get(gca,'Ylabel'),'FontSize',fontSizeArray(1));
|
||||
set(lgnd,'FontSize',fontSizeArray(2));
|
||||
|
||||
if(getConfiguration(18) == 1)
|
||||
set(hFig, 'PaperUnits', 'centimeters');
|
||||
set(hFig, 'PaperPositionMode', 'manual');
|
||||
set(hFig, 'PaperPosition',[0 0 pos(3) pos(4)]);
|
||||
set(gcf, 'PaperSize', [pos(3) pos(4)]); %Keep the same paper size
|
||||
filename = strcat(folderPath,'\apDelay');
|
||||
saveas(gcf, filename, 'pdf');
|
||||
end
|
||||
end
|
8
scripts/sample_app5/matlab/plotAvgFailedTask.m
Normal file
8
scripts/sample_app5/matlab/plotAvgFailedTask.m
Normal file
@ -0,0 +1,8 @@
|
||||
function [] = plotAvgFailedTask()
|
||||
|
||||
plotGenericLine(1, 2, 'Average Failed Tasks (%)', 'ALL_APPS', 'NorthWest', 1);
|
||||
plotGenericLine(1, 2, 'Failed Tasks for Danger Assessment App (%)', 'DANGER_ASSESSMENT', 'NorthWest', 1);
|
||||
plotGenericLine(1, 2, 'Failed Tasks for Navigation App (%)', 'TRAFFIC_MANAGEMENT', 'NorthWest', 1);
|
||||
plotGenericLine(1, 2, 'Failed Tasks for Infotainment App (%)', 'INFOTAINMENT', 'NorthWest', 1);
|
||||
|
||||
end
|
11
scripts/sample_app5/matlab/plotAvgNetworkDelay.m
Normal file
11
scripts/sample_app5/matlab/plotAvgNetworkDelay.m
Normal file
@ -0,0 +1,11 @@
|
||||
function [] = plotAvgNetworkDelay()
|
||||
plotGenericLine(1, 7, 'Average Network Delay (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(5, 1, 'Average WLAN Delay (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(5, 2, 'Average MAN Delay (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(5, 3, 'Average WAN Delay (sec)', 'ALL_APPS', 'NorthWest', 0, 1, 1);
|
||||
|
||||
plotGenericLine(5, 4, 'Average GSM Delay (sec)', 'ALL_APPS', 'NorthWest', 0, 1, 1, 0, [4, 1700]);
|
||||
end
|
9
scripts/sample_app5/matlab/plotAvgProcessingTime.m
Normal file
9
scripts/sample_app5/matlab/plotAvgProcessingTime.m
Normal file
@ -0,0 +1,9 @@
|
||||
function [] = plotAvgProcessingTime()
|
||||
|
||||
plotGenericLine(1, 6, 'Average Processing Time (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(2, 6, 'Processing Time on RSU (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(3, 6, 'Processing Time on Cloud (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
end
|
8
scripts/sample_app5/matlab/plotAvgQoE.m
Normal file
8
scripts/sample_app5/matlab/plotAvgQoE.m
Normal file
@ -0,0 +1,8 @@
|
||||
function [] = plotAvgQoE()
|
||||
|
||||
plotGenericLine(1, 13, 'Average QoE (%)', 'ALL_APPS', 'SouthWest', 0);
|
||||
plotGenericLine(1, 13, 'QoE for Danger Assessment App (%)', 'DANGER_ASSESSMENT', 'SouthWest', 0);
|
||||
plotGenericLine(1, 13, 'QoE for Navigation App (%)', 'TRAFFIC_MANAGEMENT', 'SouthWest', 0);
|
||||
plotGenericLine(1, 13, 'QoE for Infotainment App (%)', 'INFOTAINMENT', 'SouthWest', 0);
|
||||
|
||||
end
|
9
scripts/sample_app5/matlab/plotAvgServiceTime.m
Normal file
9
scripts/sample_app5/matlab/plotAvgServiceTime.m
Normal file
@ -0,0 +1,9 @@
|
||||
function [] = plotAvgServiceTime()
|
||||
|
||||
plotGenericLine(1, 5, 'Average Service Time (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(2, 5, 'Service Time on RSU (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(3, 5, 'Service Time on Cloud (sec)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
end
|
7
scripts/sample_app5/matlab/plotAvgVmUtilization.m
Normal file
7
scripts/sample_app5/matlab/plotAvgVmUtilization.m
Normal file
@ -0,0 +1,7 @@
|
||||
function [] = plotAvgVmUtilization()
|
||||
|
||||
plotGenericLine(2, 8, 'Average VM Utilization of RSU (%)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
plotGenericLine(3, 8, 'Average VM Utilization of Cloud (%)', 'ALL_APPS', 'NorthWest', 0);
|
||||
|
||||
end
|
91
scripts/sample_app5/matlab/plotDelayReasonAsBar.m
Normal file
91
scripts/sample_app5/matlab/plotDelayReasonAsBar.m
Normal file
@ -0,0 +1,91 @@
|
||||
function [] = plotDelayReasonAsBar(isEdge)
|
||||
folderPath = getConfiguration(1);
|
||||
numOfSimulations = getConfiguration(3);
|
||||
stepOfxAxis = 3;%getConfiguration(4);
|
||||
startOfMobileDeviceLoop = getConfiguration(10);
|
||||
stepOfMobileDeviceLoop = getConfiguration(11);
|
||||
endOfMobileDeviceLoop = getConfiguration(12);
|
||||
numOfMobileDevices = (endOfMobileDeviceLoop - startOfMobileDeviceLoop)/stepOfMobileDeviceLoop + 1;
|
||||
|
||||
all_results = zeros(numOfSimulations, numOfMobileDevices, 2);
|
||||
|
||||
if ~exist('isEdge','var')
|
||||
isEdge = 1;
|
||||
end
|
||||
|
||||
for s=1:numOfSimulations
|
||||
for j=1:numOfMobileDevices
|
||||
try
|
||||
mobileDeviceNumber = startOfMobileDeviceLoop + stepOfMobileDeviceLoop * (j-1);
|
||||
filePath = strcat(folderPath,'\ite',int2str(s),'\SIMRESULT_ITS_SCENARIO_AI_BASED_',int2str(mobileDeviceNumber),'DEVICES_ALL_APPS_GENERIC.log');
|
||||
|
||||
readData = dlmread(filePath,';',1,0);
|
||||
value1 = 0;
|
||||
value2 = 0;
|
||||
if(isEdge == 1)
|
||||
value1 = readData(2,5);
|
||||
value2 = readData(2,6);
|
||||
else
|
||||
value1 = readData(3,5);
|
||||
value2 = readData(3,6);
|
||||
end
|
||||
|
||||
all_results(s,j,1) = value2;
|
||||
all_results(s,j,2) = value1 - value2;
|
||||
catch err
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if(numOfSimulations == 1)
|
||||
results = all_results;
|
||||
else
|
||||
results = mean(all_results); %still 3d matrix but 1xMxN format
|
||||
end
|
||||
|
||||
results = squeeze(results); %remove singleton dimensions
|
||||
|
||||
hFig=figure;
|
||||
pos=getConfiguration(7);
|
||||
set(hFig, 'Units','centimeters');
|
||||
set(hFig, 'Position',pos);
|
||||
set(0,'DefaultAxesFontName','Times New Roman');
|
||||
set(0,'DefaultTextFontName','Times New Roman');
|
||||
set(0,'DefaultAxesFontSize',11);
|
||||
set(0,'DefaultTextFontSize',12);
|
||||
|
||||
b = bar(results,'stacked');
|
||||
%set(b(1),'LineStyle','--');
|
||||
|
||||
if(isEdge == 1)
|
||||
lgnd = legend(b,{'processing time','WLAN delay'},'Location','NorthWest');
|
||||
ylabel({'Service Time on Edge (sec)'});
|
||||
filename = 'edge_delay_reason';
|
||||
else
|
||||
lgnd = legend(b,{'processing time','WAN delay'},'Location','NorthWest');
|
||||
ylabel({'Service Time on Cloud(sec)'});
|
||||
filename = 'cloud_delay_reason';
|
||||
end
|
||||
|
||||
set(b,{'FaceColor'},{[.45 .45 .45];[.90 .90 .90]});
|
||||
|
||||
axis square
|
||||
xlabel(getConfiguration(9));
|
||||
set(gca,'XTick', stepOfxAxis:stepOfxAxis:numOfMobileDevices);
|
||||
set(gca,'XTickLabel', (startOfMobileDeviceLoop*stepOfxAxis):(stepOfxAxis*stepOfMobileDeviceLoop):endOfMobileDeviceLoop);
|
||||
set(gca,'XLim',[0 numOfMobileDevices+1])
|
||||
|
||||
set(get(gca,'Xlabel'),'FontSize',12)
|
||||
set(get(gca,'Ylabel'),'FontSize',12)
|
||||
set(lgnd,'FontSize',12)
|
||||
|
||||
if(getConfiguration(18) == 1)
|
||||
set(hFig, 'PaperUnits', 'centimeters');
|
||||
set(hFig, 'PaperPositionMode', 'manual');
|
||||
set(hFig, 'PaperPosition',[0 0 pos(3) pos(4)]);
|
||||
set(gcf, 'PaperSize', [pos(3) pos(4)]); %Keep the same paper size
|
||||
filename = strcat(folderPath,'\',filename);
|
||||
saveas(gcf, filename, 'pdf');
|
||||
end
|
||||
end
|
198
scripts/sample_app5/matlab/plotGenericLine.m
Normal file
198
scripts/sample_app5/matlab/plotGenericLine.m
Normal file
@ -0,0 +1,198 @@
|
||||
function [] = plotGenericLine(rowOfset, columnOfset, yLabel, appType, legendPos, calculatePercentage, divisor, ignoreZeroValues, hideLowerValues, hideXAxis)
|
||||
folderPath = getConfiguration(1);
|
||||
numOfSimulations = getConfiguration(3);
|
||||
stepOfxAxis = getConfiguration(4);
|
||||
scenarioType = getConfiguration(5);
|
||||
startOfMobileDeviceLoop = getConfiguration(10);
|
||||
stepOfMobileDeviceLoop = getConfiguration(11);
|
||||
endOfMobileDeviceLoop = getConfiguration(12);
|
||||
numOfMobileDevices = (endOfMobileDeviceLoop - startOfMobileDeviceLoop)/stepOfMobileDeviceLoop + 1;
|
||||
|
||||
all_results = zeros(numOfSimulations, size(scenarioType,2), numOfMobileDevices);
|
||||
min_results = zeros(size(scenarioType,2), numOfMobileDevices);
|
||||
max_results = zeros(size(scenarioType,2), numOfMobileDevices);
|
||||
|
||||
if ~exist('appType','var')
|
||||
appType = 'ALL_APPS';
|
||||
end
|
||||
|
||||
if ~exist('divisor','var')
|
||||
divisor = 1;
|
||||
end
|
||||
|
||||
if ~exist('ignoreZeroValues','var')
|
||||
ignoreZeroValues = 0;
|
||||
end
|
||||
|
||||
if ~exist('hideLowerValues','var')
|
||||
hideLowerValues = 0;
|
||||
end
|
||||
|
||||
if exist('hideXAxis','var')
|
||||
hideXAxisStartValue = hideXAxis(2);
|
||||
hideXAxisIndex = hideXAxis(1);
|
||||
end
|
||||
|
||||
for s=1:numOfSimulations
|
||||
for i=1:size(scenarioType,2)
|
||||
for j=1:numOfMobileDevices
|
||||
try
|
||||
mobileDeviceNumber = startOfMobileDeviceLoop + stepOfMobileDeviceLoop * (j-1);
|
||||
filePath = strcat(folderPath,'\ite',int2str(s),'\SIMRESULT_ITS_SCENARIO_',char(scenarioType(i)),'_',int2str(mobileDeviceNumber),'DEVICES_',appType,'_GENERIC.log');
|
||||
|
||||
readData = dlmread(filePath,';',rowOfset,0);
|
||||
value = readData(1,columnOfset);
|
||||
if(calculatePercentage==1)
|
||||
readData = dlmread(filePath,';',1,0);
|
||||
totalTask = readData(1,1)+readData(1,2);
|
||||
value = (100 * value) / totalTask;
|
||||
end
|
||||
|
||||
all_results(s,i,j) = value;
|
||||
catch err
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if(numOfSimulations == 1)
|
||||
results = all_results;
|
||||
else
|
||||
if(ignoreZeroValues == 1)
|
||||
results = sum(all_results,1) ./ sum(all_results~=0,1);
|
||||
%TODO cahnge NaN to 0
|
||||
else
|
||||
results = mean(all_results); %still 3d matrix but 1xMxN format
|
||||
end
|
||||
end
|
||||
|
||||
results = squeeze(results); %remove singleton dimensions
|
||||
|
||||
for i=1:size(scenarioType,2)
|
||||
for j=1:numOfMobileDevices
|
||||
if(results(i,j) < hideLowerValues)
|
||||
results(i,j) = NaN;
|
||||
else
|
||||
results(i,j) = results(i,j) / divisor;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
if exist('hideXAxis','var')
|
||||
for j=1:numOfMobileDevices
|
||||
if(j*stepOfMobileDeviceLoop+startOfMobileDeviceLoop > hideXAxisStartValue)
|
||||
results(hideXAxisIndex,j) = NaN;
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
for i=1:size(scenarioType,2)
|
||||
for j=1:numOfMobileDevices
|
||||
x=results(i,j); % Create Data
|
||||
SEM = std(x)/sqrt(length(x)); % Standard Error
|
||||
ts = tinv([0.05 0.95],length(x)-1); % T-Score
|
||||
CI = mean(x) + ts*SEM; % Confidence Intervals
|
||||
|
||||
if(CI(1) < 0)
|
||||
CI(1) = 0;
|
||||
end
|
||||
|
||||
if(CI(2) < 0)
|
||||
CI(2) = 0;
|
||||
end
|
||||
|
||||
min_results(i,j) = results(i,j) - CI(1);
|
||||
max_results(i,j) = CI(2) - results(i,j);
|
||||
end
|
||||
end
|
||||
|
||||
types = zeros(1,numOfMobileDevices);
|
||||
for i=1:numOfMobileDevices
|
||||
types(i)=startOfMobileDeviceLoop+((i-1)*stepOfMobileDeviceLoop);
|
||||
end
|
||||
|
||||
hFig = figure;
|
||||
pos=getConfiguration(7);
|
||||
fontSizeArray = getConfiguration(8);
|
||||
set(hFig, 'Units','centimeters');
|
||||
set(hFig, 'Position',pos);
|
||||
set(0,'DefaultAxesFontName','Times New Roman');
|
||||
set(0,'DefaultTextFontName','Times New Roman');
|
||||
set(0,'DefaultAxesFontSize',fontSizeArray(3));
|
||||
|
||||
if(getConfiguration(20) == 1)
|
||||
for i=1:1:numOfMobileDevices
|
||||
xIndex=startOfMobileDeviceLoop+((i-1)*stepOfMobileDeviceLoop);
|
||||
|
||||
markers = getConfiguration(50);
|
||||
for j=1:size(scenarioType,2)
|
||||
plot(xIndex, results(j,i),char(markers(j)),'MarkerFaceColor',getConfiguration(20+j),'color',getConfiguration(20+j));
|
||||
hold on;
|
||||
end
|
||||
end
|
||||
|
||||
for j=1:size(scenarioType,2)
|
||||
if(getConfiguration(19) == 1)
|
||||
errorbar(types, results(j,:), min_results(j,:),max_results(j,:),'-k','color',getConfiguration(20+j),'LineWidth',1);
|
||||
else
|
||||
plot(types, results(j,:),'-k','color',getConfiguration(20+j),'LineWidth',1);
|
||||
end
|
||||
hold on;
|
||||
end
|
||||
|
||||
set(gca,'color','none');
|
||||
else
|
||||
markers = getConfiguration(40);
|
||||
for j=1:size(scenarioType,2)
|
||||
if(getConfiguration(19) == 1)
|
||||
errorbar(types, results(j,:),min_results(j,:),max_results(j,:),char(markers(j)),'MarkerFaceColor','w','LineWidth',1);
|
||||
else
|
||||
plot(types, results(j,:),char(markers(j)),'MarkerFaceColor','w');
|
||||
end
|
||||
hold on;
|
||||
end
|
||||
|
||||
end
|
||||
|
||||
legends = getConfiguration(6);
|
||||
lgnd = legend(legends,'Location',legendPos);
|
||||
%lgnd.Position=[0.21,0.8,0.2,0.01];
|
||||
if(getConfiguration(20) == 1)
|
||||
set(lgnd,'color','none');
|
||||
end
|
||||
|
||||
xCoefficent = 100;
|
||||
if(getConfiguration(17) == 0)
|
||||
xCoefficent = 1;
|
||||
end
|
||||
|
||||
hold off;
|
||||
axis square
|
||||
xlabel(getConfiguration(9));
|
||||
step = stepOfxAxis*stepOfMobileDeviceLoop;
|
||||
set(gca,'XTick', step:step:endOfMobileDeviceLoop);
|
||||
set(gca,'XTickLabel', step/xCoefficent:step/xCoefficent:endOfMobileDeviceLoop/xCoefficent);
|
||||
ylabel(yLabel);
|
||||
set(gca,'XLim',[startOfMobileDeviceLoop-5 endOfMobileDeviceLoop+5]);
|
||||
|
||||
if(getConfiguration(17) == 1)
|
||||
xlim = get(gca,'XLim');
|
||||
ylim = get(gca,'YLim');
|
||||
text(1.02 * xlim(2), 0.165 * ylim(2), 'x 10^2');
|
||||
end
|
||||
|
||||
|
||||
set(get(gca,'Xlabel'),'FontSize',fontSizeArray(1));
|
||||
set(get(gca,'Ylabel'),'FontSize',fontSizeArray(1));
|
||||
set(lgnd,'FontSize',fontSizeArray(2));
|
||||
|
||||
if(getConfiguration(18) == 1)
|
||||
set(hFig, 'PaperUnits', 'centimeters');
|
||||
set(hFig, 'PaperPositionMode', 'manual');
|
||||
set(hFig, 'PaperPosition',[0 0 pos(3) pos(4)]);
|
||||
set(gcf, 'PaperSize', [pos(3) pos(4)]); %Keep the same paper size
|
||||
filename = strcat(folderPath,'\',int2str(rowOfset),'_',int2str(columnOfset),'_',appType);
|
||||
saveas(gcf, filename, 'pdf');
|
||||
end
|
||||
end
|
78
scripts/sample_app5/matlab/plotGenericPie.m
Normal file
78
scripts/sample_app5/matlab/plotGenericPie.m
Normal file
@ -0,0 +1,78 @@
|
||||
function [] = plotGenericPie(vmType, appType, threshold)
|
||||
folderPath = "D:\git-repos\PhD\EdgeCloudSim\sim_results";
|
||||
scenarioType = getConfiguration(5);
|
||||
startOfMobileDeviceLoop = 2000;
|
||||
stepOfMobileDeviceLoop = 2000;
|
||||
endOfMobileDeviceLoop = 2000;
|
||||
numOfMobileDevices = (endOfMobileDeviceLoop - startOfMobileDeviceLoop)/stepOfMobileDeviceLoop + 1;
|
||||
|
||||
if ~exist('appType','var')
|
||||
appType = 1;
|
||||
end
|
||||
|
||||
if ~exist('vmType','var')
|
||||
vmType = 'edge';
|
||||
end
|
||||
|
||||
total = zeros(1,size(scenarioType,2));
|
||||
found = zeros(1,size(scenarioType,2));
|
||||
|
||||
for s=1:size(scenarioType,2)
|
||||
for j=1:numOfMobileDevices
|
||||
try
|
||||
mobileDeviceNumber = startOfMobileDeviceLoop + stepOfMobileDeviceLoop * (j-1);
|
||||
filePath = strcat(folderPath,'\ite11\SIMRESULT_ITS_SCENARIO_',char(scenarioType(s)),'_',int2str(mobileDeviceNumber),'DEVICES_SUCCESS.log');
|
||||
|
||||
readData = dlmread(filePath,';',1,0);
|
||||
for k=1:size(readData,1)
|
||||
if(readData(k,7) == appType && ((strcmp(vmType,'edge') == 1 && readData(k,3) == 3) || (strcmp(vmType,'cloud') == 1 && readData(k,3) ~= 3) || strcmp(vmType,'all')==1))
|
||||
if(readData(k,12) - readData(k,11) > threshold)
|
||||
found(s) = found(s) + 1;
|
||||
end
|
||||
total(s) = total(s) + 1;
|
||||
end
|
||||
end
|
||||
catch err
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hFig = figure;
|
||||
pos=getConfiguration(7);
|
||||
fontSizeArray = getConfiguration(8);
|
||||
set(hFig, 'Units','centimeters');
|
||||
set(hFig, 'Position',pos);
|
||||
set(0,'DefaultAxesFontName','Times New Roman');
|
||||
set(0,'DefaultTextFontName','Times New Roman');
|
||||
set(0,'DefaultAxesFontSize',fontSizeArray(3));
|
||||
|
||||
if(getConfiguration(20) == 1)
|
||||
%result = found ./ total .* 100;
|
||||
p = pie(found);
|
||||
hold on;
|
||||
end
|
||||
|
||||
txt = reshape(getConfiguration(6),[size(scenarioType,2) 1]);
|
||||
pText = findobj(p,'Type','text');
|
||||
percentValues = get(pText,'String');
|
||||
combinedtxt = strcat(txt,' (',percentValues,')');
|
||||
|
||||
for i=1:size(scenarioType,2)
|
||||
pText(i).String = combinedtxt(i);
|
||||
end
|
||||
|
||||
set(pText,'fontsize',fontSizeArray(1))
|
||||
|
||||
hold off;
|
||||
axis square
|
||||
|
||||
if(getConfiguration(18) == 1)
|
||||
set(hFig, 'PaperUnits', 'centimeters');
|
||||
set(hFig, 'PaperPositionMode', 'manual');
|
||||
set(hFig, 'PaperPosition',[0 0 pos(3) pos(4)]);
|
||||
set(gcf, 'PaperSize', [pos(3) pos(4)]); %Keep the same paper size
|
||||
filename = strcat(folderPath,'\',int2str(rowOfset),'_',int2str(columnOfset),'_',appType);
|
||||
saveas(gcf, filename, 'pdf');
|
||||
end
|
||||
end
|
96
scripts/sample_app5/matlab/plotGenericScatter.m
Normal file
96
scripts/sample_app5/matlab/plotGenericScatter.m
Normal file
@ -0,0 +1,96 @@
|
||||
function [] = plotGenericScatter(yLabel, xLabel, legendPos, vmType, appType, drawLine)
|
||||
folderPath = "D:\git-repos\PhD\EdgeCloudSim\sim_results";
|
||||
scenarioType = getConfiguration(5);
|
||||
simulationTime = getConfiguration(2);
|
||||
startOfMobileDeviceLoop = 2000;
|
||||
stepOfMobileDeviceLoop = 2000;
|
||||
endOfMobileDeviceLoop = 2000;
|
||||
numOfMobileDevices = (endOfMobileDeviceLoop - startOfMobileDeviceLoop)/stepOfMobileDeviceLoop + 1;
|
||||
|
||||
if ~exist('appType','var')
|
||||
appType = 1;
|
||||
end
|
||||
|
||||
if ~exist('vmType','var')
|
||||
vmType = 'edge';
|
||||
end
|
||||
|
||||
result_x = NaN(size(scenarioType,2), 5000);
|
||||
result_y = NaN(size(result_x,1), size(result_x,2));
|
||||
%result_sz = NaN(size(result_x,1), size(result_x,2));
|
||||
|
||||
for s=1:size(scenarioType,2)
|
||||
index = 1;
|
||||
firstDeviceId = -1;
|
||||
for j=1:numOfMobileDevices
|
||||
try
|
||||
mobileDeviceNumber = startOfMobileDeviceLoop + stepOfMobileDeviceLoop * (j-1);
|
||||
filePath = strcat(folderPath,'\ite11\SIMRESULT_ITS_SCENARIO_',char(scenarioType(s)),'_',int2str(mobileDeviceNumber),'DEVICES_SUCCESS.log');
|
||||
|
||||
readData = dlmread(filePath,';',1,0);
|
||||
for k=1:size(readData,1)
|
||||
if(readData(k,7) == appType && ((strcmp(vmType,'edge') == 1 && readData(k,3) == 3) || (strcmp(vmType,'cloud') == 1 && readData(k,3) ~= 3) || strcmp(vmType,'all')==1))
|
||||
if(firstDeviceId == -1)
|
||||
firstDeviceId = readData(k,2);
|
||||
end
|
||||
if(readData(k,2) == firstDeviceId) % && readData(k,11) - readData(k,10) < 2
|
||||
result_y(s, index) = readData(k,12) - readData(k,11);
|
||||
result_x(s, index) = readData(k,12) / 60;
|
||||
%result_sz(s, index) = j*10;
|
||||
index = index + 1;
|
||||
end
|
||||
end
|
||||
end
|
||||
catch err
|
||||
error(err)
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
hFig = figure;
|
||||
pos=getConfiguration(7);
|
||||
fontSizeArray = getConfiguration(8);
|
||||
set(hFig, 'Units','centimeters');
|
||||
set(hFig, 'Position',pos);
|
||||
set(0,'DefaultAxesFontName','Times New Roman');
|
||||
set(0,'DefaultTextFontName','Times New Roman');
|
||||
set(0,'DefaultAxesFontSize',fontSizeArray(3));
|
||||
|
||||
if(getConfiguration(20) == 1)
|
||||
for i=1:size(scenarioType,2)
|
||||
scatter(result_x(i,:), result_y(i,:));
|
||||
hold on;
|
||||
end
|
||||
|
||||
if exist('drawLine','var')
|
||||
y = [drawLine, drawLine];
|
||||
x = [0, simulationTime];
|
||||
plot(x,y);
|
||||
end
|
||||
end
|
||||
|
||||
legends = getConfiguration(6);
|
||||
lgnd = legend(legends,'Location',legendPos);
|
||||
%lgnd.Position=[0.21,0.8,0.2,0.01];
|
||||
if(getConfiguration(20) == 1)
|
||||
set(lgnd,'color','none');
|
||||
end
|
||||
|
||||
hold off;
|
||||
axis square
|
||||
xlabel(xLabel);
|
||||
ylabel(yLabel);
|
||||
|
||||
set(get(gca,'Xlabel'),'FontSize',fontSizeArray(1));
|
||||
set(get(gca,'Ylabel'),'FontSize',fontSizeArray(1));
|
||||
set(lgnd,'FontSize',fontSizeArray(2));
|
||||
|
||||
if(getConfiguration(18) == 1)
|
||||
set(hFig, 'PaperUnits', 'centimeters');
|
||||
set(hFig, 'PaperPositionMode', 'manual');
|
||||
set(hFig, 'PaperPosition',[0 0 pos(3) pos(4)]);
|
||||
set(gcf, 'PaperSize', [pos(3) pos(4)]); %Keep the same paper size
|
||||
filename = strcat(folderPath,'\',int2str(rowOfset),'_',int2str(columnOfset),'_',appType);
|
||||
saveas(gcf, filename, 'pdf');
|
||||
end
|
||||
end
|
66
scripts/sample_app5/matlab/plotLocation.m
Normal file
66
scripts/sample_app5/matlab/plotLocation.m
Normal file
@ -0,0 +1,66 @@
|
||||
function [] = plotLocation()
|
||||
folderPath = getConfiguration(1);
|
||||
numOfSimulations = getConfiguration(3);
|
||||
stepOfxAxis = getConfiguration(4);
|
||||
startOfMobileDeviceLoop = 500;
|
||||
stepOfMobileDeviceLoop = 500;
|
||||
endOfMobileDeviceLoop = 1500;
|
||||
numOfMobileDevices = (endOfMobileDeviceLoop - startOfMobileDeviceLoop)/stepOfMobileDeviceLoop + 1;
|
||||
PlaceCount = 40;
|
||||
|
||||
results = zeros(numOfMobileDevices, PlaceCount);
|
||||
|
||||
for s=1:numOfSimulations
|
||||
indexCounter = 1;
|
||||
for i=startOfMobileDeviceLoop:stepOfMobileDeviceLoop:endOfMobileDeviceLoop
|
||||
try
|
||||
filePath = strcat(folderPath,'\ite',int2str(s),'\SIMRESULT_ITS_SCENARIO_AI_BASED_',int2str(i),'DEVICES_LOCATION.log');
|
||||
readData = dlmread(filePath,';',1,0);
|
||||
|
||||
for j=1:PlaceCount
|
||||
results(indexCounter,j) = results(indexCounter,j) + mean(readData(:,j+1));
|
||||
end
|
||||
catch err
|
||||
error(err)
|
||||
end
|
||||
indexCounter = indexCounter + 1;
|
||||
end
|
||||
end
|
||||
results = results/numOfSimulations;
|
||||
|
||||
xValues = {};
|
||||
yValues = {};
|
||||
|
||||
indexCounter = 1;
|
||||
for i=startOfMobileDeviceLoop:stepOfMobileDeviceLoop:endOfMobileDeviceLoop
|
||||
xValues(indexCounter) = {int2str(i)};
|
||||
indexCounter = indexCounter + 1;
|
||||
end
|
||||
for i=1:PlaceCount
|
||||
yValues(i) = {int2str(i)}
|
||||
end
|
||||
|
||||
hFig=figure;
|
||||
%pos=getConfiguration(7);
|
||||
pos=[10 3 24 6];
|
||||
set(hFig, 'Units','centimeters');
|
||||
set(hFig, 'Position',pos);
|
||||
|
||||
C = [0,172,0;2,171,0;5,171,0;7,171,0;10,171,0;12,171,0;15,171,0;17,171,0;20,171,0;22,171,0;25,170,0;27,170,0;30,170,0;32,170,0;35,170,0;37,170,0;40,170,0;42,170,0;45,170,0;47,169,0;50,169,0;52,169,0;55,169,0;57,169,0;60,169,0;62,169,0;65,169,0;67,169,0;70,168,0;72,168,0;75,168,0;77,168,0;80,168,0;82,168,0;85,168,0;87,168,0;90,168,0;92,168,0;95,167,0;97,167,0;100,167,0;102,167,0;105,167,0;107,167,0;110,167,0;112,167,0;115,167,0;117,166,0;120,166,0;122,166,0;125,166,0;127,166,0;130,166,0;132,166,0;135,166,0;137,166,0;140,165,0;142,165,0;145,165,0;147,165,0;150,165,0;152,165,0;155,165,0;157,165,0;159,164,0;160,164,0;161,163,0;162,162,0;163,162,0;163,161,0;164,160,0;165,159,0;166,159,0;167,158,0;168,157,0;168,157,0;169,156,0;170,155,0;171,154,0;172,154,0;172,153,0;173,152,0;174,152,0;175,151,0;176,150,0;176,149,0;177,149,0;178,148,0;179,147,0;180,147,0;181,146,0;181,145,0;182,144,0;183,144,0;184,143,0;185,142,0;185,142,0;186,141,0;187,140,0;188,139,0;189,139,0;189,138,0;190,137,0;191,137,0;192,136,0;193,135,0;193,134,0;194,134,0;195,133,0;196,132,0;197,132,0;198,131,0;198,130,0;199,129,0;200,129,0;201,128,0;202,127,0;202,127,0;203,126,0;204,125,0;205,124,0;206,124,0;206,123,0;207,122,0;208,122,0;209,121,0;210,120,0;211,119,0;211,119,0;211,118,0;211,117,0;210,116,0;210,115,0;210,114,0;210,113,0;210,112,0;210,111,0;209,110,0;209,109,0;209,108,0;209,107,0;209,106,0;208,105,0;208,104,0;208,103,0;208,102,0;208,102,0;208,101,0;207,100,0;207,99,0;207,98,0;207,97,0;207,96,0;207,95,0;206,94,0;206,93,0;206,92,0;206,91,0;206,90,0;206,89,0;205,88,0;205,87,0;205,86,0;205,85,0;205,84,0;205,84,0;204,83,0;204,82,0;204,81,0;204,80,0;204,79,0;204,78,0;203,77,0;203,76,0;203,75,0;203,74,0;203,73,0;203,72,0;202,71,0;202,70,0;202,69,0;202,68,0;202,67,0;202,67,0;201,66,0;201,65,0;201,64,0;201,63,0;201,62,0;201,61,0;200,60,0;200,59,0;199,58,0;198,57,0;197,56,0;196,55,0;195,54,0;194,53,0;193,53,0;192,52,0;191,51,0;190,50,0;189,49,0;188,48,0;187,47,0;186,46,0;185,45,0;184,44,0;183,43,0;182,42,0;181,41,0;180,41,0;179,40,0;177,39,0;176,38,0;175,37,0;174,36,0;173,35,0;172,34,0;171,33,0;170,32,0;169,31,0;168,30,0;167,29,0;166,29,0;165,28,0;164,27,0;163,26,0;162,25,0;161,24,0;160,23,0;159,22,0;158,21,0;157,20,0;156,19,0;155,18,0;153,18,0;152,17,0;151,16,0;150,15,0;149,14,0;148,13,0;147,12,0;146,11,0;145,10,0;144,9,0;143,8,0;142,7,0;141,6,0;140,6,0;139,5,0;138,4,0;137,3,0;136,2,0;135,1,0;134,0,0];
|
||||
|
||||
h = heatmap(yValues, xValues, results, 'Colormap', colormap(C/255),'FontName','Times New Roman','FontSize',11);
|
||||
|
||||
h.Title = 'Mean number of vehicles per places';
|
||||
h.XLabel = 'Place IDs';
|
||||
h.YLabel = '#Vehicle in simulation';
|
||||
|
||||
if(getConfiguration(18) == 1)
|
||||
set(hFig, 'PaperUnits', 'centimeters');
|
||||
set(hFig, 'PaperPositionMode', 'manual');
|
||||
set(hFig, 'PaperPosition',[0 0 pos(3) pos(4)]);
|
||||
set(gcf, 'PaperSize', [pos(3) pos(4)]); %Keep the same paper size
|
||||
filename = strcat(folderPath,'\position');
|
||||
saveas(gcf, filename, 'pdf');
|
||||
end
|
||||
|
||||
end
|
15
scripts/sample_app5/matlab/plotTaskFailureReason.m
Normal file
15
scripts/sample_app5/matlab/plotTaskFailureReason.m
Normal file
@ -0,0 +1,15 @@
|
||||
function [] = plotTaskFailureReason()
|
||||
|
||||
plotGenericLine(1, 10, 'Failed Task due to VM Capacity (%)', 'ALL_APPS', 'NorthWest', 1);
|
||||
|
||||
plotGenericLine(1, 11, 'Failed Task due to Mobility (%)', 'ALL_APPS', 'NorthWest', 1);
|
||||
|
||||
plotGenericLine(5, 5, 'Failed Tasks due to WLAN (%)', 'ALL_APPS', 'NorthWest', 1);
|
||||
|
||||
plotGenericLine(5, 6, 'Failed Tasks due to MAN failure (%)', 'ALL_APPS', 'NorthWest', 1);
|
||||
|
||||
plotGenericLine(5, 7, 'Failed Tasks due to WAN failure (%)', 'ALL_APPS', 'NorthWest', 1);
|
||||
|
||||
plotGenericLine(5, 8, 'Failed Tasks due to GSM failure (%)', 'ALL_APPS', 'NorthEast', 1);
|
||||
|
||||
end
|
7
scripts/sample_app5/matlab/plotTimeComplexity.m
Normal file
7
scripts/sample_app5/matlab/plotTimeComplexity.m
Normal file
@ -0,0 +1,7 @@
|
||||
function [] = plotTimeComplexity()
|
||||
|
||||
plotGenericLine(6, 1, 'Simulation Time (minute)', 'ALL_APPS', 'NorthWest', 0, 60);
|
||||
|
||||
plotGenericLine(6, 2, 'Orchestration Algorithm Overhead (micro second)', 'ALL_APPS', 'NorthEast', 0, 1000);
|
||||
|
||||
end
|
75
scripts/sample_app5/run_scenarios.sh
Normal file
75
scripts/sample_app5/run_scenarios.sh
Normal file
@ -0,0 +1,75 @@
|
||||
#!/bin/bash
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Missing arguments! Please provide number of parallel processes and number of iterations."
|
||||
echo "Usage: '$0 4 10'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
re='^[0-9]+$'
|
||||
if ! [[ $1 =~ $re ]] ; then
|
||||
echo "$1 is not an integer! Please provide number of parallel processes."
|
||||
echo "Usage: '$0 4 10'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
if ! [[ $2 =~ $re ]] ; then
|
||||
echo "$1 is not an integer! Please provide number of iterations."
|
||||
echo "Usage: '$0 4 10'"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
script_root_path="$(dirname "$(readlink -f "$0")")"
|
||||
root_out_folder=${script_root_path}/output
|
||||
num_of_processes=$1
|
||||
iterationNumber=$2
|
||||
process_counter=0
|
||||
|
||||
date=$(date '+%d-%m-%Y_%H-%M')
|
||||
simulation_out_folder=${root_out_folder}/${date}
|
||||
mkdir -p $simulation_out_folder
|
||||
|
||||
simulations=$(cat ${script_root_path}/simulation.list)
|
||||
|
||||
rm -rf ${script_root_path}/tmp_runner*
|
||||
|
||||
for sim_args in $simulations
|
||||
do
|
||||
scenario_name=$(echo $sim_args | cut -d ';' -f1)
|
||||
edge_devices_file=$(echo $sim_args | cut -d ';' -f2)
|
||||
applications_file=$(echo $sim_args | cut -d ';' -f3)
|
||||
mkdir -p $simulation_out_folder/${scenario_name}
|
||||
echo "STARTED" > $simulation_out_folder/${scenario_name}/progress.log
|
||||
|
||||
for (( i=1; i<=$iterationNumber; i++ ))
|
||||
do
|
||||
process_id=$(($process_counter % $num_of_processes))
|
||||
process_counter=$(($process_counter + 1))
|
||||
|
||||
echo "${script_root_path}/runner.sh $simulation_out_folder $scenario_name $edge_devices_file $applications_file ${i}" >> "${simulation_out_folder}/tmp_runner${process_id}.sh"
|
||||
done
|
||||
done
|
||||
|
||||
#num_of_cores=$(grep -c ^processor /proc/cpuinfo)
|
||||
|
||||
for (( i=0; i<$num_of_processes; i++ ))
|
||||
do
|
||||
chmod +x ${simulation_out_folder}/tmp_runner${i}.sh
|
||||
${simulation_out_folder}/tmp_runner${i}.sh &
|
||||
# pid=$!
|
||||
# cpu=$(($i % $num_of_cores))
|
||||
# taskset -cp $cpu,$cpu $pid
|
||||
done
|
||||
|
||||
echo "###############################################################"
|
||||
echo " SIMULARIONS ARE STARTED!"
|
||||
echo "###############################################################"
|
||||
echo "You can follow the progress via the following command"
|
||||
echo "tail -f <scenario_folder>/progress.log"
|
||||
echo "e.g."
|
||||
echo "tail -f output/${date}/${scenario_name}/progress.log"
|
||||
echo "###############################################################"
|
||||
echo "You can inspect each iteration via the following command"
|
||||
echo "tail -f <scenario_folder>/ite[n].log"
|
||||
echo "e.g."
|
||||
echo "tail -f output/${date}/${scenario_name}/ite1.log"
|
||||
echo "###############################################################"
|
25
scripts/sample_app5/runner.sh
Normal file
25
scripts/sample_app5/runner.sh
Normal file
@ -0,0 +1,25 @@
|
||||
#!/bin/sh
|
||||
|
||||
script_root_path="$(dirname "$(readlink -f "$0")")"
|
||||
simulation_out_folder=$1
|
||||
scenario_name=$2
|
||||
edge_devices_file=$3
|
||||
applications_file=$4
|
||||
iteration_number=$5
|
||||
|
||||
scenario_out_folder=${simulation_out_folder}/${scenario_name}/ite${iteration_number}
|
||||
scenario_conf_file=${script_root_path}/config/${scenario_name}.properties
|
||||
scenario_edge_devices_file=${script_root_path}/config/${edge_devices_file}
|
||||
scenario_applications_file=${script_root_path}/config/${applications_file}
|
||||
|
||||
mkdir -p $scenario_out_folder
|
||||
java -classpath '../../bin:../../lib/cloudsim-4.0.jar:../../lib/commons-math3-3.6.1.jar:../../lib/colt.jar:../../lib/weka.jar:../../lib/mtj-1.0.4.jar' -Djava.library.path=../../lib/native/linux edu.boun.edgecloudsim.applications.vec_ai_app.VehicularMainApp $scenario_conf_file $scenario_edge_devices_file $scenario_applications_file $scenario_out_folder $iteration_number > ${scenario_out_folder}.log
|
||||
|
||||
if [ $? -eq 0 ]; then
|
||||
echo "ite${iteration_number} OK" >> ${simulation_out_folder}/${scenario_name}/progress.log
|
||||
else
|
||||
echo "ite${iteration_number} FAIL !!!" >> ${simulation_out_folder}/${scenario_name}/progress.log
|
||||
fi
|
||||
|
||||
#tar -czf ${scenario_out_folder}.tar.gz -C $simulation_out_folder/${scenario_name} ite${iteration_number}
|
||||
#rm -rf $scenario_out_folder
|
1
scripts/sample_app5/simulation.list
Normal file
1
scripts/sample_app5/simulation.list
Normal file
@ -0,0 +1 @@
|
||||
default_config;edge_devices.xml;applications.xml
|
15
scripts/sample_app5/stop_scenarios.sh
Normal file
15
scripts/sample_app5/stop_scenarios.sh
Normal file
@ -0,0 +1,15 @@
|
||||
#!/bin/sh
|
||||
|
||||
echo "This script kills all java processes including Eclipse etc."
|
||||
read -p "Do you want to continue[y/n]? " REPLY
|
||||
|
||||
if [ "$REPLY" = "y" ]
|
||||
then
|
||||
while pgrep java >/dev/null 2>&1
|
||||
do
|
||||
killall java
|
||||
sleep 1
|
||||
done
|
||||
fi
|
||||
|
||||
echo "Operation completed. bye..."
|
Reference in New Issue
Block a user