ferrox/jobshop/
problem.rs1use serde::{Deserialize, Serialize};
2
3#[derive(Debug, Clone, Serialize, Deserialize)]
5pub struct Operation {
6 pub machine_id: usize,
7 pub duration: i64,
8}
9
10#[derive(Debug, Clone, Serialize, Deserialize)]
12pub struct Job {
13 pub id: usize,
14 pub name: String,
15 pub operations: Vec<Operation>,
17}
18
19#[derive(Debug, Clone, Serialize, Deserialize)]
21pub struct JobShopRequest {
22 pub id: String,
23 pub jobs: Vec<Job>,
24 pub num_machines: usize,
25 #[serde(default = "default_time_limit")]
26 pub time_limit_seconds: f64,
27}
28
29fn default_time_limit() -> f64 {
30 30.0
31}
32
33impl JobShopRequest {
34 pub fn horizon(&self) -> i64 {
36 self.jobs.iter().flat_map(|j| j.operations.iter()).map(|o| o.duration).sum()
37 }
38}
39
40#[derive(Debug, Clone, Serialize, Deserialize)]
42pub struct ScheduledOp {
43 pub job_id: usize,
44 pub job_name: String,
45 pub machine_id: usize,
46 pub op_index: usize,
47 pub start: i64,
48 pub end: i64,
49}
50
51#[derive(Debug, Clone, Serialize, Deserialize)]
53pub struct JobShopPlan {
54 pub request_id: String,
55 pub schedule: Vec<ScheduledOp>,
56 pub makespan: i64,
57 pub lower_bound: Option<i64>,
59 pub solver: String,
60 pub status: String,
62 pub wall_time_seconds: f64,
63}