#50 JGAP 3.3.3 example Knapsack KnapsackMain.java

closed-works-for-me
Klaus
5
2009-02-04
2008-11-09
jasonshiu
No

It uses Math.ceil(). It's right!?

because parameter of IntegerGene require upper bound that is inclusive.

ex:
java -classpath ".;../../jgap.jar" KnapsackMain 100

cash 10.2d
coin 3.3d

The best solution has a fitness value of 4.99999896E8
It contained the following:
10 x cash

For a total volume of 102.0 ccm
Expected volume was 100.0 ccm
Volume difference is 2.0 ccm

or, it means I should change a bigger bag?

Discussion

  • Klaus

    Klaus - 2008-11-15
    • assigned_to: nobody --> klausikm
    • status: open --> open-works-for-me
     
  • Klaus

    Klaus - 2008-11-15

    It does not have to do with the ceil construct in the main class, as this is only used for the sample gene (and could be skipped IMO). More important is the fitness function. There, to high volumes with the same difference as too low volumes could be weighted worse. As this only is an example, I don't think it is a bug. the behaviour you observed is just a simplification.

     
  • Klaus

    Klaus - 2009-02-04
    • status: open-works-for-me --> closed-works-for-me
     

Log in to post a comment.

Get latest updates about Open Source Projects, Conferences and News.

Sign up for the SourceForge newsletter:

JavaScript is required for this form.





No, thanks