Menu

#22 Allow different implementations of Initialization interface

Any Version
open
nobody
None
5
2014-11-10
2014-04-24
Anonymous
No

For an application I'm considering I would like to be able to provide my own implementation of the Initialization interface to create an initial population (rather than always using RandomInitialization).

I'm quite happy to make the necessary changes myself - I'm just not sure what the procedure is for submitting patches. If there isn't one, I'd likely just post my modified MOEA Framework to GitHub.

Related

Feature Requests: #22

Discussion

  • D. Hadka

    D. Hadka - 2014-04-25

    This sounds like a great addition! I've created a Git repo with the latest source code so that you can submit the changes. You should be able to clone with:

    git clone https://@git.code.sf.net/p/moeaframework/git moeaframework-git

     
  • Brad

    Brad - 2014-11-05

    Hello! Is there currently a way to insert a single individual into the randomly initialized population at initialization?

     
  • Anonymous

    Anonymous - 2014-11-10

    Hi Brad,

    There currently isn't a way to insert a single individual using the default Executor. However, you could manually create a new algorithm with a custom initialization procedure:

    import org.moeaframework.algorithm.NSGAII;
    import org.moeaframework.core.Initialization;
    import org.moeaframework.core.NondominatedPopulation;
    import org.moeaframework.core.NondominatedSortingPopulation;
    import org.moeaframework.core.Problem;
    import org.moeaframework.core.Solution;
    import org.moeaframework.core.Variation;
    import org.moeaframework.core.comparator.ChainedComparator;
    import org.moeaframework.core.comparator.CrowdingComparator;
    import org.moeaframework.core.comparator.ParetoDominanceComparator;
    import org.moeaframework.core.operator.RandomInitialization;
    import org.moeaframework.core.operator.TournamentSelection;
    import org.moeaframework.core.spi.OperatorFactory;
    import org.moeaframework.problem.DTLZ.DTLZ2;
    import org.moeaframework.util.TypedProperties;
    
    public class Test {
    
        public static void main(String[] args) {
            final Problem problem = new DTLZ2(2);
            final int populationSize = 100;
    
            Initialization initialization = new Initialization() {
                public Solution[] initialize() {
                    Solution[] result = new RandomInitialization(problem, populationSize).initialize();
                    //result[0] = your custom solution
                    return result;
                }
            };
    
            NondominatedSortingPopulation population = 
                    new NondominatedSortingPopulation();
    
            TournamentSelection selection = new TournamentSelection(2, 
                    new ChainedComparator(
                            new ParetoDominanceComparator(),
                            new CrowdingComparator()));
    
            Variation variation = OperatorFactory.getInstance().getVariation(null, 
                    new TypedProperties(), problem);
    
            NSGAII algorithm = new NSGAII(problem, population, null, selection, variation,
                    initialization);
    
            while (!algorithm.isTerminated() && (algorithm.getNumberOfEvaluations() < 100000)) {
                algorithm.step();
            }
    
            NondominatedPopulation result = algorithm.getResult();
        }
    
    }
    
     
    • Brad

      Brad - 2014-11-12

      Thanks for your response! I believe that will work to use
      results[0].setVariable( ) with my solution. I will try it here shortly.
      Brad

      On Mon, Nov 10, 2014 at 7:19 AM, noreply@in.sf.net wrote:

      Hi Brad,

      There currently isn't a way to insert a single individual using the
      default Executor. However, you could manually create a new algorithm with a
      custom initialization procedure:

      import org.moeaframework.algorithm.NSGAII;import org.moeaframework.core.Initialization;import org.moeaframework.core.NondominatedPopulation;import org.moeaframework.core.NondominatedSortingPopulation;import org.moeaframework.core.Problem;import org.moeaframework.core.Solution;import org.moeaframework.core.Variation;import org.moeaframework.core.comparator.ChainedComparator;import org.moeaframework.core.comparator.CrowdingComparator;import org.moeaframework.core.comparator.ParetoDominanceComparator;import org.moeaframework.core.operator.RandomInitialization;import org.moeaframework.core.operator.TournamentSelection;import org.moeaframework.core.spi.OperatorFactory;import org.moeaframework.problem.DTLZ.DTLZ2;import org.moeaframework.util.TypedProperties;
      public class Test {

      public static void main(String[] args) {
          final Problem problem = new DTLZ2(2);
          final int populationSize = 100;
      
          Initialization initialization = new Initialization() {
              public Solution[] initialize() {
                  Solution[] result = new RandomInitialization(problem, populationSize).initialize();
                  //result[0] = your custom solution
                  return result;
              }
          };
      
          NondominatedSortingPopulation population =
                  new NondominatedSortingPopulation();
      
          TournamentSelection selection = new TournamentSelection(2,
                  new ChainedComparator(
                          new ParetoDominanceComparator(),
                          new CrowdingComparator()));
      
          Variation variation = OperatorFactory.getInstance().getVariation(null,
                  new TypedProperties(), problem);
      
          NSGAII algorithm = new NSGAII(problem, population, null, selection, variation,
                  initialization);
      
          while (!algorithm.isTerminated() && (algorithm.getNumberOfEvaluations() < 100000)) {
              algorithm.step();
          }
      
          NondominatedPopulation result = algorithm.getResult();
      }
      

      }


      Status: open
      Group: Any Version
      Created: Thu Apr 24, 2014 11:31 PM UTC by Anonymous
      Last Updated: Wed Nov 05, 2014 07:34 PM UTC
      Owner: nobody

      For an application I'm considering I would like to be able to provide my
      own implementation of the Initialization interface to create an initial
      population (rather than always using RandomInitialization).

      I'm quite happy to make the necessary changes myself - I'm just not sure
      what the procedure is for submitting patches. If there isn't one, I'd
      likely just post my modified MOEA Framework to GitHub.


      Sent from sourceforge.net because you indicated interest in
      https://sourceforge.net/p/moeaframework/feature-requests/22/

      To unsubscribe from further messages, please visit
      https://sourceforge.net/auth/subscriptions/

       

      Related

      Feature Requests: #22

Want the latest updates on software, tech news, and AI?
Get latest updates about software, tech news, and AI from SourceForge directly in your inbox once a month.