Refactor for clean root module and documentation
This commit is contained in:
committed by
Guillaume P
parent
eb3c60678c
commit
5db1b7d4df
@@ -1,19 +1,24 @@
|
||||
use cp_sat::builder::CpModelBuilder;
|
||||
use cp_sat::proto::CpSolverStatus;
|
||||
|
||||
fn main() {
|
||||
let mut model = cp_sat::builder::CpModelBuilder::default();
|
||||
let mut model = CpModelBuilder::default();
|
||||
|
||||
let x = model.new_int_var_with_name([(0, 2)], "x");
|
||||
let y = model.new_int_var_with_name([(0, 2)], "y");
|
||||
let z = model.new_int_var_with_name([(0, 2)], "z");
|
||||
model.add_all_different([x, y, z]);
|
||||
println!("{:#?}", model);
|
||||
println!("model stats: {}", model.stats());
|
||||
|
||||
model.add_ne(x, y);
|
||||
|
||||
let response = model.solve();
|
||||
println!("{:#?}", response);
|
||||
println!(
|
||||
"response stats: {}",
|
||||
cp_sat::cp_solver_response_stats(&response, false)
|
||||
"{}",
|
||||
cp_sat::ffi::cp_solver_response_stats(&response, false)
|
||||
);
|
||||
assert_eq!(response.status(), cp_sat::proto::CpSolverStatus::Optimal);
|
||||
assert!(x.solution_value(&response) != y.solution_value(&response));
|
||||
assert!(x.solution_value(&response) != z.solution_value(&response));
|
||||
assert!(y.solution_value(&response) != z.solution_value(&response));
|
||||
|
||||
if response.status() == CpSolverStatus::Optimal {
|
||||
println!("x = {}", x.solution_value(&response));
|
||||
println!("y = {}", y.solution_value(&response));
|
||||
println!("z = {}", z.solution_value(&response));
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user