Пример #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";
 }
Пример #2
0
 public void MOCCOOptimization() {
   boolean cont = true;
   InterfaceProcessElement tmpP;
   while (cont) {
     this.iteration++;
     while (stillWorking) {
       try {
         Thread.sleep(1000);
       } catch (java.lang.InterruptedException e) {
       }
     }
     if (this.state.originalProblem == null) {
       this.state.originalProblem = new TF1Problem();
       tmpP = new MOCCOProblemInitialization(this);
       tmpP.initProcessElementParametrization();
       while (!tmpP.isFinished()) {
         try {
           Thread.sleep(1000);
         } catch (java.lang.InterruptedException e) {
         }
       }
       this.state.currentProblem =
           (InterfaceOptimizationProblem) this.state.originalProblem.clone();
       this.view.problemChanged(true);
       this.parameterPanel.removeAll();
       tmpP = new MOCCOInitialPopulationSize(this);
       tmpP.initProcessElementParametrization();
       while (!tmpP.isFinished()) {
         try {
           Thread.sleep(1000);
         } catch (java.lang.InterruptedException e) {
         }
       }
       this.state.initialPopulationSize = Math.max(1, this.state.initialPopulationSize);
       Population pop = new Population();
       pop.setTargetSize(this.state.initialPopulationSize);
       this.state.currentProblem =
           (InterfaceOptimizationProblem) this.state.originalProblem.clone();
       this.state.currentProblem.initializePopulation(pop);
       this.state.currentProblem.evaluate(pop);
       this.state.addPopulation2History(pop);
       this.view.problemChanged(true);
     }
     ((InterfaceMultiObjectiveDeNovoProblem) this.state.currentProblem)
         .deactivateRepresentationEdit();
     this.updateStatus("Analysis/Redefinition", 33);
     tmpP = new MOCCOProblemRedefinition(this);
     tmpP.initProcessElementParametrization();
     while (!tmpP.isFinished()) {
       try {
         Thread.sleep(1000);
       } catch (java.lang.InterruptedException e) {
       }
     }
     this.state.makeFitnessCache(true);
     this.state.currentProblem.initializeProblem();
     this.state.makeBackup();
     this.view.problemChanged(true);
     if (this.state.currentProblem.isMultiObjective()) {
       this.updateStatus("MO Strategy Selection", 50);
       tmpP = new MOCCOChooseMOStrategy(this);
       tmpP.initProcessElementParametrization();
       while (!tmpP.isFinished()) {
         try {
           Thread.sleep(1000);
         } catch (java.lang.InterruptedException e) {
         }
       }
       switch (((MOCCOChooseMOStrategy) tmpP).getMOStrategy()) {
         case MOCCOChooseMOStrategy.STRATEGY_MOEA:
           {
             this.updateStatus("MOEA Parameterization", 75);
             tmpP = new MOCCOParameterizeMO(this);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             break;
           }
         case MOCCOChooseMOStrategy.STRATEGY_STEP:
           {
             this.updateStatus("Reference Solution...", 75);
             tmpP = new MOCCOChooseReferenceSolution(this);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             AbstractEAIndividual reference =
                 ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
             this.updateStatus("STEP Parameterization...", 90);
             tmpP = new MOCCOParameterizeSTEP(this);
             ((MOCCOParameterizeSTEP) tmpP).setReferenceSolution(reference);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             break;
           }
         case MOCCOChooseMOStrategy.STRATEGY_REFP:
           {
             this.updateStatus("Reference Point...", 75);
             tmpP = new MOCCOChooseReferencePoint(this);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
             this.updateStatus("Reference Point Parameterization...", 90);
             tmpP = new MOCCOParameterizeRefPoint(this);
             ((MOCCOParameterizeRefPoint) tmpP).setReferencePoint(reference);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             break;
           }
         case MOCCOChooseMOStrategy.STRATEGY_TBCH:
           {
             this.updateStatus("Reference Point...", 75);
             tmpP = new MOCCOChooseReferencePoint(this);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             double[] reference = ((MOCCOChooseReferencePoint) tmpP).getReferencePoint();
             this.updateStatus("Tchebycheff Method Parameterization...", 90);
             tmpP = new MOCCOParameterizeTchebycheff(this);
             ((MOCCOParameterizeTchebycheff) tmpP).setReferencePoint(reference);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             break;
           }
         case MOCCOChooseMOStrategy.STRATEGY_GDF:
           {
             this.updateStatus("Reference Solution...", 75);
             tmpP = new MOCCOChooseReferenceSolution(this);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             AbstractEAIndividual reference =
                 ((MOCCOChooseReferenceSolution) tmpP).getReferenceSolution();
             this.updateStatus("Geoffrion-Dyer-Feinberg Method Parameterization...", 90);
             tmpP = new MOCCOParameterizeGDF(this);
             ((MOCCOParameterizeGDF) tmpP).setReferenceSolution(reference);
             tmpP.initProcessElementParametrization();
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             break;
           }
         default:
           {
             tmpP = new MOCCOParameterizeMO(this);
             while (!tmpP.isFinished()) {
               try {
                 Thread.sleep(1000);
               } catch (java.lang.InterruptedException e) {
               }
             }
             break;
           }
       }
     } else {
       this.updateStatus("SO-Optimizer Parameterization", 66);
       tmpP = new MOCCOParameterizeSO(this);
       tmpP.initProcessElementParametrization();
       while (!tmpP.isFinished()) {
         try {
           Thread.sleep(1000);
         } catch (java.lang.InterruptedException e) {
         }
       }
     }
     // now optimize
     this.updateStatus("Optimizing...", 0);
     this.startExperiment();
   }
 }