rust-or / rust-lp-modeler

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

Evaluate objective function without parsing #38

Closed jcavat closed 5 years ago

jcavat commented 5 years ago

Provide a function that evaluate the objective function who may have been returned by the run function.

Maybe something like:

let (solver_status, values, objective) = solver::run(&prob).unwrap();
zappolowski commented 5 years ago

I'm not sure whether the objective should be unconditionally evaluated. There are use cases where its actual value isn't important, but just the values of the variables is of interest.

Thus, I propose to make it two step:

let (status, values) = solver.run(&problem).unwrap();
let objective = problem.eval(&values);

eval is just the name I've used and I'm open for better suggestions. Another benefit of this approach is its backward compatibility.

Alternatively it might be a better to wrap the return value of solver.run into its own struct (e.g. named Solution), which then provides ways of retrieving status, values and objective.

jcavat commented 5 years ago

It's a good point. Returning a Solution structure seems a good ideal. Especially if we add new features such as eval. Maybe a Solution should refer to a Problem. With this, we could call eval without giving parameters.

jcavat commented 5 years ago

Create a new issue for that : #39