Skip to main content

SchedulingGaProblem

Struct SchedulingGaProblem 

Source
pub struct SchedulingGaProblem {
    pub activities: Vec<ActivityInfo>,
    pub resources: Vec<Resource>,
    pub task_categories: HashMap<String, String>,
    pub transition_matrices: TransitionMatrixCollection,
    pub deadlines: HashMap<String, i64>,
    pub release_times: HashMap<String, i64>,
    pub tardiness_weight: f64,
    pub process_times: HashMap<(String, i32, String), i64>,
    pub operators: GeneticOperators,
    /* private fields */
}
Expand description

GA problem definition for scheduling optimization.

Decodes chromosomes into schedules and evaluates fitness as makespan.

§Example

use u_schedule::ga::{SchedulingGaProblem, ActivityInfo};
use u_schedule::models::{Task, Resource, ResourceType};
use u_metaheur::ga::{GaConfig, GaRunner};

let tasks = vec![/* ... */];
let resources = vec![/* ... */];
let problem = SchedulingGaProblem::new(&tasks, &resources);
let config = GaConfig::default();
let result = GaRunner::run(&problem, &config);

Fields§

§activities: Vec<ActivityInfo>

Activity info (extracted from tasks).

§resources: Vec<Resource>

Available resources.

§task_categories: HashMap<String, String>

Task categories (task_id → category).

§transition_matrices: TransitionMatrixCollection

Transition matrices for setup times.

§deadlines: HashMap<String, i64>

Task deadlines (task_id → deadline_ms).

§release_times: HashMap<String, i64>

Task release times (task_id → release_ms).

§tardiness_weight: f64

Weight for tardiness in fitness (default: 0.5).

§process_times: HashMap<(String, i32, String), i64>

Per-resource processing times: (task_id, sequence, resource_id) → ms.

Used for SPT (Shortest Processing Time) initialization. If empty, SPT initialization is skipped and replaced with load-balanced.

§operators: GeneticOperators

Genetic operators for crossover/mutation strategy selection.

Default: POX crossover + Swap mutation. Override with with_operators.

Implementations§

Source§

impl SchedulingGaProblem

Source

pub fn new(tasks: &[Task], resources: &[Resource]) -> Self

Creates a problem from domain models.

Source

pub fn with_transition_matrices( self, matrices: TransitionMatrixCollection, ) -> Self

Sets transition matrices.

Source

pub fn with_tardiness_weight(self, weight: f64) -> Self

Sets tardiness weight (0.0 = pure makespan, 1.0 = pure tardiness).

Source

pub fn with_process_times( self, process_times: HashMap<(String, i32, String), i64>, ) -> Self

Sets per-resource processing times for SPT initialization.

When set, 25% of the initial population uses SPT (Shortest Processing Time) initialization. When empty, that 25% falls back to load-balanced.

Source

pub fn with_operators(self, operators: GeneticOperators) -> Self

Sets the genetic operators (crossover + mutation strategy).

§Example
use u_schedule::ga::SchedulingGaProblem;
use u_schedule::ga::operators::{GeneticOperators, CrossoverType, MutationType};

let problem = SchedulingGaProblem::new(&tasks, &resources)
    .with_operators(GeneticOperators {
        crossover_type: CrossoverType::LOX,
        mutation_type: MutationType::Invert,
    });
Source

pub fn decode(&self, chromosome: &ScheduleChromosome) -> Schedule

Decodes a chromosome into a Schedule.

Trait Implementations§

Source§

impl GaProblem for SchedulingGaProblem

Source§

type Individual = ScheduleChromosome

The individual (solution) type for this problem.
Source§

fn create_individual<R: Rng>(&self, rng: &mut R) -> ScheduleChromosome

Creates a random individual. Read more
Source§

fn evaluate(&self, individual: &ScheduleChromosome) -> f64

Evaluates an individual and returns its fitness. Read more
Source§

fn crossover<R: Rng>( &self, parent1: &ScheduleChromosome, parent2: &ScheduleChromosome, rng: &mut R, ) -> Vec<ScheduleChromosome>

Produces one or two offspring by recombining two parents. Read more
Source§

fn mutate<R: Rng>(&self, individual: &mut ScheduleChromosome, rng: &mut R)

Mutates an individual in place. Read more
Source§

fn on_generation( &self, _generation: usize, _best_fitness: <Self::Individual as Individual>::Fitness, )

Called at the end of each generation with the current best fitness. Read more
Source§

impl Send for SchedulingGaProblem

Source§

impl Sync for SchedulingGaProblem

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<V, T> VZip<V> for T
where V: MultiLane<T>,

Source§

fn vzip(self) -> V