rust-or / rust-lp-modeler

Lp modeler written in Rust
MIT License
96 stars 29 forks source link

`run` function from solver return a Solution `struct` #39

Closed jcavat closed 5 years ago

jcavat commented 5 years ago

This would change the dsl API

from:

let (solver_status, values) = solver::run(&prob).unwrap();

to:

let solution = solver::run(&prob).unwrap();
jcavat commented 5 years ago

6d97ca8 close first step of this issue

zappolowski commented 5 years ago

The implementation of your parsing rules (e.g. on this line) will fail if the variable isn't found in the HashMap. So, you seem to assume, that all variables are always present in the output. Unfortunately, this isn't always true as e.g. CBC just puts nonzero values in the results file (if there are more than a certain number of variables).

E.g. this input yields an output which looks like:

Optimal (within gap tolerance) - objective value -4186.00000000
      3 d3_v10                 1                    -724
      7 d3_v19                 1                    -521
     16 d3_v08                 1                    -172
     19 d3_v13                 1                    -149
     20 d3_v04                 1                    -141
     21 d3_v05                 2                    -140
     32 d1_v02                 1                    -334
     33 d1_v01                 1                    -323
     36 d1_v03                 2                    -288
     39 d1_v22                 2                    -162
     40 d1_v17                 2                    -154
     54 d2_v02                 1                    -334
jcavat commented 5 years ago

Good point ! 7d59fff should fix this

jcavat commented 5 years ago

66a904b close second step of this issue

jcavat commented 5 years ago

eval should be used with caution. Need to add more test for this new feature.

jcavat commented 5 years ago

Thanks to @zappolowski for the eval function given here : https://github.com/jcavat/rust-lp-modeler/issues/37#issuecomment-544129756