sampo.scheduler.genetic.base#

Overview#

Classes#

GeneticScheduler

Class for hybrid scheduling algorithm, that uses heuristic algorithm to generate

Classes#

class sampo.scheduler.genetic.base.GeneticScheduler(number_of_generation: int | None = 50, mutate_order: Optional[float or None] = None, mutate_resources: Optional[float or None] = None, size_of_population: Optional[float or None] = None, rand: random.Random | None = None, seed: Optional[float or None] = None, n_cpu: int = 1, weights: list[int] = None, fitness_constructor: Callable[[sampo.schemas.time.Time | None], sampo.scheduler.genetic.operators.FitnessFunction] = TimeFitness, scheduler_type: sampo.scheduler.base.SchedulerType = SchedulerType.Genetic, resource_optimizer: sampo.scheduler.resource.base.ResourceOptimizer = IdentityResourceOptimizer(), work_estimator: sampo.schemas.time_estimator.WorkTimeEstimator = DefaultWorkEstimator(), optimize_resources: bool = False, verbose: bool = True)#

Bases: sampo.scheduler.base.Scheduler

Class for hybrid scheduling algorithm, that uses heuristic algorithm to generate first population and genetic algorithm to search the best solving

__str__() str#

Return str(self).

get_params(works_count: int) tuple[float, float, int]#

Return base parameters for model to make new population

Parameters:

works_count

Returns:

set_use_multiprocessing(n_cpu: int)#

Set the number of CPU cores

Parameters:

n_cpu

set_time_border(time_border: int)#
set_deadline(deadline: sampo.schemas.time.Time)#

Set the deadline of tasks

Parameters:

deadline

set_weights(weights: list[int])#
set_optimize_resources(optimize_resources: bool)#
set_verbose(verbose: bool)#
static generate_first_population(wg: sampo.schemas.graph.WorkGraph, contractors: list[sampo.schemas.contractor.Contractor], landscape: sampo.schemas.landscape.LandscapeConfiguration = LandscapeConfiguration(), spec: sampo.schemas.schedule_spec.ScheduleSpec = ScheduleSpec(), work_estimator: sampo.schemas.time_estimator.WorkTimeEstimator = None, deadline: sampo.schemas.time.Time = None, weights=None)#

Algorithm, that generate first population

Parameters:
  • landscape

  • wg – graph of works

  • contractors

  • spec

Returns:

schedule_with_cache(wg: sampo.schemas.graph.WorkGraph, contractors: list[sampo.schemas.contractor.Contractor], landscape: sampo.schemas.landscape.LandscapeConfiguration = LandscapeConfiguration(), spec: sampo.schemas.schedule_spec.ScheduleSpec = ScheduleSpec(), validate: bool = False, assigned_parent_time: sampo.schemas.time.Time = Time(0), timeline: sampo.scheduler.timeline.base.Timeline | None = None) tuple[sampo.schemas.schedule.Schedule, sampo.schemas.time.Time, sampo.scheduler.timeline.base.Timeline, list[sampo.schemas.graph.GraphNode]]#

Build schedule for received graph of workers and return the current state of schedule It’s needed to use this method in multy agents model

Parameters:
  • landscape

  • wg

  • contractors

  • spec

  • validate

  • assigned_parent_time

  • timeline

Returns: