Click here to Skip to main content
15,849,996 members
Please Sign up or sign in to vote.
1.67/5 (3 votes)
See more:
i'm doing a schedule generator for my university using a genetic algorithm and i made a chromosome that represent the problem ,
i want to know how to fill the chromosome in a random way respecting the hard constraint like: (two lecteur can't be in the same room at the same time ....) using a random()  function

Assuming that your next generation process will include mutation and cross-over of chromosomes, some of those will generate cases of "fatal genetic defects" I.e., chromosomes that don't meet the hard constraints. You will need to remove these from the population.
You can use the same process to remove any randomly generated initial chromosomes that have the "fatal genetic defect".
  generate a random chromosome
  if it is valid, put into initial population set
until population has desired count of "individuals"
Share this answer
Sergey Alexandrovich Kryukov 13-Oct-15 22:54pm    
Matt T Heffron 14-Oct-15 11:50am    
There is no solution because this is not a question !

First choose a language and say which one.

You described what you want/have to do: start working.

When you are stuck, come back with the piece of code you have done and explain what is your problem.

Otherwise, it look like a do my work, which is not what we do here.
Share this answer
Sergey Alexandrovich Kryukov 13-Oct-15 17:08pm    
You are right, but we usually put such content only in comments. This is not quite an answer. It could make an answer if you added some real advice, not so abstract, and not on just the ways to ask questions, but, say, something more concrete on the "start working" topic...
Patrice T 13-Oct-15 17:25pm    

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900