Main
~~(~~:~~html:)~~

<iframe width=~~"560" height="315" src="https://www.youtube.com/embed/RPKPjqdiX1c" frameborder="0" allowfullscreen></iframe>~~

(:htmlend:)

~~Discrete decision variables are those that have only certain levels or quantities that are acceptable at an optimal solution. Examples of discrete variables are binary (e.g. off/on or 0/1), integer (e.g. 4,5,6,7), or general discrete values that are not integer (e.g. 1/4 cm, 1/2 cm, 1 cm).~~

!!!! Integer Variables

!!!! Discrete Variables

Discrete decision variables are those that have only certain levels or quantities that are acceptable at an optimal solution. Examples of discrete variables are binary (e.g. off/on or 0/1), integer (e.g. 4,5,6,7), or general discrete values that are not integer (e.g. 1/4 cm, 1/2 cm, 1 cm).

## Integer/Binary Variables in Optimization

## Main.IntegerBinaryVariables History

Hide minor edits - Show changes to output

Changed line 11 from:

This is not the case, however. Solving discrete problems is harder than continuous problems. This is because of the combinatorial explosion that occurs in all but the smallest problems. For example if we have two variables which can each take 10 values, we have 10*10 = 100 possibilities. If we have 10 variables that can each take 10 values, we have 10^10 possibilities. Even with the fastest computer, it would take a long time to evaluate all of these. There are numerical solvers that use methods such branch and bound and outer approximations to efficiently solve problems with binary, integer, or discrete variables.

to:

This is not the case, however. Solving discrete problems is harder than continuous problems. This is because of the combinatorial explosion that occurs in all but the smallest problems. For example if we have two variables which can each take 10 values, we have 10*10 = 100 possibilities. If we have 10 variables that can each take 10 values, we have 10^10 possibilities. Even with the fastest computer, it would take a long time to evaluate all of these. There are numerical solvers such as [[https://apopt.com|APOPT]] and [[https://projects.coin-or.org/Bonmin|Bonmin]] that use methods such branch and bound and outer approximations to efficiently solve problems with binary, integer, or discrete variables.

Changed line 11 from:

This is not the case, however. Solving discrete problems is harder than continuous problems. This is because of the combinatorial explosion that occurs in all but the smallest problems. For example if we have two variables which can each take 10 values, we have 10*10 = 100 possibilities. If we have 10 variables that can each take 10 values, we have 10^10 possibilities. Even with the fastest computer, it would take a long time to evaluate all of these.

to:

This is not the case, however. Solving discrete problems is harder than continuous problems. This is because of the combinatorial explosion that occurs in all but the smallest problems. For example if we have two variables which can each take 10 values, we have 10*10 = 100 possibilities. If we have 10 variables that can each take 10 values, we have 10^10 possibilities. Even with the fastest computer, it would take a long time to evaluate all of these. There are numerical solvers that use methods such branch and bound and outer approximations to efficiently solve problems with binary, integer, or discrete variables.

Changed lines 7-10 from:

<iframe width

(:htmlend:)

to:

* [[http://apmonitor.com/online/view_pass.php?f=minlp.apm|Solve Mixed Integer Nonlinear Programming Problems Online]]

Changed lines 13-16 from:

!!!! Integer

to:

!!!! Binary Variables

Added lines 21-22:

!!!! Integer Variables

Added lines 30-33:

!!!! Discrete Variables

Discrete decision variables are those that have only certain levels or quantities that are acceptable at an optimal solution. Examples of discrete variables are binary (e.g. off/on or 0/1), integer (e.g. 4,5,6,7), or general discrete values that are not integer (e.g. 1/4 cm, 1/2 cm, 1 cm).

Changed line 1 from:

(:title Integer~~ and ~~Binary Variables in Optimization:)

to:

(:title Integer/Binary Variables in Optimization:)

Added lines 1-33:

(:title Integer and Binary Variables in Optimization:)

(:keywords integer, binary, discrete, mixed integer:)

(:description Binary (0 or 1) or the more general integer (select integer 0 to 10), or other discrete decision variables are frequently used in optimization:)

Binary (0 or 1) or the more general integer (select integer 0 to 10), or other discrete decision variables are frequently used in optimization. Examples of discrete variables include ON/OFF state (0 or 1 binary), selection of multiple options (0 to 5 integers), and other variables that are naturally integers.

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/RPKPjqdiX1c" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

At first glance it might seem solving a discrete variable problem would be easier than a continuous problem. After all, for a variable within a given range, a set of discrete values within the range is finite whereas the number of continuous values is infinite. When searching for an optimum, it seems it would be easier to search from a finite set rather than from an infinite set.

This is not the case, however. Solving discrete problems is harder than continuous problems. This is because of the combinatorial explosion that occurs in all but the smallest problems. For example if we have two variables which can each take 10 values, we have 10*10 = 100 possibilities. If we have 10 variables that can each take 10 values, we have 10^10 possibilities. Even with the fastest computer, it would take a long time to evaluate all of these.

Discrete decision variables are those that have only certain levels or quantities that are acceptable at an optimal solution. Examples of discrete variables are binary (e.g. off/on or 0/1), integer (e.g. 4,5,6,7), or general discrete values that are not integer (e.g. 1/4 cm, 1/2 cm, 1 cm).

!!!! Integer Variables

Integer or binary variables are defined in the APMonitor Modeling Language by appending a variable name with '''int'''. An binary decision variable is an integer variable with bounds between 0 and 1.

! Binary decision variable (0 or 1)

Variables

int_b >=0 <=1

The range of upper and lower bounds can be increased or decreased to any range to create a more general integer variable.

! Integer decision variable (-5 to 10)

Variables

int_v >=-5 <=10

Nonlinear programming solvers (such as IPOPT) may not return an integer solution because they are designed for continuous variables. Mixed Integer Nonlinear Programming solvers (such as APOPT) are equipped to solve for binary or integer variables. Select the appropriate [[http://apmonitor.com/wiki/index.php/Main/OptionApmSolver|solver option]] to either find an initial solution without integer variables or an integer solution. It is sometimes desirable to find a non-integer solution first because of the often significant reduction in computation time without the integer variables.

See [[http://apmonitor.com/do/index.php/Main/DiscreteVariables|Dynamic Optimization with Discrete Variables]] and [[http://apmonitor.com/me575/index.php/Main/DiscreteOptimization|Discrete Optimization]].

(:keywords integer, binary, discrete, mixed integer:)

(:description Binary (0 or 1) or the more general integer (select integer 0 to 10), or other discrete decision variables are frequently used in optimization:)

Binary (0 or 1) or the more general integer (select integer 0 to 10), or other discrete decision variables are frequently used in optimization. Examples of discrete variables include ON/OFF state (0 or 1 binary), selection of multiple options (0 to 5 integers), and other variables that are naturally integers.

(:html:)

<iframe width="560" height="315" src="https://www.youtube.com/embed/RPKPjqdiX1c" frameborder="0" allowfullscreen></iframe>

(:htmlend:)

At first glance it might seem solving a discrete variable problem would be easier than a continuous problem. After all, for a variable within a given range, a set of discrete values within the range is finite whereas the number of continuous values is infinite. When searching for an optimum, it seems it would be easier to search from a finite set rather than from an infinite set.

This is not the case, however. Solving discrete problems is harder than continuous problems. This is because of the combinatorial explosion that occurs in all but the smallest problems. For example if we have two variables which can each take 10 values, we have 10*10 = 100 possibilities. If we have 10 variables that can each take 10 values, we have 10^10 possibilities. Even with the fastest computer, it would take a long time to evaluate all of these.

Discrete decision variables are those that have only certain levels or quantities that are acceptable at an optimal solution. Examples of discrete variables are binary (e.g. off/on or 0/1), integer (e.g. 4,5,6,7), or general discrete values that are not integer (e.g. 1/4 cm, 1/2 cm, 1 cm).

!!!! Integer Variables

Integer or binary variables are defined in the APMonitor Modeling Language by appending a variable name with '''int'''. An binary decision variable is an integer variable with bounds between 0 and 1.

! Binary decision variable (0 or 1)

Variables

int_b >=0 <=1

The range of upper and lower bounds can be increased or decreased to any range to create a more general integer variable.

! Integer decision variable (-5 to 10)

Variables

int_v >=-5 <=10

Nonlinear programming solvers (such as IPOPT) may not return an integer solution because they are designed for continuous variables. Mixed Integer Nonlinear Programming solvers (such as APOPT) are equipped to solve for binary or integer variables. Select the appropriate [[http://apmonitor.com/wiki/index.php/Main/OptionApmSolver|solver option]] to either find an initial solution without integer variables or an integer solution. It is sometimes desirable to find a non-integer solution first because of the often significant reduction in computation time without the integer variables.

See [[http://apmonitor.com/do/index.php/Main/DiscreteVariables|Dynamic Optimization with Discrete Variables]] and [[http://apmonitor.com/me575/index.php/Main/DiscreteOptimization|Discrete Optimization]].