Closed keegit closed 2 years ago
Quick side note: this crate is awesome!
One problem I am running into is that I want to create an f64 variable that lies within the domain of all real numbers. How can I achieve this?
f64
This is what I am currently trying to do, but it does not compile due to From<bool> is not implemented for f64.
From<bool> is not implemented for f64
use std::error::Error; use good_lp::{constraint, coin_cbc, SolverModel, variables}; fn main() -> Result<(), Box<dyn Error>> { let INF: f32 = f32::INFINITY; let NEG_INF: f32 = f32::NEG_INFINITY; variables! { vars: NEG_INF <= x1 <= INF; NEG_INF <= x2 <= INF; } let _solution = vars.minimise(2 * x1 + 3 * x2) .using(coin_cbc) .with(constraint!((3 * x1) + (4 * x2) >= 1)) .solve()?; Ok(()) }
Edit: I can specify either a lower or upper bound but not both; I am wondering if this is suitable for this situation.
Use clamp() :)
clamp()
No, don't use clamp. Variables are unbounded by default.
variables! { problem: x1; x2; }
Quick side note: this crate is awesome!
One problem I am running into is that I want to create an
f64
variable that lies within the domain of all real numbers. How can I achieve this?This is what I am currently trying to do, but it does not compile due to
From<bool> is not implemented for f64
.Edit: I can specify either a lower or upper bound but not both; I am wondering if this is suitable for this situation.