optim/
lib.rs

1use std::collections::HashMap;
2
3pub struct Model {
4  variables: HashMap<String, Option<f64>>,
5  constraints: Vec<Constraint>,
6}
7
8impl Model {
9  pub fn new() -> Self {
10    Model {
11      variables: HashMap::new(),
12      constraints: vec![],
13    }
14  }
15
16  pub fn solve() -> Result<Solution, SolverError> {
17    Ok(Solution)
18  }
19
20  pub fn add_variable(&mut self, variable: Variable) {
21    self.variables.insert(variable.name, variable.value);
22  }
23
24  pub fn add_constraint(&mut self, constraint: Constraint) {}
25  pub fn maximise(&mut self, variable: Variable) {}
26  pub fn minimise(&mut self, variable: Variable) {}
27}
28
29pub struct Variable {
30  name: String,
31  value: Option<f64>,
32}
33
34impl Variable {
35  pub fn new(name: String) -> Self {
36    Variable { name, value: None }
37  }
38}
39
40pub struct Constraint;
41pub struct Solution;
42pub struct SolverError;