Skip to content

Commit 329f7e9

Browse files
Christoph BodensteinChristoph Bodenstein
authored andcommitted
added support for cached benchmark simulation
1 parent 7ef6fcf commit 329f7e9

File tree

8 files changed

+90
-26
lines changed

8 files changed

+90
-26
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

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+
* distributed
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/typedef.java

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -205,7 +205,12 @@ public enum typeOfSimulator {
205205
/**
206206
* Use chosen benchmark function to "simulate" parameter set
207207
*/
208-
Benchmark
208+
Benchmark,
209+
/**
210+
* To test caching effects with benchmar functions
211+
*/
212+
Cached_Benchmark
213+
209214
};
210215

211216
/**
@@ -420,70 +425,64 @@ public enum typeOfPossiblePlot {
420425
* No Plot is possible, may no Axes are configured
421426
*/
422427
NoPlot,
423-
424428
/**
425429
* 2D-Plot is possble and colorchooser is active
426430
*/
427431
Plot2D,
428-
429432
/**
430433
* 3D-Plot is possible, also the interactive plot
431434
*/
432435
Plot3D
433436
};
434-
437+
435438
/**
436439
* Type of 3D-Plot to export Script
437440
*/
438-
public enum typeOf3DPlot{
441+
public enum typeOf3DPlot {
439442

440443
/**
441-
*Standard Scatterplot3D with lib plot3D
444+
* Standard Scatterplot3D with lib plot3D
442445
*/
443446
ScatterPlot,
444-
445447
/**
446448
* interactive opengl with lib rgl
447449
*/
448450
Perspective,
449-
450451
/**
451452
* Draws a 2D-Heatmap
452453
*/
453454
Heatmap
454455
}
455-
456+
456457
/**
457458
* Type of distance calculation in definition space for found optima
458459
*/
459-
public enum typeOfRelativeDistanceCalculation{
460+
public enum typeOfRelativeDistanceCalculation {
460461

461462
/**
462463
* Use standard relative distance
463464
*/
464-
STANDARD,
465-
465+
STANDARD,
466466
/**
467467
* use EULID Distance and calc relative value
468468
*/
469-
EUKLID}
470-
469+
EUKLID
470+
}
471+
471472
/**
472-
* Skills of Client to be mentioned for distributed simulation
473-
* TimeNET, MLDesigner, Matlab ???
473+
* Skills of Client to be mentioned for distributed simulation TimeNET,
474+
* MLDesigner, Matlab ???
474475
*/
475-
public enum typeOfClientSkills{
476-
476+
public enum typeOfClientSkills {
477+
477478
/**
478479
* client can simulate SCPNs (with TimeNET)
479480
*/
480481
TIMENET,
481-
482482
/**
483483
* client can simulate MLD-Models
484484
*/
485485
MLDESIGNER,
486-
487486
/**
488487
* client can simulate Matlab models
489488
*/

0 commit comments

Comments
 (0)