KnapSack problem on grid!

View: New views
2 Messages — Rating Filter:   Alert me  

KnapSack problem on grid!

by Alex Ef :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Hello JGAP users/admin, I have semestrial project on parallel computing and I must make parallel genetic algorithm to solve KnapSack problem. I'm trying to use JGAP to create grid. In examples there is KnapSack problem and grid example. My question is how to combine two examples to one working grid solution? I use Fitness function from KnapSack example for Fitness function in my GridConfiguration class and configure grid in GridConfiguration like that (This is for GridClient - I start grid server and worker before that. All classes are just like in grid example for evolution distributed only Fitness and Config classes are modified):

..........
public class KSEvoConfig extends GridConfigurationBase{
       
        public double a_knapsackVolume = 10000d;
        public final static double[] itemVolumes = {
              50.2d, 14.8d, 27.5d, 6800.0d, 25.0d, 4.75d, 95.36d, 1500.7d, 18365.9d,
              83571.1d};
        public final static String[] itemNames = {
              "Monitor", "Fruit", "Radio", " Big TV", "Gameboy", "Small object",
              "Medium object", "Big object", "Huge object", "Gigantic object"};

       
        public KSEvoConfig() {
            super();
          }

          public void initialize(GridNodeClientConfig a_gridconfig)
              throws Exception {
           
            if (a_gridconfig != null) {
              a_gridconfig.setSessionName("GRID_evolution_distributed");
            }
            Configuration ksconfig = new DefaultConfiguration();
                ksconfig.setEventManager(new EventManager());
               
                ksconfig.setPreservFittestIndividual(true);
                ksconfig.setFitnessFunction(new KSEvoFitnessFunction   a_knapsackVolume));
               
                Gene[] sampleGenes = new Gene[itemVolumes.length];
            for (int i = 0; i < itemVolumes.length; i++) {
              sampleGenes[i] = new IntegerGene(ksconfig, 0,
                                               (int) Math.ceil(a_knapsackVolume /
                  itemVolumes[i]));
            }
            IChromosome sampleChromosome = new Chromosome(ksconfig, sampleGenes);
            ksconfig.setSampleChromosome(sampleChromosome);
           
            ksconfig.setPopulationSize(100);
           
           
            setWorkerReturnStrategy(new EvoWorkerReturnStrategy());
           
            setGenotypeInitializer(new EvoGenotypeInitial());
           
            setWorkerEvolveStrategy(new KSEvoStrategy());
           
            setRequestSplitStrategy(new EvoRequestSplitStrategy(ksconfig));
            setConfiguration(ksconfig);
           
            setClientEvolveStrategy(new EvoClientEvolveStrategy());
           
          }........ etc.

With this setup the grid (Client!) don't work at all. Client conects and login properly, but then - Exception:

java.lang.NullPointerException
        at org.jgap.distr.grid.JGAPClient.evolve(JGAPClient.java:163)
        at org.jgap.distr.grid.JGAPClient.run(JGAPClient.java:101)

Thanking you in adavnce for any help!

 

-----------------------------------------------------------------
Търси се двойник!
http://zoom.bg/page.php?bid=6

-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jgap-users mailing list
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users

Re: KnapSack problem on grid!

by Klaus Meffert-5 :: Rate this Message:

Reply to Author | View Threaded | Show Only this Message

Alex,

the NullPointerException seems to result out of a missing client feedback
object.
Please use ksconfig.setClientFeedback(feedbackHandler). For an
implementation of feedbackHandler see the several example classes, e.g.
examples.grid.fitnessDistributed.MyClientFeedback, or simply do an empty
implementation of interface IClientFeedback.

I will enhance the source so that a dummy client feedback handler is set per
default.

Best

Klaus
www.klaus-meffert.com

 

> -----Original Message-----
> From: jgap-users-bounces@...
> [mailto:jgap-users-bounces@...] On Behalf Of Alex Ef
> Sent: Tuesday, May 27, 2008 8:20 PM
> To: jgap-users@...
> Subject: [jgap-users] KnapSack problem on grid!
>
> Hello JGAP users/admin, I have semestrial project on parallel
> computing and I must make parallel genetic algorithm to solve
> KnapSack problem. I'm trying to use JGAP to create grid. In
> examples there is KnapSack problem and grid example. My
> question is how to combine two examples to one working grid
> solution? I use Fitness function from KnapSack example for
> Fitness function in my GridConfiguration class and configure
> grid in GridConfiguration like that (This is for GridClient -
> I start grid server and worker before that. All classes are
> just like in grid example for evolution distributed only
> Fitness and Config classes are modified):
>
> ..........
> public class KSEvoConfig extends GridConfigurationBase{
>
> public double a_knapsackVolume = 10000d;
> public final static double[] itemVolumes = {
>      50.2d, 14.8d, 27.5d, 6800.0d, 25.0d, 4.75d,
> 95.36d, 1500.7d, 18365.9d,
>      83571.1d};
> public final static String[] itemNames = {
>      "Monitor", "Fruit", "Radio", " Big TV",
> "Gameboy", "Small object",
>      "Medium object", "Big object", "Huge object",
> "Gigantic object"};
>
>
> public KSEvoConfig() {
>    super();
>  }
>
>  public void initialize(GridNodeClientConfig a_gridconfig)
>      throws Exception {
>    
>    if (a_gridconfig != null) {
>      a_gridconfig.setSessionName("GRID_evolution_distributed");
>    }
>    Configuration ksconfig = new DefaultConfiguration();
> ksconfig.setEventManager(new EventManager());
>
> ksconfig.setPreservFittestIndividual(true);
> ksconfig.setFitnessFunction(new
> KSEvoFitnessFunction   a_knapsackVolume));
>
> Gene[] sampleGenes = new Gene[itemVolumes.length];
>    for (int i = 0; i < itemVolumes.length; i++) {
>      sampleGenes[i] = new IntegerGene(ksconfig, 0,
>                                       (int)
> Math.ceil(a_knapsackVolume /
>          itemVolumes[i]));
>    }
>    IChromosome sampleChromosome = new
> Chromosome(ksconfig, sampleGenes);
>    ksconfig.setSampleChromosome(sampleChromosome);
>    
>    ksconfig.setPopulationSize(100);
>    
>    
>    setWorkerReturnStrategy(new EvoWorkerReturnStrategy());
>    
>    setGenotypeInitializer(new EvoGenotypeInitial());
>    
>    setWorkerEvolveStrategy(new KSEvoStrategy());
>    
>    setRequestSplitStrategy(new
> EvoRequestSplitStrategy(ksconfig));
>    setConfiguration(ksconfig);
>    
>    setClientEvolveStrategy(new EvoClientEvolveStrategy());
>    
>  }........ etc.
>
> With this setup the grid (Client!) don't work at all. Client
> conects and login properly, but then - Exception:
>
> java.lang.NullPointerException
> at org.jgap.distr.grid.JGAPClient.evolve(JGAPClient.java:163)
> at org.jgap.distr.grid.JGAPClient.run(JGAPClient.java:101)
>
> Thanking you in adavnce for any help!
>
>  
>
> -----------------------------------------------------------------
> Търси се двойник!
> http://zoom.bg/page.php?bid=6
>
> --------------------------------------------------------------
> -----------
> This SF.net email is sponsored by: Microsoft Defy all
> challenges. Microsoft(R) Visual Studio 2008.
> http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
> _______________________________________________
> jgap-users mailing list
> jgap-users@...
> https://lists.sourceforge.net/lists/listinfo/jgap-users
>


-------------------------------------------------------------------------
This SF.net email is sponsored by: Microsoft
Defy all challenges. Microsoft(R) Visual Studio 2008.
http://clk.atdmt.com/MRT/go/vse0120000070mrt/direct/01/
_______________________________________________
jgap-users mailing list
jgap-users@...
https://lists.sourceforge.net/lists/listinfo/jgap-users
LightInTheBox - Buy quality products at wholesale price