Skip to content
New issue

Have a question about this project? # for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “#”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? # to your account

How to maximise particular variables? #8

Open
Virtlink opened this issue Jun 27, 2018 · 0 comments
Open

How to maximise particular variables? #8

Virtlink opened this issue Jun 27, 2018 · 0 comments

Comments

@Virtlink
Copy link

I'm trying to find a maximal solution for my problem. I found an example where they maximize P here, which translated to Rust would be:

let p = Variable::new();
let x = Variable::new();
let y = Variable::new();

let mut solver = Solver::new();
solver.add_constraints(&[
    p |EQ(REQUIRED)| x * -3.0 + y * -4.0,
    x + y |LE(REQUIRED)| 4.0,
    x * 2.0 + y |LE(REQUIRED)| 5.0,
    x |GE(REQUIRED)| 0.0,
    y |GE(REQUIRED)| 0.0
]).unwrap();

println!("Values:");
println!("P: {}", solver.get_value(p));  // -15
println!("x: {}", solver.get_value(x));  // 1
println!("y: {}", solver.get_value(y));  // 3

Except, I don't know how to specify that I want to optimize for P. I should get the values P=-16, x=0, y=4. How can I get similar results using your Cassowary crate?

# for free to join this conversation on GitHub. Already have an account? # to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant