funkelab / motile

Multi-Object Tracker using Integer Linear Equations
https://funkelab.github.io/motile/
MIT License
27 stars 5 forks source link

Obtaining value of objective function after solving #73

Closed lmanan closed 10 months ago

lmanan commented 10 months ago

This is a feature request and not an issue: I was wondering if there is currently an API-based way (as opposed to looping over all selected nodes and edges and summing individual costs) of obtaining the cost of the objective function which is minimized, post the solving? If not, this would be a useful feature to have.

tlambert03 commented 10 months ago

I believe that’s what ilpy.Solution.get_value() will give you: https://funkelab.github.io/ilpy/api.html#ilpy.Solution.get_value

I’m away from computer at the moment… so i can’t remember exactly how to get there from the motile Solver, but pretty sure it’s publicly accessible. Let me know if you can’t find it, or if it’s not what you’re looking for

lmanan commented 10 months ago

Thanks Talley.

solver =  motile.Solver(graph)
# add constraints
# add costs
solver.solve()
print(solver.solution.get_value())

works nicely!