Mixed Integer Nonlinear Programming

Main.IntegerBinaryVariables History

Show minor edits - Show changes to output

Changed line 35 from:
m.Obj(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
to:
m.Minimize(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
Changed line 62 from:
m.Obj(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
to:
m.Minimize(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
Changed line 85 from:
m.Obj(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
to:
m.Minimize(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
Changed lines 92-97 from:
See [[https://apmonitor.com/do/index.php/Main/DiscreteVariables|Dynamic Optimization with Discrete Variables]] and [[https://apmonitor.com/me575/index.php/Main/DiscreteOptimization|Discrete Optimization]].
to:
!!!! Additional Resources

*
[[https://apmonitor.com/do/index.php/Main/DiscreteVariables|Dynamic Optimization with Discrete Variables]]
* [[https://apmonitor.com/me575/index.php/Main/DiscreteOptimization|Discrete Optimization]]
* [[https://apmonitor.com/pdc/index.php/Main/LinearProgramming|Linear Programming]]
* [[Main/IntegerProgramming|Integer Linear Programming (ILP)]]
Changed line 5 from:
[[Main/IntegerProgramming|Integer Programming]] is a type of optimization problem where the variables are restricted to discrete whole number values. A Mixed-Integer Programming problem is when some of the variables are continuous and some are discrete.
to:
[[Main/IntegerProgramming|Integer Programming]] is a type of optimization problem where the variables are restricted to discrete whole number values. A Mixed-Integer Programming problem is when some of the variables are continuous and some are discrete. Mixed-Integer Nonlinear Programming (MINLP) also includes nonlinear equations and requires specialized MINLP solvers such as [[https://apopt.com|APOPT]].
Changed line 1 from:
(:title Mixed Integer Nonlinear Programming (MINLP) in Optimization:)
to:
(:title Mixed Integer Nonlinear Programming:)
Added lines 4-5:

[[Main/IntegerProgramming|Integer Programming]] is a type of optimization problem where the variables are restricted to discrete whole number values. A Mixed-Integer Programming problem is when some of the variables are continuous and some are discrete.
October 27, 2020, at 05:06 PM by 172.58.59.248 -
Changed lines 1-2 from:
(:title Integer/Binary Variables in Optimization:)
(:keywords integer, binary, discrete, mixed integer:)
to:
(:title Mixed Integer Nonlinear Programming (MINLP) in Optimization:)
(:keywords
integer, MINLP, MILP, binary, discrete, mixed integer:)
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 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.
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.
Added lines 17-18:
'''APMonitor Model File'''
Added lines 23-39:
'''Python Gekko'''

Binary variables '''x1''' and '''x2''' problem are solved with [[https://gekko.readthedocs.io/en/latest/|Python GEKKO]]. The option '''integer'''=True is used to switch the variable from continuous to discrete form. The [[https://apopt.com|APOPT solver]] is required to solve problem with integer variables.

(:source lang=python:)
from gekko import GEKKO
m = GEKKO() # create GEKKO model
# create binary variables
x1 = m.Var(integer=True,lb=0,ub=1)
x2 = m.Var(integer=True,lb=0,ub=1)
m.Obj(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
m.options.SOLVER = 1 # APOPT solver
m.solve()
print('x1: ' + str(x1.value[0]))
print('x2: ' + str(x2.value[0]))
(:sourceend:)

Changed lines 42-43 from:
The range of upper and lower bounds can be increased or decreased to any range to create a more general integer variable.
to:
The range of upper and lower bounds can be increased or decreased to any range to create an integer variable.

'''APMonitor Model File'''

Added lines 50-66:
'''Python Gekko'''

Integer variables '''x1''' and '''x2''' problem are solved with [[https://gekko.readthedocs.io/en/latest/|Python GEKKO]]. The option '''integer'''=True is used to switch the variable from continuous to discrete variables and the range is expanded from 0-1 to a wider range for both variables.

(:source lang=python:)
from gekko import GEKKO
m = GEKKO() # create GEKKO model
# create integer variables
x1 = m.Var(integer=True,lb=-5,ub=10)
x2 = m.Var(integer=True,lb=-1,ub=2)
m.Obj(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
m.options.SOLVER = 1 # APOPT solver
m.solve()
print('x1: ' + str(x1.value[0]))
print('x2: ' + str(x2.value[0]))
(:sourceend:)

Added lines 72-88:

'''Python Gekko'''

Integer variable '''x1''' and [[https://en.wikipedia.org/wiki/Special_ordered_set|Special Ordered Set]] '''x2''' variables are solved with [[https://gekko.readthedocs.io/en/latest/|Python GEKKO]]. The '''sos1''' Gekko function is used to create the SOS1 variable.

(:source lang=python:)
from gekko import GEKKO
m = GEKKO() # create GEKKO model
x1 = m.Var(integer=True,lb=-5,ub=10)
# create Special Ordered Set variable
x2 = m.sos1([0.5, 1.15, 2.6, 5.2])
m.Obj(4*x1**2-4*x2*x1**2+x2**2+x1**2-x1+1)
m.options.SOLVER = 1 # APOPT solver
m.solve()
print('x1: ' + str(x1.value[0]))
print('x2: ' + str(x2.value[0]))
(:sourceend:)
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:
(:html:)
<iframe width
="560" height="315" src="https://www.youtube.com/embed/RPKPjqdiX1c" frameborder="0" allowfullscreen></iframe>
(:htmlend:)

to:
* [[https://apmonitor.com/online/view_pass.php?f=minlp.apm|Solve Mixed Integer Nonlinear Programming Problems Online]]
Changed lines 13-16 from:
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
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 [[https://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 [[https://apmonitor.com/do/index.php/Main/DiscreteVariables|Dynamic Optimization with Discrete Variables]] and [[https://apmonitor.com/me575/index.php/Main/DiscreteOptimization|Discrete Optimization]].