use of kr.ac.kaist.se.simulator.Simulator in project SIMVA-SoS by SESoS.
the class RobotMain method main.
public static void main(String[] args) throws IOException {
RobotScenario robot = new RobotScenario(0);
Simulator sim = new Simulator(robot);
BaseChecker checker = new BaseChecker();
checker.init(sim.getScenario().getEndTick(), 3, BaseChecker.comparisonType.EQUAL_TO);
SPRTMethod sprt = new SPRTMethod(0.05, 0.05, 0.01);
sprt.setLessCheck();
for (int j = 0; j < 10; j++) {
String outputName = "robot_result/SIM_robot_" + (j + 1) + ".csv";
CSVWriter cw = new CSVWriter(new OutputStreamWriter(new FileOutputStream(outputName), "UTF-8"), ',', '"');
cw.writeNext(new String[] { "prob", "num_of_samples", "result" });
ArrayList<RobotResult> resList = new ArrayList<>();
for (int trial = 1; trial <= 200; trial++) {
for (int i = 1; i < 100; i++) {
double theta = 0.01 * i;
sprt.setExpression(theta);
while (!sprt.checkStopCondition()) {
sim.execute();
System.out.println(checker.evaluateSample(sim.getResult()));
int result = checker.evaluateSample(sim.getResult());
if (result == 1)
result = 0;
else
result = 1;
sprt.updateResult(result);
sim.reset();
}
// Result
boolean h0 = sprt.getResult();
int numSamples = sprt.getNumSamples();
sprt.reset();
if (h0)
System.out.print("T");
else
System.out.print("F");
if (resList.size() < 99)
resList.add(new RobotResult(h0, numSamples, theta));
else {
RobotResult res = resList.get(i - 1);
res.updateResult(numSamples);
resList.set(i - 1, res);
}
}
System.out.println();
}
for (RobotResult r : resList) {
System.out.print(".");
cw.writeNext(r.getArr());
}
System.out.println();
cw.close();
}
}
use of kr.ac.kaist.se.simulator.Simulator in project SIMVA-SoS by SESoS.
the class LargeScaleMCIMain method debugMain.
public static void debugMain() throws IOException {
NormalDistributor distributor = new NormalDistributor();
distributor.setNormalDistParams(2500, 700);
LargeMCIScenario lMCI = new LargeMCIScenario(20, 500);
Simulator sim = new Simulator(lMCI);
sim.setDEBUG();
Executor.Perform_Debug_Experiment(distributor, sim, "mci");
}
use of kr.ac.kaist.se.simulator.Simulator in project SIMVA-SoS by SESoS.
the class KIISEMain method main.
public static void main(String[] args) throws IOException {
Constituent cs1 = new Constituent("CS1", 120);
Constituent cs2 = new Constituent("CS2", 120);
Constituent cs3 = new Constituent("CS3", 120);
Action a1 = new Action("Action1", 2, 1);
a1.setActionType(Action.TYPE.NORMAL);
Action a2 = new Action("Action2", 2, 2);
a2.setActionType(Action.TYPE.NORMAL);
Action a3 = new Action("Action3", 3, 3);
a3.setActionType(Action.TYPE.NORMAL);
cs1.addCapability(a1, 1);
cs1.addCapability(a2, 2);
cs2.addCapability(a2, 2);
cs2.addCapability(a3, 3);
cs3.addCapability(a1, 1);
cs3.addCapability(a3, 3);
Constituent[] CSs = { cs1, cs2, cs3 };
Action[] actions = { a1, a2, a3 };
SoS sos = new SoS("SoS Manager", CSs, actions);
Environment env = new Environment(CSs, actions);
Simulator sim = new Simulator(CSs, sos, env);
sim.setEndTick(300);
int[] boundArr = { 120, 125, 130, 135, 140, 145, 150 };
for (int bound : boundArr) {
String outputName = "SIM_" + bound + ".csv";
CSVWriter cw = new CSVWriter(new OutputStreamWriter(new FileOutputStream(outputName), "UTF-8"), ',', '"');
cw.writeNext(new String[] { "prob", "num_of_samples", "execution_time", "min_tick", "max_tick", "result" });
ArrayList<SMCResult> resList = new ArrayList<SMCResult>();
System.out.println("----------------------------------------------------");
System.out.println("SoS-level benefit is greater than " + bound + ".");
BaseChecker checker = new BaseChecker();
checker.init(10000, bound, BaseChecker.comparisonType.GREATER_THAN_AND_EQUAL_TO);
SPRTMethod sprt = new SPRTMethod(0.01, 0.01, 0.005);
for (int i = 1; i < 100; i++) {
// theta
double theta = 0.01 * i;
long start = System.currentTimeMillis();
sprt.setExpression(theta);
while (!sprt.checkStopCondition()) {
sim.execute();
SIMResult res = sim.getResult();
int checkResult = checker.evaluateSample(res);
sprt.updateResult(checkResult);
}
// Result
boolean h0 = sprt.getResult();
int numSamples = sprt.getNumSamples();
// System.out.print("SMC decides that your hypothesis is ");
// if(h0)
// {
// System.out.println("accepted at " + theta + " / number of samples: " + numSamples);
// }
// else
// {
// System.out.println("not accepted at " + theta + " / number of samples: " + numSamples);
// }
// exec time
long exec_time = System.currentTimeMillis() - start;
int minTick = checker.getMinTick();
int maxTick = checker.getMaxTick();
sprt.reset();
resList.add(new SMCResult(theta, numSamples, exec_time, minTick, maxTick, h0));
if (h0)
System.out.print("T");
else
System.out.print("F");
}
System.out.println();
System.out.print("w");
for (SMCResult r : resList) {
System.out.print(".");
cw.writeNext(r.getArr());
}
cw.close();
resList.clear();
System.out.println();
}
System.out.println("Finished");
}
use of kr.ac.kaist.se.simulator.Simulator in project SIMVA-SoS by SESoS.
the class LargeScaleMCIMain method experimentMain.
public static void experimentMain() throws IOException {
NormalDistributor distributor = new NormalDistributor();
distributor.setNormalDistParams(1500, 400);
// Experiment # 1 Total # of CSs 10
// LargeMCIScenario lMCI = new LargeMCIScenario(5, 250);
// Simulator sim = new Simulator(lMCI);
// Executor.Perform_Experiment(distributor, sim, "mci", 235);
//
// // Experiment # 2 Total # of CSs 20
// LargeMCIScenario lMCI1 = new LargeMCIScenario(10, 400);
// sim = new Simulator(lMCI1);
// Executor.Perform_Experiment(distributor, sim, "mci", 380);
//
// // Experiment # 3 Total # of CSs 30
LargeMCIScenario lMCI2 = new LargeMCIScenario(15, 1500);
Simulator sim = new Simulator(lMCI2);
Executor.Perform_Experiment(distributor, sim, "mci", 1230);
// Experiment # 4 Total # of CSs 40
// LargeMCIScenario lMCI3 = new LargeMCIScenario(20, 2000);
// Simulator sim = new Simulator(lMCI3);
// Executor.Perform_Experiment(distributor, sim, "mci", 1750);
}
use of kr.ac.kaist.se.simulator.Simulator in project SIMVA-SoS by SESoS.
the class Main method debugMain.
public static void debugMain() throws IOException {
NormalDistributor distributor = new NormalDistributor();
distributor.setNormalDistParams(2000, 500);
MCIScenario lMCI = new MCIScenario(6000, 100);
Simulator sim = new Simulator(lMCI);
sim.setDEBUG();
Executor.Perform_Debug_Experiment(distributor, sim, "mci");
}
Aggregations