0

I'm new to programming and writing models. Most of the models I studied have straightforward objective functions and easy constraints that simple inequalities. I'm trying to write a constraint that would select the max of a set. Q is the queue selection and Ri is the rate of user i, both of which are dependant on time. Q and R will change every time period. a and b are constants. I know I should introduce a large number and a binary variable. I'm not sure where to start.

Q=[max(Ri)][a][b]

I read this thread (linear programming set a variable the max between two another variables) but I couldn't apply it to my example.

  • A little more information would be helpful. Maybe a dynamic programming model is more appropriate in your case given that things change with time ? Can;t really say for now. – skr Mar 04 '19 at 20:21

1 Answers1

0

If you want $Q=ab\max_i R_i$, there are two possibilities. Both start by adding the constraints $Q\ge abR_i$ for all $i$. If the nature of the remainder of the model is such that the smallest possible $Q$ is always optimal, that's all you need. Otherwise, you need to make sure that $Q=abR_i$ for some $i$ (i.e., that the solver does not inflate the value of $Q$. To do that, you need to introduce binary variables (one for each $i$). If we call them $z_i$, the added constraints are $$Q\le abR_i + M_i(1-z_i)\,\forall i$$(where the $M_i$ are sufficiently large constants) and $$\sum_i z_i = 1.$$

prubin
  • 4,923