You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I was trying to input a linear program using matrix format, i.e., with constraints in the form of Ax = b. I constructed a COO matrix A but cannot multiply it with the variable x.
I get the following error "cannot multiply numopt::matrix::coo::CooMat<f64> by good_lp::Variable".
Do you have any more complicated examples where the input is a matrix?
Below is my code.
fn main() -> Result<(), Box<dyn Error>> {
let x = arr1(&[1.0]);
let c = arr1(&[1.0]);
let b = arr1(&[10.0]);
let u = arr1(&[15.0]);
let l = arr1(&[-15.0]);
let p = vec![false ];
let A: CooMat<f64> = CooMat::<f64>::new(
(1 , 1 ),
vec![0],
vec![0],
vec![1.0]
);
variables! {
vars:
a <= x;
} // variables can also be added dynamically
let solution = vars.maximise( &a )
.using(default_solver) // multiple solvers available
.with(constraint!( A * a == 5))
.solve()?;
println!("a={} b={}", solution.value(a), solution.value(b));
println!("a + b = {}", solution.eval(a + b));
Ok(())
}
}
Thank you for your help!
The text was updated successfully, but these errors were encountered:
Hello and thanks for getting in touch !
Are you sure what you are looking for is a modeler ?
If you don't have meaningful names for your variables and functions to apply to them, then using good_lp is kind of an useless overhead for you. You can still use it if you want (just create n variables and add the constraint A[i] * var_i == 5 for each one), but you would probably be better off just using the underlying solvers that good_lp uses directly.
The goal of an lp modeler is to create this matrix for you without you having to worry about anything but the variables that make sense in your problem and the relationship between them. If you already have the matrix, you can skip the modeler altogether, and use a solver (such as highs or cbc) directly.
Hi,
I was trying to input a linear program using matrix format, i.e., with constraints in the form of Ax = b. I constructed a COO matrix A but cannot multiply it with the variable x.
I get the following error "cannot multiply
numopt::matrix::coo::CooMat<f64>
bygood_lp::Variable
".Do you have any more complicated examples where the input is a matrix?
Below is my code.
Thank you for your help!
The text was updated successfully, but these errors were encountered: