1

I have an integer programming problem with a decision variable X_i_j_k_t that is 1 if job i was assigned to worker j for day k and shift t. I am maximizing the benefit of assigning orders to my workers. I have an additional binary variable Y_i_k_t that is 1 if the job was executed and a given day and shift (jobs might require more than one worker). How can I add this variable in CPLEX? So as to form, for example, sum(i, k, t)(Y_i_k_t) <= 1 (the order can´t be done more than once).

Thank you in advance

1
  • Welcome to Stackoverflow! Please consider reading the How to Ask section of the site. Please post the code you have tried out so far, and include any specific error cases that you are getting stuck on. Commented Nov 25, 2019 at 3:35

1 Answer 1

1

You did not say whether you use the CPLEX Python API or docplex. But in either case, you can call the functions that create variables multiple times.

So in the CPLEX Python API call Cplex.variables.add() again to add another set of variables.

In docplex just call Model.binary_var_dict() (or whatever method you used to create X) again for the Y variables.

Sign up to request clarification or add additional context in comments.

6 Comments

I am sorry. I am using the CPLEX Python API. So, with cplex.variables.add() I can add that binary variable? I'm not sure how exactly to do it.
Can you augment your question with the code that creates the X variable? Then I can show you how to analogously create the Y variables.
my_problem.variables.add(obj = coeficientes_funcion_objetivo, lb = [0]*data.n, ub = [1]*data.n, types=['B']*data.n). Where "coeficientes_funcion_objetivo" is my list with the benefit of each order per needed worker.
The functions returns the indices of the X variables. Now do the same to create Y variables and get their indices. Maybe take a look at the examples that ship with CPLEX. There are several examples that create multiple types of variables. For example, admipex8.py which creates variables called supply and cost.
Ok, I think I got it, thanks! The objective function of this problem is maximize the benefit minus the cost. These are two different sums. How can I do thiis with CPLEX Python API?
|

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.