Questions Tagged With binaryhttp://www.or-exchange.com/tags/binary/?type=rssquestions tagged <span class="tag">binary</span>enSun, 10 Apr 2016 05:45:52 -0400What products to make, how much to make and in what plants to make them?http://www.or-exchange.com/questions/13548/what-products-to-make-how-much-to-make-and-in-what-plants-to-make-them<p>A company wants to make <strong>3 new products</strong> for the upcoming week. Each product can be made in <strong>1 of 2 plants</strong>.</p>
<p><strong>At most 2</strong> of the 3 new products should be chosen to be made. <strong>Only 1 of the plants</strong> should be chosen to make the (0, 1 or 2) products.</p>
<p>Below is</p>
<ol>
<li>
<p>the <strong>Production hours</strong> for a unit of product $j$ in plant $i$</p>
</li>
<li>
<p><strong>total available production hours</strong> available for the week</p>
</li>
<li>
<p>the <strong>profit/unit and maximum sales/week</strong> estimated for product $i$</p>
</li>
</ol>
<p><a href="http://i.stack.imgur.com/akaTR.png"><img alt="enter image description here" src="http://i.stack.imgur.com/akaTR.png"></a></p>
<p>I have to formulate a linear model that allows to solve for <strong>what products to make, how much to make and in what plants to make them</strong> so that we can <strong>maximise profit</strong>.</p>
<hr>
<p><strong>What I tried</strong>:</p>
<p>Let $x_{ij}$ be hrs spent on making product j in plant i</p>
<p>where $i=1,2$ and $j=A,B,C$.</p>
<p>Let $y_i$ be $1$ if plant $i$ is chosen and $0$ otherwise.</p>
<p>Let $z_j$ be $1$ if product $j$ is made and $0$ otherwise.</p>
<p>We want to maximise profit given by</p>
<p>$$z = 5000(x_{1A} + x_{2A}) + 7000(x_{1B} + x_{2B}) + 3000(x_{1C} + x_{2C})$$</p>
<p>subject to the constraints:</p>
<ol>
<li>
<p>Plant 1 Production Hours $$3x_{1A} + 4x_{1B} + 2x_{1C} \le 30$$</p>
</li>
<li>
<p>Plant 2 Production Hours $$4x_{2A} + 6x_{2B} + 2x_{2C} \le 40$$</p>
</li>
<li>
<p>Max Sales for Product A $$x_{1A} + x_{2A} \le 7$$</p>
</li>
<li>
<p>Max Sales for Product B $$x_{1B} + x_{2B} \le 5$$</p>
</li>
<li>
<p>Max Sales for Product C $$x_{1C} + x_{2C} \le 9$$</p>
</li>
<li>
<p>At most one plant $$y_1 + y_2 \le 1$$</p>
</li>
<li>
<p>If plant $i$ is not chosen then $x_{iA} = x_{iB} = x_{iC} = 0$: $$x_{ij} \le My_i$$</p>
</li>
<li>
<p>At most two products $$z_A + z_B + z_C \le 2$$</p>
</li>
<li>
<p>If product $j$ is not made then $x_{1j} = x_{2j} = 0$: $$x_{ij} \le Mz_j$$</p>
</li>
<li>
<p>Nonnegativity (we can consider fractions of hours) $$x_{ij} \ge 0$$</p>
</li>
<li>
<p>Binary constraint $$y_i, z_j \in {0,1}$$</p>
</li>
</ol>
<hr>
<p>Is that right?</p>BCLCSun, 10 Apr 2016 05:45:52 -0400http://www.or-exchange.com/questions/13548/what-products-to-make-how-much-to-make-and-in-what-plants-to-make-thembinaryinteger-programmingconstraintformulationslinear-programmingLinearize equality constraint with binary variablehttp://www.or-exchange.com/questions/12581/linearize-equality-constraint-with-binary-variable<p>I have an equality constraint like z(Ax-y)=0, where z>=0 ,and x is binary variable, and y is bounded variable Lx<=y<=Ux. How can it be linearized? Thanks in advance.</p>zunTue, 07 Jul 2015 16:58:40 -0400http://www.or-exchange.com/questions/12581/linearize-equality-constraint-with-binary-variablelinearizationbinaryvariableequalityconstraintHow to select a binary variable according to precedencehttp://www.or-exchange.com/questions/12525/how-to-select-a-binary-variable-according-to-precedence<p>Hello, OR experts,</p>
<p>Now I want to express the following constraint:</p>
<p>A series of binary variables \(x_1, x_2, x_3,...\) satisfy
\[\sum\limits_i {x_i} = 1\]
But I want to set the one with the smallest indice to 1, i.e., \(x_1 = 1\).
What I am thinking is to assign a weight to each variable, e.g., \(c_i\) to \(x_i\) satisfying \(c_i < c_{i-1}\), then add a constraint like this:
\[c_i x_i \leq \sum\limits_j {c_j x_j}, \forall i\]</p>
<p>But it doesn't work. Do you have some ideas to express this in a constraint (not in the objective)?</p>
<p>Thank you very much.</p>LinYuanTue, 23 Jun 2015 17:32:00 -0400http://www.or-exchange.com/questions/12525/how-to-select-a-binary-variable-according-to-precedencebinaryformulationsconstraintTo represent a logic constrainthttp://www.or-exchange.com/questions/11607/to-represent-a-logic-constraint<p>Hello, now I have a problem, in which \(x\) is the binary variable, constant \(a \ge 0\), \(f(x)\) is a function of \(x\).</p>
<p>How to represent the following relationship:</p>
<p>If \(a \le f(x)\), then \(x=0\).</p>
<p>Do you have some ideas for the constraint above? Many thanks for that, it seems a bottle-neck in my current problem. I want to fix it. Thank you.</p>LinYuanTue, 10 Mar 2015 10:52:36 -0400http://www.or-exchange.com/questions/11607/to-represent-a-logic-constraintlinearizationbinarynonlinearconstraintsHandling binary variables in sedumi solverhttp://www.or-exchange.com/questions/8393/handling-binary-variables-in-sedumi-solver<p>I need to linearize z(i,j)=abs(xi-xj) for which I write the following code:</p>
<pre><code>for i=1:n
for j=1:n
if(i<=j)
z(i,j)>=x(i)-x(j);
z(i,j)<=x(i)-x(j)+2*(y(i,j));
z(i,j)>=x(j)-x(i);
z(i,j)<=x(j)-x(i)+1*(1-y(i,j));
y(i,j)>=0; y(i,j)<=1;
end
end
end
</code></pre>
<p>where <code>y(i,j)</code> are binary.</p>
<p>This code is wrong as <code>y(i,j)</code> are continuous here.</p>
<p>I am solving in CVX sedumi and sedumi does not accomodate integer variables.</p>
<p>How can I handle the linearization?</p>
<p>Thanking you.</p>R K NayakThu, 22 Aug 2013 00:17:19 -0400http://www.or-exchange.com/questions/8393/handling-binary-variables-in-sedumi-solverlinearizationbinarycvxartificial-variableReflection of a binary variable to a summation index in an MILP problemhttp://www.or-exchange.com/questions/8282/reflection-of-a-binary-variable-to-a-summation-index-in-an-milp-problem<p>Hello,</p>
<p>Is there anyway to incorporate the numerical information of a binary variable to a summation index? I have a term like: 1/(sum{i in S} A[i] in some of the constraints of my MILP model where A[i] is a parameter. I want summation merely happens for the indices that the binary variable B[i,t] is equal to 1. For example assume:</p>
<p>S = {1, 2, ..., 10} and B[1,t] = B[3,t] = B[5,t] = B[7,t] = 1</p>
<p>instead of 1/(sum{i in S} A[i], I want to have 1/(sum{i in S1} A[i] where S1 = {1,3,5,7}.</p>
<p>It seems that simply multiplying A[i] by the binary variable B[i,t] doesn't solve the problem. Can we implement this while keeping the model linear? </p>
<p>Also, the constraints of the model in which the term 1/(sum{i in S} A[i] appears looks like the following:</p>
<p>x[i,t] <= B[i,t]<em>A[i]</em>(10 - B[t]/(sum{i in S}A[i]));</p>
<p>where x[i,t] is a continuous variable and A[i] and B[t] are parameters.</p>
<p>Thanks in advance,</p>
<p>Amir</p>s_amiruwMon, 08 Jul 2013 11:56:01 -0400http://www.or-exchange.com/questions/8282/reflection-of-a-binary-variable-to-a-summation-index-in-an-milp-problemsummationbinarymilpindex