Пример #1
0
  /**
   * This method is used to evaluate the first population,that it is called after the calling to
   * <code>setup</code> method
   *
   * @throws JMException
   */
  public void evaluatePopulation() throws JMException {
    // NOTEIT First evaluation of the SolutionSet

    int loadingPosition = population_.getLoadingPosition();

    // Commented by Bernabe Dorronsoro
    //		if ( ( specialSolution_ != null ) ){
    //
    //			DecisionVariables[] best = new DecisionVariables[problem_.getNumberOfIslands()-1];
    //
    //			population_.clear();
    //			for( int f=0 ; f<populationSize_ ; ++f) {
    //				DecisionVariables specialDV   = problem_.generateSpecial( specialSolution_ );
    //				if ( f < numberOfSolutions_ ){
    //					for( int i=0 ; i<problem_.getNumberOfIslands() ; ++i ){
    //						if (i<loadingPosition)
    //							best[i] = new DecisionVariables( specialDV.extractSlice(i) );
    //						if (i>loadingPosition)
    //							best[i-1] = new DecisionVariables( specialDV.extractSlice(i) );
    //					} // for
    //
    //					population_.setBestRow( best , f );
    //				} // if
    //
    //				DecisionVariables decisionVar = new DecisionVariables( specialDV.extractSlice(
    // loadingPosition ) );
    //				Solution S = new Solution( problem_ , decisionVar );
    //				population_.add( S );
    //				S.unLink();
    //			} // for
    //
    //		} // if

    Iterator<Solution> it = population_.iterator();
    while (it.hasNext()) {
      Solution tmp = it.next();
      tmp.unLink();
      population_.linkExternalDecisionVariables(tmp);
      problem_.evaluate(tmp, loadingPosition);
      problem_.evaluateConstraints(tmp);
      ++evaluations_;
    } // while

    // population_.printObjectivesToFile( "FUN.S."+loadingPosition );
  } // evaluatePopulation
Пример #2
0
  public void setup(int islandId) throws JMException {
    islandID_ = islandId;

    distance_ = new Distance();

    // Read the parameters
    indicators_ = (QualityIndicator) this.getInputParameter("indicators");

    islands_ = ((Integer) getInputParameter("numberOfIslands")).intValue();
    populationSize_ = ((Integer) getInputParameter("populationSize")).intValue();
    maxEvaluations_ = ((Integer) getInputParameter("maxEvaluations")).intValue();
    numberOfSolutions_ = ((Integer) getInputParameter("numberOfSolutions")).intValue();
    bestSolutionsFirstLevel_ = ((Integer) getInputParameter("bestSolutionsFirstLevel")).intValue();
    specialSolution_ = ((String) getInputParameter("specialSolution"));
    mergeSolution_ = ((Integer) this.getInputParameter("mergeSolution")).intValue();

    // Initialize the variables
    population_ =
        new SolutionSet(islandId, islands_, numberOfSolutions_, populationSize_, mergeSolution_);
    evaluations_ = 0;
    // bestSolutions = new Solution[islands-1];

    requiredEvaluations_ = 0;

    // Read the operators
    mutationOperator_ = operators_.get("mutation");
    crossoverOperator_ = operators_.get("crossover");
    selectionOperator_ = operators_.get("selection");
    localSearchOperator_ = operators_.get("localsearch");

    // NOTEIT Creation of the SolutionSet of the Islands
    // Create the initial solutionSet
    Solution newSolution = null;

    //		for( int i=0 ; i<populationSize_ ; ++i) {
    //			newSolution = new Solution( problem_ );
    //			population_.add( newSolution );
    //		} // for

    int minminInit =
        PseudoRandom.randInt(0, populationSize_ - 1); // To initialize one individual with min-min

    for (int i = 0; i < populationSize_; i++) {
      if (specialSolution_ == null) {
        newSolution = new Solution(problem_);
      } // if
      else if (specialSolution_.contains("OneMinmin")) {
        if (minminInit == i) {
          // int [] vars = ScheduleStrategy.minMin(ETC_, numberOfTasks, numberOfMachines)
          DecisionVariables specialDV = problem_.generateSpecial(specialSolution_, islandId);
          newSolution = new Solution(problem_, specialDV);
        } else newSolution = new Solution(problem_);
      } else if (specialSolution_.equalsIgnoreCase("Min-Min")) {
        DecisionVariables specialDV = problem_.generateSpecial(specialSolution_, islandId);
        newSolution = new Solution(problem_, specialDV);
      } // else
      //			problem_.evaluate( newSolution );
      //			problem_.evaluateConstraints( newSolution );
      population_.add(newSolution);
      newSolution.setLocation(i);
      //			evaluations++;
    } // for

    prepareSetupBestSolutions();
  } // setup