Mathematical Programs with Equilibrium Constraints (MPECs) are formulations that can be used to model certain classes of discrete events. MPECs can be more efficient than solving mixed integer formulations of the optimization problems because it avoids the combinatorial difficulties of searching for optimal discrete variables.
SIGN Operator !MPEC formulation
forSIGN function
y
=SIGN
(x
)returns a value y
,where:
the corresponding element of X
isgreater than zero
-
1 ifthe corresponding element of X
isless than zero
Model sign
Parameters
x
=-
2End Parameters
Variables
y
>=-
1, <= 1s_a >= 0
s_b
>= 0End Variables
Equations
sign
operator,y
=sign
(x
)x
=s_b - s_a
minimize s_a*(1+y) + s_b*(1-y)
End Equations
End Model
!SIGN function MPEC
asan Object
Objects
f
=sign
End Objects
Connections
f.
x =x
f.
y =y
End Connections
Parameters
x
=-
2End Parameters
Variables
y
End Variables
GEKKO SIGNUM function (sign2)
See GEKKO Documentation for additional examples.
from gekko import GEKKO
m = GEKKO()
x = m.Param(-2)
# use sign2 to define a new variable
y = m.sign2(x)
m.solve() # solve
print('x: ' + str(x.value))
print('y: ' + str(y.value))
MPEC formulation
forABS function
y
=ABS
(x
)returns a value y
,where:
y
=x
ifthe corresponding element of X
is >than zero
y
=-x
ifthe corresponding element of X
is <than zero
Parameters
x
=-
2End Parameters
Variables
y
s_a >= 0
s_b
>= 0End Variables
Equations
y
= abs(x
)x
=s_b - s_a
y
=s_a + s_b
minimize s_a*s_b
End Equations
!ABS function MPEC
asan Object
Objects
f
= absEnd Objects
Connections
f.
x =x
f.
y =y
End Connections
Parameters
x
=-
2End Parameters
Variables
y
End Variables
GEKKO ABS function (abs2)
See GEKKO Documentation for additional examples.
from gekko import GEKKO
m = GEKKO()
x = m.Param(-2)
# use abs2 to define a new variable
y = m.abs2(x)
# use abs2 in an equation
z = m.Var()
m.Equation(z==m.abs2(x)+1)
m.solve() # solve
print('x: ' + str(x.value))
print('y: ' + str(y.value))
print('z: ' + str(z.value))
MPEC formulation
forMIN function
y
=MIN
(x1
,x2
)returns a value y
,where:
y
=x1
ifx1
<x2
y
=x2
ifx2
<x1
Model
Parameters
x1
=-
2x2
=-
1End Parameters
Variables
y
! slack variables
s_a
>= 0s_b
>= 0End Variables
Equations
y
= min(x1
,x2
)x2 - x1
=s_b - s_a
y
=x1 - s_a
minimize s_a*s_b
End Equations
End Model
!MIN function MPEC
asan Object
Objects
f
= minEnd Objects
Connections
f.
x[1] =x1
f.
x[2] =x2
f.
y =y
End Connections
Parameters
x1
=-
2x2
=-
1End Parameters
Variables
y
End Variables
GEKKO MIN function (min2)
See GEKKO Documentation for additional examples.
from gekko import GEKKO
m = GEKKO()
x1 = m.Param(-2)
x2 = m.Param(-1)
# use min2
y = m.min2(x1,x2)
m.solve() # solve
print('x1: ' + str(x1.value))
print('x2: ' + str(x2.value))
print('y: ' + str(y.value))
MPEC formulation
forMAX function
y
=MAX
(x1
,x2
)returns a value y
,where:
y
=x1
ifx1
>x2
y
=x2
ifx2
>x1
Model
Parameters
x1
=-
2x2
= 4End Parameters
Variables
y
! slack variables
s_a
>= 0s_b
>= 0End Variables
Equations
y
= max(x1
,x2
)x2 - x1
=s_a - s_b
y
=x1 + s_a
minimize s_a*s_b
End Equations
End Model
!MAX function MPEC
asan Object
Objects
f
= maxEnd Objects
Connections
f.
x[1] =x1
f.
x[2] =x2
f.
y =y
End Connections
Parameters
x1
=-
2x2
= 4End Parameters
Variables
y
End Variables
GEKKO MAX function (min2)
See GEKKO Documentation for additional examples.
from gekko import GEKKO
m = GEKKO()
x1 = m.Param(-2)
x2 = m.Param(-1)
# use max2
y = m.max2(x1,x2)
m.solve() # solve
print('x1: ' + str(x1.value))
print('x2: ' + str(x2.value))
print('y: ' + str(y.value))
Mojica, J.L., Petersen, D.J., Hansen, B., Powell, K.M., Hedengren, J.D., Optimal Combined Long-Term Facility Design and Short-Term Operational Strategy for CHP Capacity Investments, Energy, Vol 118, 1 January 2017, pp. 97–115. Article
RetroSearch is an open source project built by @garambo | Open a GitHub Issue
Search and Browse the WWW like it's 1997 | Search results from DuckDuckGo
HTML:
3.2
| Encoding:
UTF-8
| Version:
0.7.4