Hello, I want to create a sort of indicator function to use in my objective function. Here is the set up:
I have x_i for i from 1 to 10 as my decision variables. I have a list of lists (let's call it y, with one of these lists being called y_r) as an input; for example, 100 lists of 10 numbers, which are all randomly generated decision variables for which I have to compare my solution. If x_i is larger than y_r_i, I add a certain value v_i to my objective value. Else, I add 0.
This is my current code (r is given in this function):
gb.quicksum(v[i]*x[i] if x[i] > y[r][i] else 0 for i in range(10))
The error I get is:
TypeError: '>' not supported between instances of 'Var' and 'int'
i.e. due to x[i] being a decision variable in my Gurobi model and y[r][i] being an input integer.
How can I make this objection function work?
Please sign in to leave a comment.