use serde::{Deserialize, Serialize};
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Operation {
pub machine_id: usize,
pub duration: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct Job {
pub id: usize,
pub name: String,
pub operations: Vec<Operation>,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobShopRequest {
pub id: String,
pub jobs: Vec<Job>,
pub num_machines: usize,
#[serde(default = "default_time_limit")]
pub time_limit_seconds: f64,
}
fn default_time_limit() -> f64 {
30.0
}
impl JobShopRequest {
pub fn horizon(&self) -> i64 {
self.jobs.iter().flat_map(|j| j.operations.iter()).map(|o| o.duration).sum()
}
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct ScheduledOp {
pub job_id: usize,
pub job_name: String,
pub machine_id: usize,
pub op_index: usize,
pub start: i64,
pub end: i64,
}
#[derive(Debug, Clone, Serialize, Deserialize)]
pub struct JobShopPlan {
pub request_id: String,
pub schedule: Vec<ScheduledOp>,
pub makespan: i64,
pub lower_bound: Option<i64>,
pub solver: String,
pub status: String,
pub wall_time_seconds: f64,
}