我对APOPT如何解决MINLP有一些疑问。
答案 0 :(得分:3)
APOPT是使用分支和约束的活动集顺序二次规划(SQP)求解器。 APOPT使用热启动方法来加快连续的非线性编程(NLP)解决方案的速度。 Wikipedia,APMonitor documentation和APOPT.com中有关于APOPT的更多信息。从2013 INFORMS演示文稿和2014 APMonitor CACE论文中可以获得基准信息。
以下是使用pip install gekko
打包后用Python Gekko解决的一个示例MINLP问题。
from gekko import GEKKO
m = GEKKO() # Initialize gekko
m.options.SOLVER=1 # APOPT is an MINLP solver
# optional solver settings with APOPT
m.solver_options = ['minlp_maximum_iterations 500', \
# minlp iterations with integer solution
'minlp_max_iter_with_int_sol 10', \
# treat minlp as nlp
'minlp_as_nlp 0', \
# nlp sub-problem max iterations
'nlp_maximum_iterations 50', \
# 1 = depth first, 2 = breadth first
'minlp_branch_method 1', \
# maximum deviation from whole number
'minlp_integer_tol 0.05', \
# covergence tolerance
'minlp_gap_tol 0.01']
# Initialize variables
x1 = m.Var(value=1,lb=1,ub=5)
x2 = m.Var(value=5,lb=1,ub=5)
# Integer constraints for x3 and x4
x3 = m.Var(value=5,lb=1,ub=5,integer=True)
x4 = m.Var(value=1,lb=1,ub=5,integer=True)
m.Equation(x1*x2*x3*x4>=25)
m.Equation(x1**2+x2**2+x3**2+x4**2==40)
m.Obj(x1*x4*(x1+x2+x3)+x3) # Objective
m.solve(disp=False) # Solve
print('x1: ' + str(x1.value))
print('x2: ' + str(x2.value))
print('x3: ' + str(x3.value))
print('x4: ' + str(x4.value))
print('Objective: ' + str(m.options.objfcnval))
迭代摘要提供了有关分支和绑定过程以查找解决方案的更多信息。
----------------------------------------------
Steady State Optimization with APOPT Solver
----------------------------------------------
Iter: 1 I: 0 Tm: 0.00 NLPi: 7 Dpth: 0 Lvs: 3 Obj: 1.70E+01 Gap: NaN
--Integer Solution: 1.75E+01 Lowest Leaf: 1.70E+01 Gap: 3.00E-02
Iter: 2 I: 0 Tm: 0.00 NLPi: 5 Dpth: 1 Lvs: 2 Obj: 1.75E+01 Gap: 3.00E-02
Iter: 3 I: 0 Tm: 0.00 NLPi: 6 Dpth: 1 Lvs: 2 Obj: 1.75E+01 Gap: 3.00E-02
--Integer Solution: 1.75E+01 Lowest Leaf: 1.70E+01 Gap: 3.00E-02
Iter: 4 I: 0 Tm: 0.00 NLPi: 6 Dpth: 2 Lvs: 1 Obj: 2.59E+01 Gap: 3.00E-02
Iter: 5 I: 0 Tm: 0.00 NLPi: 5 Dpth: 1 Lvs: 0 Obj: 2.15E+01 Gap: 3.00E-02
No additional trial points, returning the best integer solution
Successful solution
---------------------------------------------------
Solver : APOPT (v1.0)
Solution time : 1.609999999345746E-002 sec
Objective : 17.5322673012512
Successful solution
---------------------------------------------------
x1: [1.3589086474]
x2: [4.5992789966]
x3: [4.0]
x4: [1.0]
Objective: 17.532267301