funkelab / motile

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

feat: use ilpy.expressions in motile Constraints #30

Closed tlambert03 closed 1 year ago

tlambert03 commented 1 year ago

This updates most of the motile constraints and costs to use ilpy.Expression introduced in https://github.com/funkelab/ilpy/pull/9 and released in ilpy v0.3.0

Another notable (API breaking) change is that indexing into a Variable (i.e. Variable.__get_item__) now returns an ilpy.Variable instance, rather than an integer, as per https://github.com/funkelab/motile/pull/30#issuecomment-1483333393. In many cases, that Variable can be used exactly as the integer could before (it can be cast to an int with int(), it can be used as an index in a Solution, etc...), but it can also be used to create expressions.

funkey commented 1 year ago

I wonder if we shouldn't make the return value of variables[key] an ilpy.Variable right away instead of returning the index?

ilpy.Variables have an index, and that is precisely the one we need. This would make writing constraints a bit easier, but most importantly

for node, selection_indicator in selection_indicators.items():
    # use selection_indicator here

assumes less familiarity with the internals than

for node, index in selection_indicators.items():
    # know what to do with an index
codecov-commenter commented 1 year ago

Codecov Report

Merging #30 (db64ba6) into main (624d903) will decrease coverage by 0.30%. The diff coverage is 100.00%.

:exclamation: Your organization is not using the GitHub App Integration. As a result you may experience degraded service beginning May 15th. Please install the Github App Integration for your organization. Read more.

@@            Coverage Diff             @@
##             main      #30      +/-   ##
==========================================
- Coverage   92.77%   92.47%   -0.30%     
==========================================
  Files          30       30              
  Lines         747      718      -29     
==========================================
- Hits          693      664      -29     
  Misses         54       54              
Impacted Files Coverage Δ
motile/constraints/constraint.py 100.00% <100.00%> (ø)
motile/constraints/max_children.py 100.00% <100.00%> (ø)
motile/constraints/max_parents.py 100.00% <100.00%> (ø)
motile/constraints/select_edge_nodes.py 100.00% <100.00%> (ø)
motile/costs/features.py 82.85% <100.00%> (+1.03%) :arrow_up:
motile/solver.py 96.96% <100.00%> (ø)
motile/variables/node_appear.py 100.00% <100.00%> (ø)
motile/variables/variable.py 63.88% <100.00%> (+1.03%) :arrow_up:
tlambert03 commented 1 year ago

This is now ready for review @funkey

funkey commented 1 year ago

Perfect, looks all good. Thanks a lot!