Skip to content

Commit 33d6f0c

Browse files
Christoph BodensteinChristoph Bodenstein
authored andcommitted
2 parents ee384d6 + 493eb36 commit 33d6f0c

12 files changed

+118
-298
lines changed

TimeNETOptimizationEnvironment/src/toe/MainFrame.java

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -284,7 +284,7 @@ public void updateComboBoxSimulationType() {
284284
DefaultListSelectionModel model = new DefaultListSelectionModel();
285285
model.addSelectionInterval(0, 0);
286286
model.addSelectionInterval(2, 2);
287-
model.addSelectionInterval(5, 5);
287+
model.addSelectionInterval(5, 6);
288288
if (support.isCachedSimulationAvailable()) {
289289
model.addSelectionInterval(1, 1);
290290
}

TimeNETOptimizationEnvironment/src/toe/SimOptiFactory.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,6 +22,7 @@
2222
import toe.optimization.OptimizerSimAnnealing;
2323
import toe.optimization.OptimizerHill;
2424
import java.util.ArrayList;
25+
import toe.simulation.SimulatorCachedBenchmark;
2526

2627
/**
2728
*
@@ -68,6 +69,9 @@ public static Simulator getSimulator() {
6869
case Benchmark:
6970
//Return Simulator for Benchmark-Functions
7071
return new SimulatorBenchmark();
72+
case Cached_Benchmark:
73+
//Return the Benchmark-Simulator with cache-support
74+
return new SimulatorCachedBenchmark();
7175
default:
7276
return new SimulatorLocal();
7377
}

TimeNETOptimizationEnvironment/src/toe/helper/SimulationTypeComboBoxModel.java

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -63,6 +63,10 @@ public void setSelectedItem(Object anObject) {
6363
super.setSelectedItem(anObject);
6464
support.setChosenSimulatorType((typeOfSimulator) anObject);
6565
}
66+
if ((anObject).equals(typeOfSimulator.Cached_Benchmark)) {
67+
super.setSelectedItem(anObject);
68+
support.setChosenSimulatorType((typeOfSimulator) anObject);
69+
}
6670

6771
} else {
6872

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorBenchmark.java

Lines changed: 12 additions & 269 deletions
Large diffs are not rendered by default.

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorCached.java

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ public class SimulatorCached implements Simulator {
2323

2424
private SimulationCache mySimulationCache = null;
2525
private ArrayList<SimulationType> myListOfSimulations = null;
26-
private String logFileName;
26+
private final String logFileName;
2727

2828
/**
2929
* Constructor
@@ -40,6 +40,7 @@ public SimulatorCached() {
4040
* @param simulationCounterTMP actual Number of simulation, will be
4141
* increased with every simulation-run
4242
*/
43+
@Override
4344
public void initSimulator(ArrayList<ArrayList<parameter>> listOfParameterSetsTMP, int simulationCounterTMP, boolean log) {
4445
if (mySimulationCache != null) {
4546
this.myListOfSimulations = mySimulationCache.getListOfCompletedSimulationParsers(listOfParameterSetsTMP, support.getGlobalSimulationCounter());
@@ -83,6 +84,7 @@ public void initSimulator(ArrayList<ArrayList<parameter>> listOfParameterSetsTMP
8384
*
8485
* @return % of simulatiions that are finished
8586
*/
87+
@Override
8688
public int getStatus() {
8789
if (this.myListOfSimulations != null) {
8890
return 100;
@@ -96,6 +98,7 @@ public int getStatus() {
9698
*
9799
* @return actual simulation counter
98100
*/
101+
@Override
99102
public int getSimulationCounter() {
100103
return support.getGlobalSimulationCounter();
101104
}
@@ -107,6 +110,7 @@ public int getSimulationCounter() {
107110
* @return list of completed simulations (parsers) which contain all data
108111
* from the log-files
109112
*/
113+
@Override
110114
public ArrayList<SimulationType> getListOfCompletedSimulationParsers() {
111115
return this.myListOfSimulations;
112116
}
@@ -136,6 +140,7 @@ public void setMySimulationCache(SimulationCache mySimulationCache) {
136140
*
137141
* @return
138142
*/
143+
@Override
139144
public SimulationType getCalculatedOptimum(MeasureType targetMeasure) {
140145
//iterate through all cached sims and look for best solution
141146
support.log("SimulatorCached: Getting absolute optimum simulation from Cache.");
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
/**
2+
* Simulator which uses log data from already done simulations and returns them.
3+
* If not all parametersets can be found in cache, the rest is simulated
4+
* via Benchmark-function
5+
*
6+
* Christoph Bodenstein TU-Ilmenau, FG SSE
7+
*/
8+
package toe.simulation;
9+
10+
import toe.datamodel.MeasureType;
11+
import toe.datamodel.SimulationType;
12+
13+
/**
14+
*
15+
* @author Christoph Bodenstein
16+
*/
17+
public class SimulatorCachedBenchmark extends SimulatorCachedLocal {
18+
19+
/**
20+
* Returns new Simulator-object to be used, if parametersets are not in
21+
* cache
22+
*
23+
* @return Simulator object (benchmark)
24+
*/
25+
@Override
26+
public Simulator getNoCacheSimulator() {
27+
return new SimulatorBenchmark();
28+
}
29+
30+
/**
31+
* Returns the calculated optimimum For Benchmark-Functions this can be
32+
* calculated. For other simulators, this must be given by user.
33+
*
34+
* @param targetMeasure Measure to be optimized.
35+
* @return caluclated optimum. Not possible in Web-Simulator so returns null
36+
*/
37+
@Override
38+
public SimulationType getCalculatedOptimum(MeasureType targetMeasure){
39+
return new SimulatorBenchmark().getCalculatedOptimum(targetMeasure);
40+
}
41+
}

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorCachedDistributed.java

Lines changed: 16 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,9 +7,12 @@
77
*/
88
package toe.simulation;
99

10+
import toe.datamodel.MeasureType;
11+
import toe.datamodel.SimulationType;
12+
1013
/**
1114
*
12-
* @author chbo1in
15+
* @author Christoph Bodenstein
1316
*/
1417
public class SimulatorCachedDistributed extends SimulatorCachedLocal {
1518

@@ -23,4 +26,16 @@ public class SimulatorCachedDistributed extends SimulatorCachedLocal {
2326
public Simulator getNoCacheSimulator() {
2427
return new SimulatorDistributed();
2528
}
29+
30+
/**
31+
* Returns the calculated optimimum For Benchmark-Functions this can be
32+
* calculated. For other simulators, this must be given by user.
33+
*
34+
* @param targetMeasure Measure to be optimized.
35+
* @return caluclated optimum. Not possible in Web-Simulator so returns null
36+
*/
37+
@Override
38+
public SimulationType getCalculatedOptimum(MeasureType targetMeasure){
39+
return new SimulatorDistributed().getCalculatedOptimum(targetMeasure);
40+
}
2641
}

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorCachedLocal.java

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -24,9 +24,9 @@ public class SimulatorCachedLocal extends SimulatorCached {
2424

2525
private SimulationCache mySimulationCache = null;
2626
private ArrayList<SimulationType> myListOfSimulationParsers = null;
27-
private String logFileName;
27+
private final String logFileName;
2828
private int status;
29-
private Simulator myLocalSimulator = getNoCacheSimulator();
29+
private final Simulator myLocalSimulator = getNoCacheSimulator();
3030

3131
/**
3232
* Constructor
@@ -48,7 +48,7 @@ public SimulatorCachedLocal() {
4848
public void initSimulator(ArrayList< ArrayList<parameter>> listOfParameterSetsTMP, int simulationCounterTMP, boolean log) {
4949

5050
this.myListOfSimulationParsers = null;
51-
ArrayList< ArrayList<parameter>> remainingParametersets = new ArrayList< ArrayList<parameter>>();
51+
ArrayList< ArrayList<parameter>> remainingParametersets = new ArrayList< >();
5252
status = 0;
5353
//this.simulationCounter=simulationCounterTMP;
5454

@@ -61,7 +61,7 @@ public void initSimulator(ArrayList< ArrayList<parameter>> listOfParameterSetsTM
6161

6262
if (this.myListOfSimulationParsers == null) {
6363
support.log("No Simulation found in local Cache. Starting simulation.");
64-
this.myListOfSimulationParsers = new ArrayList<SimulationType>();
64+
this.myListOfSimulationParsers = new ArrayList<>();
6565
}
6666

6767
status = myListOfSimulationParsers.size() * 100 / listOfParameterSetsTMP.size();

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorDistributed.java

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -550,6 +550,7 @@ public void uploadSimulationFile(String urlString, File file, String fileName, S
550550
* @param targetMeasure Measure to be optimized.
551551
* @return caluclated optimum. Not possible in Web-Simulator so returns null
552552
*/
553+
@Override
553554
public SimulationType getCalculatedOptimum(MeasureType targetMeasure) {
554555
//support.log("SimulatorDistributed: Getting absolute optimum simulation from Cache. Will return null.");
555556
return null;

TimeNETOptimizationEnvironment/src/toe/simulation/SimulatorLocal.java

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,7 @@ public SimulatorLocal() {
5858
* @param listOfParameterSetsTMP List of Parameter-sets to be simulated
5959
* @param simulationCounterTMP start value of simulation counter
6060
*/
61+
@Override
6162
public void initSimulator(ArrayList< ArrayList<parameter>> listOfParameterSetsTMP, int simulationCounterTMP, boolean log) {
6263
this.status = 0;
6364
this.listOfParameterSets = listOfParameterSetsTMP;
@@ -78,9 +79,10 @@ public void initSimulator(ArrayList< ArrayList<parameter>> listOfParameterSetsTM
7879
* Run Method to start simulations and collect the data simulats the SCPNs,
7980
* main routine
8081
*/
82+
@Override
8183
public void run() {
8284
this.status = 0;
83-
this.listOfCompletedSimulationParsers = new ArrayList<SimulationType>();
85+
this.listOfCompletedSimulationParsers = new ArrayList<>();
8486
int numberOfSimulations = 0;
8587
if (support.checkTimeNetPath()) {
8688
try {
@@ -293,6 +295,7 @@ private void startLocalSimulation(String exportFileName) {
293295
*
294296
* @return List of completed simulation parsers
295297
*/
298+
@Override
296299
public ArrayList<SimulationType> getListOfCompletedSimulationParsers() {
297300
return this.listOfCompletedSimulationParsers;
298301
}
@@ -313,6 +316,7 @@ public void deleteTmpFiles() {
313316
*
314317
* @return number of actual simulation
315318
*/
319+
@Override
316320
public int getSimulationCounter() {
317321
return this.simulationCounter;
318322
}
@@ -331,14 +335,17 @@ public void setSimulationCounter(int i) {
331335
*
332336
* @return % of simulations that are finished
333337
*/
338+
@Override
334339
public int getStatus() {
335340
return this.status;
336341
}
337342

343+
@Override
338344
public void processEnded() {
339345
support.log("Local Simulation ended.");
340346
}
341347

348+
@Override
342349
public void errorOccured(String message) {
343350
support.log("Error while local simulation.");
344351
}
@@ -347,6 +354,7 @@ public void errorOccured(String message) {
347354
* Returns the calulated optimimum For Benchmark-Functions this can be
348355
* caluclated. For other simulators, this must be given by user.
349356
*/
357+
@Override
350358
public SimulationType getCalculatedOptimum(MeasureType targetMeasure) {
351359
support.log("SimulatorLocal: Getting absolute optimum simulation from Cache. Will return null.");
352360
return null;

0 commit comments

Comments
 (0)