Runfeng Yu
Runfeng Yu

Reputation: 3

How to find the non-zero minimum value in the objective function of a mathematical model

It is a mathematical model. x is the 0-1 decision variable, and c is Non-negative coefficients. The tricky problem I'm facing now is how to find that non-zero minimum value in a series of cx. The objective function is as follows.

enter image description here

Now, I want to find the minimum element in this equation which means the minimum number (c) selected by decision virables (x). However, when an element is not selected, cx for this element equals 0. Because c>0, then, the objective function equals 0. That's not what I want.

How to modify this objective function? Adding variables, non-linearity are allowed. I hope to solve this problem with gurobi. How to deal with the modified fuction for gurobi? (Linearization? Gurobi's built-in functions?)

Thanks!

Upvotes: 0

Views: 352

Answers (2)

Axel Kemper
Axel Kemper

Reputation: 11322

You could introduce an auxiliary continuous variable Zi for every binary decision variable Xi.

Then add constraints for all Zi:

Zi = Xi * Ci + (1-Xi) * BIG_NUMBER

Due to this constraint, Zi is either Ci or BIG_NUMBER. You can then take the minimum of all Zi as your objective.

Have a look at this article about conditional statements and indicator constraints.

Upvotes: 0

Felix Benning
Felix Benning

Reputation: 1192

How about this:

def find_non_zero_minimum(cs, xs):
    options = [ c*x for c,x in zip(cs,xs)]
    options.sort()
    return next(filter(None, options)) # return first (smallest element) after filtering out zeros

Upvotes: 0

Related Questions