diff --git a/Cargo.toml b/Cargo.toml index 1b27010..a769ec6 100644 --- a/Cargo.toml +++ b/Cargo.toml @@ -1,6 +1,6 @@ [package] name = "cp_sat" -version = "0.3.0" +version = "0.3.1" edition = "2018" description = "Rust bindings to the Google CP-SAT constraint programming solver." documentation = "https://docs.rs/cp_sat" diff --git a/build.rs b/build.rs index 9cbf008..d52392c 100644 --- a/build.rs +++ b/build.rs @@ -7,10 +7,10 @@ fn main() { ) .unwrap(); - if !std::env::var("DOCS_RS").is_ok() { + if std::env::var("DOCS_RS").is_err() { let ortools_prefix = std::env::var("ORTOOLS_PREFIX") .ok() - .unwrap_or("/opt/ortools".into()); + .unwrap_or_else(|| "/opt/ortools".into()); cc::Build::new() .cpp(true) .flag("-std=c++17") diff --git a/src/builder.rs b/src/builder.rs index 004b394..7b63ee7 100644 --- a/src/builder.rs +++ b/src/builder.rs @@ -624,6 +624,28 @@ impl CpModelBuilder { } } + /// Delete all solution hints. + /// + /// # Example + /// + /// ``` + /// # use cp_sat::builder::CpModelBuilder; + /// # use cp_sat::proto::CpSolverStatus; + /// let mut model = CpModelBuilder::default(); + /// let x = model.new_int_var([(0, 100)]); + /// let y = model.new_bool_var(); + /// model.add_hint(x, 42); + /// model.add_hint(y, 1); + /// model.del_hints(); + /// model.add_hint(x, 75); + /// model.add_hint(y, 0); + /// let response = model.solve(); + /// assert_eq!(response.status(), CpSolverStatus::Optimal); + /// ``` + pub fn del_hints(&mut self) { + self.proto.solution_hint = None; + } + /// Sets the minimization objective. /// /// # Example @@ -914,7 +936,7 @@ impl> From<(i64, V)> for LinearExpr { res.vars.push(var.0); res.coeffs.push(coeff); } - return res; + res } } impl, const L: usize> From<[(i64, V); L]> for LinearExpr {