Refactor for clean root module and documentation
This commit is contained in:
committed by
Guillaume P
parent
eb3c60678c
commit
5db1b7d4df
+26
-1
@@ -1,5 +1,5 @@
|
||||
use cp_sat::builder::CpModelBuilder;
|
||||
use cp_sat::proto::CpSolverStatus;
|
||||
use cp_sat::proto::{CpSolverStatus, SatParameters};
|
||||
|
||||
#[test]
|
||||
fn presentation_problem() {
|
||||
@@ -57,3 +57,28 @@ fn solving_a_cp_problem() {
|
||||
assert!(3 * x_val - 5 * y_val + 7 * z_val <= 45);
|
||||
assert!(5 * x_val + 2 * y_val - 6 * z_val <= 37);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn solve_with_time_limit_sample_sat() {
|
||||
let mut model = CpModelBuilder::default();
|
||||
let domain = [(0, 2)];
|
||||
let x = model.new_int_var_with_name(domain, "x");
|
||||
let y = model.new_int_var_with_name(domain, "y");
|
||||
let z = model.new_int_var_with_name(domain, "z");
|
||||
|
||||
model.add_ne(x, y);
|
||||
|
||||
let mut params = SatParameters::default();
|
||||
params.max_time_in_seconds = Some(10.);
|
||||
|
||||
let response = model.solve_with_parameters(¶ms);
|
||||
println!("{:?}", response);
|
||||
|
||||
assert_eq!(response.status(), CpSolverStatus::Optimal);
|
||||
let x_val = x.solution_value(&response);
|
||||
let y_val = y.solution_value(&response);
|
||||
let z_val = z.solution_value(&response);
|
||||
println!("x = {}", x_val);
|
||||
println!("y = {}", y_val);
|
||||
println!("z = {}", z_val);
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user