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
37 .iter()
38 .flat_map(|j| j.operations.iter())
39 .map(|o| o.duration)
40 .sum()
41 }
42}
43
44#[derive(Debug, Clone, Serialize, Deserialize)]
46pub struct ScheduledOp {
47 pub job_id: usize,
48 pub job_name: String,
49 pub machine_id: usize,
50 pub op_index: usize,
51 pub start: i64,
52 pub end: i64,
53}
54
55#[derive(Debug, Clone, Serialize, Deserialize)]
57pub struct JobShopPlan {
58 pub request_id: String,
59 pub schedule: Vec<ScheduledOp>,
60 pub makespan: i64,
61 pub lower_bound: Option<i64>,
63 pub solver: String,
64 pub status: String,
66 pub wall_time_seconds: f64,
67}