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: TransitionMatrixCollectionTransition 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: f64Weight 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: GeneticOperatorsGenetic operators for crossover/mutation strategy selection.
Default: POX crossover + Swap mutation.
Override with with_operators.
Implementations§
Source§impl SchedulingGaProblem
impl SchedulingGaProblem
Sourcepub fn new(tasks: &[Task], resources: &[Resource]) -> Self
pub fn new(tasks: &[Task], resources: &[Resource]) -> Self
Creates a problem from domain models.
Sourcepub fn with_transition_matrices(
self,
matrices: TransitionMatrixCollection,
) -> Self
pub fn with_transition_matrices( self, matrices: TransitionMatrixCollection, ) -> Self
Sets transition matrices.
Sourcepub fn with_tardiness_weight(self, weight: f64) -> Self
pub fn with_tardiness_weight(self, weight: f64) -> Self
Sets tardiness weight (0.0 = pure makespan, 1.0 = pure tardiness).
Sourcepub fn with_process_times(
self,
process_times: HashMap<(String, i32, String), i64>,
) -> Self
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.
Sourcepub fn with_operators(self, operators: GeneticOperators) -> Self
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,
});Sourcepub fn decode(&self, chromosome: &ScheduleChromosome) -> Schedule
pub fn decode(&self, chromosome: &ScheduleChromosome) -> Schedule
Decodes a chromosome into a Schedule.