Require suggestion for given problem.

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view

Require suggestion for given problem.

Patel, Nachiket R. - EITL (HAZ)



We are developing system for stacking Circle Cylinder shape items on containers. (Like coin stack..)
And this problem have many constraints based on container type. (i.e Weight, Diameter, Type, Color)
We have defined these constraints into two categories . Hard and Soft (From analogy of JBoss Drools Solver, I tried it before JGAP)

Hard constraints are compulsory. If it does not fulfills then solution cannot be determined.
Soft constraints are constraints which should be optimized (I have set to Lower score means better score)

And Input will be “List of Containers” and “List of Cylinders”. Usual input will be 10 to 30 Cylinders and 4 to 8 containers
And Output should be filling up all the containers + [remaining unassigned cylinders] OR using all the cylinders
[AND Hard constraints must be adhered and soft constrains should be near to optimum]

Right now, I am giving Hard constraint much higher fitness then soft constraint. So if ONE hard constraint is broken then fitness will be say 30000, and if ONE soft constraint is broken then fitness will be 2500

Let me give you a hypothetical example for better understanding.
C1[height: 5,diameter:6,group-A],
C2[height: 7,diameter:4,group-B] ,
C3[height: 3,diameter:3,group-D],
C4[height: 4,diameter:8,group-C],
C5[height: 2,diameter:6,group-A],
C6[height: 8,diameter:9,group-A],
C7[height: 3,diameter:2,group-D]
C8[height: 6,diameter:2,group-B]

CON1[max-diameter:5, height: 10, max-capacity:3],
CON2[max-diameter:5, height: 10, max-capacity:3],
CON3[max-diameter:10, height: 8, max-capacity:3],
CON4[max-diameter:10, height: 8, max-capacity:3],

Hard Constraints
1. Container height
2. Container diameter
3. Max capacity

Soft Constraints
1. Minimum capacity wastage of containers
2. Lower diameter circle cannot be placed on higher diameter circle (i.e C3 on layer-1 and C2 on layer-2 should be avoided)
3. Circles with group [A,B] or [C,D] should be kept in one base. (i.e. rather than putting C1,C3 together prefer, C1,C5 together)

So in above detail, Input is CIRCLES + CONTAINERS and output should be (it’s just a representation, not a proper solution);
CON1 [0:C1, 1:C5,2:C6], (0,1,2 denotes layers)
CON2 [0:C2, 1:C4,2:C7],
CON3 [0:C3, 1:C5]
CON4 []

In this result, CON4 will be empty.. as there are no Circles available.
Sometimes in input number of circles are more around 30 and number of Containers are lesser (like 3 or 4) so, in that case.. elements list will remain unassigned.

I am maintaining a index based list and mapping it with IntegerGene. So if my chromosome is [2,4,6,1,0,3,5] then I’ll create a new List<Cylinder> for fitness calculation.


Fitness calculation function

It start filling Containers based on height and weight capacity. From given List<Cylinder> (which is created based on chromosome). After setting all Cylinders in Containers. Fitness value will be calculated on wastage of weight capacity and height capacity.

So please suggest better options for my settings. Here is my configuration.

Configuration gaConf = new DefaultConfiguration();
gaConf.setFitnessEvaluator(new DeltaFitnessEvaluator());


MutationOperator swapper = new SwappingMutationOperator(gaConf);


IChromosome sampleChromosome = new Chromosome(config, new IntegerGene(config), chromozomeSize);
Genotype genotype = Genotype.randomInitialGenotype(config);
List chromosomes = genotype.getPopulation().getChromosomes();
for (Object chromosome : chromosomes) {
     IChromosome chrom = (IChromosome) chromosome;
     for (int j = 0; j < chrom.size(); j++) {
         Gene gene = chrom.getGene(j);

·         Is my configuration okay? OR I am missing something?

·         Is IntegerGene appropriate for this problem?

·         I am only using SwappingMutationOperation.

But after 100 to 120 number of evolutions.. I do not get better fitness chromosome.

Please let me know if you required more information..



Nachiket Patel | Consultant | Essar Information Technology Ltd |
27th km, Surat Hazira Road, Hazira - 394270 |
T +91 9925241444 | +91 0261 2240904 |
E [hidden email] |


P Please don't print this e-mail unless you really need to.

The information contained in this electronic message and in any attachments to this message is confidential, legally privileged and intended only for the person or entity to which this electronic message is addressed. If you are not the intended recipient, please notify the system manager and you are hereby notified that any distribution, copying, review, retransmission, dissemination or other use of this electronic transmission or the information contained in it is strictly prohibited. Please accordingly also note that any views or opinions presented in this email are solely those of the author and may not represent those of the Company or bind the Company. This message has been scanned for viruses and dangerous content by Mail Scanner, and is believed to be clean. The Company accepts no liability for any damage caused by any virus transmitted by this email. < > .
Let Crystal Reports handle the reporting - Free Crystal Reports 2008 30-Day
trial. Simplify your report design, integration and deployment - and focus on
what you do best, core application coding. Discover what's new with
Crystal Reports now.
jgap-users mailing list
[hidden email]