Expand description
Safe rust bindings to the CPLEX solver API.
§Example
use cplex_rs::*;
let env = Environment::new().unwrap();
let mut problem = Problem::new(env, "my_prob").unwrap();
let v0 = problem.add_variable(Variable::new(VariableType::Continuous, 1.0, 0.0, 1.0, "x0")).unwrap();
let v1 = problem.add_variable(Variable::new(VariableType::Continuous, 10.0, 0.0, 1.0, "x1")).unwrap();
let c0 = problem.add_constraint(Constraint::new(ConstraintType::GreaterThanEq, 0.3, None, vec![(v0, 1.0)])).unwrap();
let c1 = problem.add_constraint(Constraint::new(ConstraintType::Eq, 1.0, None, vec![(v0, 1.0), (v1, 1.0)])).unwrap();
let solution = problem.set_objective_type(ObjectiveType::Maximize)
.unwrap()
.solve_as(ProblemType::Linear)
.unwrap();
assert_eq!(solution.variable_value(v0), 0.3);
assert_eq!(solution.variable_value(v1), 0.7);
Re-exports§
Modules§
Structs§
- Constraint
- Constraint
Id - A constraint identifier, unique with respect to a given problem instance
- Environment
- Problem
- A CPLEX problem instance
- Solution
- Variable
- Variable
Id - A variable identifier, unique with respect to a given problem instance