• Gurobi Staff

Hi,

Are there any other constraints/decisions involved? Otherwise I feel the non-MIP-approach might be sufficient:

• calculate the "unconstrained" solution, e.g. 20/30/50 by simple math
• see which assignments violate a local constraint (e.g. the first country can receive max 10)
• just fix those violating countries to their bound
• calculate the remaining capacity (90) and demand (60+100)
• divide the remaining capacity based on remaining demand (60*90/160 / 100*90/160)

If you're still curious how to formulate this as a MIP - consider using the Gurobi "general constraints" to define a variable holding the maximum ratio. So you would have variables for the absolute quantities for each country, as well as variables for the ratio supply/demand per country, and a single helper variable representing the maximum ratio over all countries. You would use addGenConstrMax() to link the ratio variables to the max-ratio variable.

Kind regards,
Ronald

Thank you Ronald!

We do have some other constraints that makes a heuristic approach quite challenging to implement. For example we have constraints saying item A, B & C going to the same country needs to be of equal quantity, and also something like item X and item Y going to the same country needs to add up to (or be less than or equal to) a certain number (basically X & Y being mutually exclusive), etc.

Thanks for pointing us to addGenConstrMax() function! We are already using some max_() within our formulation.

What we've tried to do is minimizing the max_() of these ratios for each item. However, we've found edge cases that only looking at the 1st max couldn't handle. For example we have 1 item going to 3 countries J, K, L. If for some reason country J cannot receive fewer than a certain quantity, forcing their ratio to be very big (let's just say 100%), the process then basically stops balancing between the other two countries K and L, because the 2nd and 3rd largest ratios don't count towards the objective. Essentially we had to factor in the 2nd and 3rd largest ratios into account which really created a lot of trouble

• Gurobi Staff

Hi,

Ah, understood - then MIP becomes an attractive option.

Indeed addGenConstrMax() and max_() essentially provide the same functionality.

Would it be an option to try and minimize variability between the supply/demand ratios over all countries? In theory we want them to be close to totalSupply/totalDemand, so you could minimize the sum of squared differences between actualSupply[i]/actualDemand[i] and totalSupply/totalDemand across all countries i. Although this makes the model non-linear, Gurobi might be able to solve it without problems.

Kind regards,
Ronald