A15. Multiple Solutions

Top  Previous  Next

Solution: Task 15

 

 


 

package net.simplace.sim.runs.training.WorkingWithSolutions;

 

import net.simplace.sim.runs.ModulesStandardRun;

 

public class Run_15_MulipleSolutions extends ModulesStandardRun

{

  public static void main(String[] args)

   {

         

         // Declare first variables

         String tSolutionName = "01_FirstSolution";

         String tSolutionFileName = "${_WORKDIR_}/training/solution/1_WorkingWithSolutions/"+tSolutionName+".sol.xml";

       

         // Setup SIMPLACE paths

         setUp();

     

         // Print messages and run SIMPLACE

         showMessage("Starting: "+tSolutionName);

         runSimulation(tSolutionFileName);

         showMessage("Finished Run: "+tSolutionName);

         

         // Redefine variables with new solutions

         tSolutionName = "02_StartEndDates";

         tSolutionFileName = "${_WORKDIR_}/training/solution/1_WorkingWithSolutions/"+tSolutionName+".sol.xml";

 

         // Setup SIMPLACE paths

         setUp();

 

         // Print messages and run SIMPLACE          

         showMessage("Starting: "+tSolutionName);

         runSimulation(tSolutionFileName);

         showMessage("Finished Run: "+tSolutionName);

 

         // Add more steps here in between if necessary

         // loops are also good practice ;)

         

         // Stop execution

         exit();

   }

}

 


 

 

OR its also possible to add each ModelSolution to an extra method that can be called by main():

 

 


 

package net.simplace.sim.runs.training.WorkingWithSolutions;

 

import net.simplace.sim.runs.ModulesStandardRun;

 

public class Run_15_MulipleSolutions_Methods extends ModulesStandardRun

{

  public static void main(String[] args)

   {

                   

         runSolution1();

         runSolution2();

         exit();        

         

   }

   

  public static void runSolution1()

 {

         // Declare first variables

         String tSolutionName = "01_FirstSolution";

         String tSolutionFileName = "${_WORKDIR_}/training/solution/1_WorkingWithSolutions/"+tSolutionName+".sol.xml";

       

         // Setup SIMPLACE paths

         setUp();

     

         // Print messages and run SIMPLACE

         showMessage("Starting: "+tSolutionName);

         runSimulation(tSolutionFileName);

         showMessage("Finished Run: "+tSolutionName);

 }

 

 public static void runSolution2()

 {

         // Redefine variables with new solutions

         String tSolutionName = "02_StartEndDates";

         String tSolutionFileName = "${_WORKDIR_}/training/solution/1_WorkingWithSolutions/"+tSolutionName+".sol.xml";

 

         // Setup SIMPLACE paths

         setUp();

 

         // Print messages and run SIMPLACE          

         showMessage("Starting: "+tSolutionName);

         runSimulation(tSolutionFileName);

         showMessage("Finished Run: "+tSolutionName);

 }  

   

   

}