khalil-research / PyEPO

A PyTorch-based End-to-End Predict-then-Optimize Library for Linear and Integer Programming
MIT License
429 stars 56 forks source link

Negative costs #7

Closed jackliu333 closed 1 year ago

jackliu333 commented 1 year ago

The SPO+ loss function has a term 2pred_cost - real_cost. It seems an error will throw up when 2pred_cost < real_cost for a given edge. Is there any control over this potential issue? Or is it already handled in the codes?

LucasBoTang commented 1 year ago

Hi Jack, Sorry for the late response. It is a good question. Negative cost may make the optimization model wrong, and further cause crashes or unknown issues. Therefore, you should be careful in your formulation. For example, I add the extra upper bound (1) to avoid the unbounded case in the shortest path. In short, you need some additional action to handle this issue. In addition, the paper "Learning with Combinatorial Optimization Layers: a Probabilistic Approach" provides a multiplicative method that resolves this issue.