1

I have a list x(variable in MIP) of outcomes.

x = [1,-1,-1,-1,1,1,-1,1,1,1,1,-1,1,-1,-1,1]

1 represent a win and -1 represent a loss. In this case the max winning streak is 4 and max losing streak is 3, thus overall max streak is 4.

How can we formulate an MIP where the objective is to minimize maximum overall streak?

How should the constraints look like?

Vinay
  • 235
  • Presumably you have in mind one or more control variables that affect the outcome (the larger of the longest winning streak and the longest losing streak). How you formulate an MIP depends on what you consider those control variables to be. – hardmath Mar 24 '20 at 21:58
  • Let me try to explain my original problem. A is a list of actual outcomes(constants) and B(control variable) is a list of predictions. X is derived from A and B such that if A =B(correct prediction)then 1 else -1. The other constraint is B repeats after every 10 predictions, like b1=b11=b21......and b2=b12=b22.... I basically simplified the problem to ask here to construct a constraint for a streak . You may try the whole problem or just assume X is the control variable. – Vinay Mar 25 '20 at 01:07
  • I also posted a different question for the A = B part here – Vinay Mar 25 '20 at 01:08
  • A ∈ {1,-1} and B ∈ {1,-1} – Vinay Mar 25 '20 at 01:54

1 Answers1

2

Let $z$ represent the maximum streak length. The problem is to minimize $z$ subject to \begin{align} z &\ge k\left(\sum_{j=t}^{t+k-1} x_j - k + 1\right) &&\text{for all $k,t$}\tag1\\ z &\ge k\left(-\sum_{j=t}^{t+k-1} x_j - k + 1\right) &&\text{for all $k,t$}\tag2 \end{align} Constraint $(1)$ forces $z\ge k$ if $x_t=\dots=x_{t+k-1}=1$. Constraint $(2)$ forces $z\ge k$ if $x_t=\dots=x_{t+k-1}=-1$.


For the other part, just take $x_j = a_j b_j$, where $a_j,b_j,x_j\in\{-1,1\}$ and the value of each $a_j$ is known.

RobPratt
  • 50,938
  • Is it x(j) or x(t) in the constraints? Let's say x ranges from x1, x2, x3.......xn, meaning we get n(n+1)/2 constraints for Constraint (1) and same number for Constraint (2). Total constraints would be n(n+1). In my actual problem n =1350 i.e., the MIP has almost 1.8M constraints. I am not sure how long will this take on google ORtools. Can I put an upper limit for k to 15, so that total constraints will be few (implying minimize z but max of z can be 15) – Vinay Mar 25 '20 at 00:48
  • Sorry, it should be $x_j$. Corrected just now. If you limit $k$ too much, the solver will cheat by setting $z$ smaller than it should be. You could also try generating the constraints dynamically only if they are violated. What does the rest of your MIP look like? – RobPratt Mar 25 '20 at 01:00
  • Thank you for the correction. I explained the actual problem under the comments of the question. "Generating constraints dynamically" - this is new to me. I would appreciate if you can guide/direct me to read about this concept. – Vinay Mar 25 '20 at 01:08
  • Also called row generation: Solve without the constraints, check for violations, include violated constraints, repeat until no more violations. – RobPratt Mar 25 '20 at 01:31
  • Okay, I will if I can. Could you give an attempt on this – Vinay Mar 25 '20 at 01:34
  • @Rob..could you take a try at this – Vinay Mar 29 '20 at 22:13