Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Update genetic algorithm #52

Merged
merged 6 commits into from
Sep 20, 2023
Merged

Update genetic algorithm #52

merged 6 commits into from
Sep 20, 2023

Conversation

Timotshak
Copy link
Collaborator

  • Update the genetic operators so that they create only valid chromosomes. Remove the validity check in the schedule_builder. This allows to control the number of schedules created during the execution of the genetic algorithm through parameters population_size and generation_number. This also increases the number of individuals in offspring obtained at each iteration, which improves the quality of the genetic algorithm.

  • Introduce combined operators of mutation and crossover. They combine operators for order and resources to make them easier to use in genetic algorithm

  • Update mutation operators of resources and resource borders by replacing the uniform distribution of possible gene mutations to improve the stability of chromosome changes

  • Replace loops in genetic operators with numpy operations for time improvement on large instances

  • Introduce two-point crossover operator for order. It has higher performance on large instances

  • Introduce resource borders updating function. It changes the resource borders to the peak values in the schedule obtained from the chromosome. This is necessary to track current resource borders when optimizing resources

  • Add to resources crossover operator ability to change resource borders based on parents. This is necessary to create valid chromosomes when optimizing resources

  • Update the schedule_builder and Genetic Algorithm, adding the ability to run it in a two-stage mode, which implements lexicographic optimization for planning to a deadline. This approach is better than integrating the deadline into the optimization criterion because it allows one to obtain solutions that exactly satisfy the deadline.

  • Introduce new tests for operators, two-stage genetic algorithm and resource borders updating function

 - Update the genetic operators so that they create only valid
   chromosomes. Remove the validity check in the schedule_builder.
   This allows to control the number of schedules created during the
   execution of the genetic algorithm through parameters
   population_size and generation_number. This also increases the
   number of individuals in offspring obtained at each iteration,
   which improves the quality of the genetic algorithm.

 - Introduce combined operators of mutation and crossover. They
   combine operators for order and resources to make them easier
   to use in genetic algorithm

 - Update mutation operators of resources and resource borders by
   replacing the uniform distribution of possible gene mutations to
   improve the stability of chromosome changes

 - Replace loops in genetic operators with numpy operations for time
   improvement on large instances

 - Introduce two-point crossover operator for order. It has higher
   performance on large instances

 - Introduce resource borders updating function. It changes the
   resource borders to the peak values in the schedule obtained from
   the chromosome. This is necessary to track current resource borders
   when optimizing resources

 - Add to resources crossover operator ability to change resource
   borders based on parents. This is necessary to create valid
   chromosomes when optimizing resources

 - Update the schedule_builder and Genetic Algorithm, adding the
   ability to run it in a two-stage mode, which implements
   lexicographic optimization for planning to a deadline.
   This approach is better than integrating the deadline into the
   optimization criterion because it allows one to obtain
   solutions that exactly satisfy the deadline.

 - Introduce new tests for operators, two-stage genetic
   algorithm and resource borders updating function
@Timotshak Timotshak added the enhancement New feature or request label Sep 18, 2023
Copy link
Collaborator

@StannisMod StannisMod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Some changes requested

sampo/scheduler/genetic/base.py Outdated Show resolved Hide resolved
sampo/scheduler/genetic/base.py Outdated Show resolved Hide resolved
sampo/scheduler/genetic/operators.py Show resolved Hide resolved
sampo/scheduler/genetic/operators.py Outdated Show resolved Hide resolved
sampo/scheduler/genetic/operators.py Outdated Show resolved Hide resolved
sampo/scheduler/genetic/schedule_builder.py Outdated Show resolved Hide resolved
 - Remove deadline from constructor of Genetic Scheduler

 - Remove rudimentary functionality from fitness
   functions. Evaluate method and evaluator attribute
   are removed

 - Extract generalized function mutate_values for
   resources and resource borders mutation

 - Remove asserts in genetic algorithm

 - Introduce categorical type for individuals. It is
   needed in genetic algorithm
@Timotshak Timotshak closed this Sep 19, 2023
@Timotshak Timotshak reopened this Sep 19, 2023
 - Delete try-except blocks

 - Add set_deadline method calling
@Timotshak Timotshak closed this Sep 19, 2023
@Timotshak Timotshak reopened this Sep 19, 2023
@Timotshak Timotshak added the refactor The rewriting of existing code to improve code quality label Sep 19, 2023
@StannisMod StannisMod self-requested a review September 20, 2023 07:56
Copy link
Collaborator

@StannisMod StannisMod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And some more changes

sampo/scheduler/genetic/base.py Outdated Show resolved Hide resolved
sampo/scheduler/genetic/operators.py Show resolved Hide resolved
sampo/scheduler/genetic/operators.py Outdated Show resolved Hide resolved
 - Update logic of fitness functions in genetic
   algorithm. Genetic Scheduler initialisation
   takes constructor of fitness object, that
   creates in each schedule method calling.
   Schedule_builder takes now fitness object

 - Make IndividualType uppercase
@Timotshak Timotshak closed this Sep 20, 2023
@Timotshak Timotshak reopened this Sep 20, 2023
@StannisMod StannisMod self-requested a review September 20, 2023 12:59
StannisMod
StannisMod previously approved these changes Sep 20, 2023
Copy link
Collaborator

@StannisMod StannisMod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

These great changes approved

StannisMod
StannisMod previously approved these changes Sep 20, 2023
Copy link
Collaborator

@StannisMod StannisMod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

And... approved!

Copy link
Collaborator

@StannisMod StannisMod left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah, sh*t... here we go accept

@Timotshak Timotshak merged commit b46bf25 into main Sep 20, 2023
1 check passed
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request refactor The rewriting of existing code to improve code quality
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants