add hints from solution (+ clippy fixes) (#23)

This commit is contained in:
Frédérick Sauvage
2021-09-14 10:28:56 +02:00
committed by GitHub
parent d8db7d7eb3
commit 942034c4bb
3 changed files with 26 additions and 4 deletions
+1 -1
View File
@@ -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"
+2 -2
View File
@@ -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")
+23 -1
View File
@@ -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<V: Into<IntVar>> From<(i64, V)> for LinearExpr {
res.vars.push(var.0);
res.coeffs.push(coeff);
}
return res;
res
}
}
impl<V: Into<IntVar>, const L: usize> From<[(i64, V); L]> for LinearExpr {