Binbin2lin: Difference between revisions

From TomWiki
Jump to navigationJump to search
(Created page with "==Purpose== Adds constraints when modeling with binary variables which is the product of two other variables. ==Calling Syntax== <syntaxhighlight lang="matlab"> Prob = binbin2...")
 
No edit summary
 
(2 intermediate revisions by the same user not shown)
Line 1: Line 1:
[[Category:Utility Functions]]
==Purpose==
==Purpose==


Line 5: Line 6:
==Calling Syntax==
==Calling Syntax==


<syntaxhighlight lang="matlab">
<source lang="matlab">
Prob = binbin2lin(Prob, idx4, idx1, idx2, idx3)
Prob = binbin2lin(Prob, idx4, idx1, idx2, idx3)
</syntaxhighlight>
</source>


==Inputs==
==Inputs==
Line 23: Line 24:
|}
|}


==Description  of Outputs==
==Outputs==
{| class="wikitable"
{| class="wikitable"
!Output||Description
!Output||Description

Latest revision as of 08:14, 10 January 2012

Purpose

Adds constraints when modeling with binary variables which is the product of two other variables.

Calling Syntax

Prob = binbin2lin(Prob, idx4, idx1, idx2, idx3)

Inputs

Prob Problem structure to be converted.
idx4 Indices for b4 variables.
idx1 Indices for b1 variables.
idx2 Indices for b2 variables.
idx3 Indices for b3 variables.

Outputs

Output Description
Prob Problem structure with added constraints.

Description

b4 = b1 * b2. The problem should be built with the extra variable b4 in place of the b1*b2 products.

The indices of the unique product variables are needed to convert the problem properly.

Three inequalities are added to the problem:

b4 <= b1

b4 <= b2

b4 >= b1 + b2 - 1

By adding this b4 will always be the product of b1 and b2.

The routine also handles products of three binary variables. b4 = b1 * b2 * b3. The following

constraints are then added:

b4 <= b1

b4 <= b2

b4 <= b3

b4 >= b1 + b2 + b3 - 1