I have the following example of a small example of a linear program in Rust:
use good_lp::{variables, variable, default_solver, SolverModel, Solution, constraint};
fn main() {
// Declaring binary variables
let mut vars = variables!();
let x = vars.add(variable().binary());
let y = vars.add(variable().binary());
// Creating the modell and solving it
let mut model = vars
.maximise(2.5 * x - y)
.using(default_solver);
model = model.with(constraint!(2 * x + y <= 1)); // Adding Constrain
model = model.with(constraint!(x + y <= 1)); // Adding Constraint
let solution = model.solve().unwrap();
// Printing the result's
println!("x = {}", solution.value(x));
println!("y = {}", solution.value(y));
}
I want to allow in the code that the found solution doesn't have to be 100% perfect. For example 99% would be also fine. If you use PuLP_CBC with Python you only need to write a command like "PULP_CBC_CMD(gapRel=0.01)".
I searched in crates.io in the docs of coin_cbc for some similar syntax/notation but I couldn't find anything so far. Did I miss something or much better do you know how to write it?