Ejemplo n.º 1
0
 /**
  * This method represents the application code that we'd like to run on a separate thread. It
  * simulates slowly computing a value, in this case just a string 'All Done'. It updates the
  * progress bar every half second to remind the user that we're still busy.
  */
 Object doWork() {
   try {
     if (Thread.interrupted()) {
       throw new InterruptedException();
     }
     while (!this.state.terminator.isTerminated(this.state.optimizer.getPopulation())) {
       if (Thread.interrupted()) {
         throw new InterruptedException();
       }
       this.state.optimizer.optimize();
     }
     System.gc();
   } catch (InterruptedException e) {
     updateStatus("Interrupted", 0);
     return "Interrupted";
   }
   updateStatus("All Done", 0);
   return "All Done";
 }
Ejemplo n.º 2
0
 /**
  * This is the main method
  *
  * @param args
  */
 public static void main(String[] args) {
   MOCCOStandalone go = new MOCCOStandalone();
   if (args.length == 0) {
     // start GUI
     go.initMOCCOFrame();
   } else {
     String file = args[0];
     go.openObject(file);
     if (go.state == null) {
       System.out.println("No valid input state!");
       System.exit(0);
     } else {
       if (go.state.optimizer.getPopulation().getFunctionCalls() == 0) {
         // start to optimize
         go.startExperiment();
         file = file.replaceAll(".ser", "");
         go.saveObject(file + "_Finished.ser");
       } else {
         // start GUI
         go.initMOCCOFrame();
       }
     }
   }
 }