@@ -97,19 +97,30 @@ public void run() {
9797 ArrayList <ArrayList <parameter >> newParameterset ;
9898 //Simulator init with initial parameterset
9999 Simulator mySimulator = SimOptiFactory .getSimulator ();
100+ int simulationTryCounter = 0 ;
100101
101102 //Wait until Simulator has ended
102- //support.waitSingleThreaded(100);
103- //support.waitForEndOfSimulator(mySimulator, support.DEFAULT_TIMEOUT);
104- //support.log("Performed % of simulations: "+mySimulator.getStatus(), typeOfLogLevel.INFO);
105- synchronized ( mySimulator ) {
106- try {
107- mySimulator .initSimulator ( getParametersetAsArrayList ( getFirstParameterset ()), support . isCreateseparateLogFilesForEverySimulation () );
108- mySimulator . wait ();
109- } catch ( InterruptedException ex ) {
110- support . log ( "Problem waiting for end of non-cache-simulator." , typeOfLogLevel . ERROR );
103+ /* encapsulate in loop to avoid empty result list at start. Unknown problem of simulators returning nothing. */
104+ do {
105+ synchronized ( mySimulator ) {
106+ try {
107+ mySimulator . initSimulator ( getParametersetAsArrayList ( getFirstParameterset ()), support . isCreateseparateLogFilesForEverySimulation ());
108+ mySimulator .wait ( );
109+ } catch ( InterruptedException ex ) {
110+ support . log ( "Problem waiting for end of non-cache-simulator." , typeOfLogLevel . ERROR );
111+ }
111112 }
112- }
113+ simulationTryCounter ++;
114+ switch (simulationTryCounter ) {
115+ default :
116+ /* It took more than one tries to simulate successfully. */
117+ support .log ("Problem with simulator, this was simulation attempt #. " + simulationTryCounter , typeOfLogLevel .ERROR );
118+ break ;
119+ case 1 :
120+ /* Simulation result after first try. */
121+ break ;
122+ }
123+ } while (mySimulator .getListOfCompletedSimulationParsers ().size () < 1 );
113124
114125 support .addLinesToLogFileFromListOfParser (mySimulator .getListOfCompletedSimulationParsers (), logFileName );
115126 this .historyOfParsers = support .appendListOfParsers (historyOfParsers , mySimulator .getListOfCompletedSimulationParsers ());
@@ -128,15 +139,29 @@ public void run() {
128139
129140 stuckInCacheCounter = support .DEFAULT_CACHE_STUCK ;//Reset Stuck-Counter
130141
131- //support.waitForEndOfSimulator(mySimulator, support.DEFAULT_TIMEOUT);
132- synchronized (mySimulator ) {
133- try {
134- mySimulator .initSimulator (newParameterset , support .isCreateseparateLogFilesForEverySimulation ());
135- mySimulator .wait ();
136- } catch (InterruptedException ex ) {
137- support .log ("Problem waiting for end of non-cache-simulator." , typeOfLogLevel .ERROR );
142+ /* encapsulate in loop to avoid empty result list at start. Unknown problem of simulators returning nothing. */
143+ simulationTryCounter = 0 ;
144+ do {
145+ synchronized (mySimulator ) {
146+ try {
147+ mySimulator .initSimulator (newParameterset , support .isCreateseparateLogFilesForEverySimulation ());
148+ mySimulator .wait ();
149+ } catch (InterruptedException ex ) {
150+ support .log ("Problem waiting for end of non-cache-simulator." , typeOfLogLevel .ERROR );
151+ }
138152 }
139- }
153+ simulationTryCounter ++;
154+ switch (simulationTryCounter ) {
155+ default :
156+ /* It took more than one tries to simulate successfully. */
157+ support .log ("Problem with simulator, this was simulation attempt #. " + simulationTryCounter , typeOfLogLevel .ERROR );
158+ break ;
159+ case 1 :
160+ /* Simulation result after first try. */
161+ break ;
162+ }
163+ } while (mySimulator .getListOfCompletedSimulationParsers ().size () < 1 );
164+
140165 listOfCompletedSimulations = mySimulator .getListOfCompletedSimulationParsers ();
141166 support .log ("List of Simulation results is: " + listOfCompletedSimulations .size () + " elements big." , typeOfLogLevel .INFO );
142167 //Shrink to first element of List
0 commit comments