APOPT Doesn't return lowest obj

123 views
Skip to first unread message

Mathias Sven

unread,
Aug 30, 2021, 2:14:51 PM8/30/21
to apmonitor
Hello,

I am fairly new to Gekko and I was wondering if I have something misconfigured with my Mix-integer optimization problem. So basically the issue I am having is that during iterations one of the first few solutions is actually the best but the solver still gives a worse one as a solution, I can't exactly figure out why. Another thing I notice is that if I take obj function formula and divide it by 100 per se (so it is smaller), then the solution I get is actually better (Once I multiply the output by 100 again).

...
m.options.SOLVER = 1
m.solver_options = ['minlp_gap_tol 1.0e-200']
...
m.Maximize((..."formula to maximize"...) / 1)
m.solve(disp=True)

Output:
Iter:     1 I:  0 Tm:      0.00 NLPi:    4 Dpth:    0 Lvs:    3 Obj: -1.05E+06 Gap:       NaN
--Integer Solution:  -1.04E+06 Lowest Leaf:  -1.05E+06 Gap:   9.67E-03
Iter:     2 I:  0 Tm:     -0.00 NLPi:    2 Dpth:    1 Lvs:    2 Obj: -1.04E+06 Gap:  9.67E-03
Iter:     3 I:  0 Tm:      0.00 NLPi:    4 Dpth:    1 Lvs:    4 Obj: -1.06E+06 Gap:  9.67E-03
--Integer Solution:  -1.05E+06 Lowest Leaf:  -1.06E+06 Gap:   4.78E-03
Iter:     4 I:  0 Tm:      0.00 NLPi:    2 Dpth:    2 Lvs:    3 Obj: -1.05E+06 Gap:  4.78E-03
Iter:     5 I:  0 Tm:      0.00 NLPi:    3 Dpth:    2 Lvs:    5 Obj: -1.05E+06 Gap:  4.78E-03
Iter:     6 I:  0 Tm:      0.00 NLPi:    3 Dpth:    2 Lvs:    7 Obj: -1.05E+06 Gap:  4.78E-03
--Integer Solution:  -1.05E+06 Lowest Leaf:  -1.05E+06 Gap:   3.71E-03
Iter:     7 I:  0 Tm:     -0.00 NLPi:    2 Dpth:    3 Lvs:    6 Obj: -1.05E+06 Gap:  3.71E-03
...
Iter:    47 I:-11 Tm:      0.00 NLPi:    2 Dpth:   13 Lvs:    3 Obj: -1.05E+06 Gap:  7.28E-04
Iter:    48 I:  0 Tm:      0.00 NLPi:    3 Dpth:   12 Lvs:    2 Obj: -1.05E+06 Gap:  7.28E-04
Iter:    49 I:  0 Tm:      0.00 NLPi:    3 Dpth:   12 Lvs:    1 Obj: -8.79E+05 Gap:  7.28E-04
 No additional trial points, returning the best integer solution
 Successful solution

Objective      :  -1050396.901745295

So as you can see Iter 3 should have been the solution.
Then if instead of m.Maximize((..."formula to maximize"...) / 1) I do
m.Maximize((..."formula to maximize"...) / 1000) instead, then the obj final becomes -1061.394773200687 which once multiplied by 1000 gives the correct "best solution" (I believe) to the original question.

Does anyone have any insight as for why this could be happening?

Thank you,

Mathias Sven

John Hedengren

unread,
Aug 30, 2021, 2:31:31 PM8/30/21
to apmo...@googlegroups.com

Mathias,

 

The Lowest Leaf is not a potential solution. It is the lowest non-integer solution and serves as a lower bound to the mixed-integer solution. The difference between the best integer solution and lowest leaf is used to calculate the Gap.

 

Output:

Iter:     1 I:  0 Tm:      0.00 NLPi:    4 Dpth:    0 Lvs:    3 Obj: -1.05E+06 Gap:       NaN

--Integer Solution:  -1.04E+06 Lowest Leaf:  -1.05E+06 Gap:   9.67E-03

Iter:     2 I:  0 Tm:     -0.00 NLPi:    2 Dpth:    1 Lvs:    2 Obj: -1.04E+06 Gap:  9.67E-03

Iter:     3 I:  0 Tm:      0.00 NLPi:    4 Dpth:    1 Lvs:    4 Obj: -1.06E+06 Gap:  9.67E-03

--Integer Solution:  -1.05E+06 Lowest Leaf:  -1.06E+06 Gap:   4.78E-03

Iter:     4 I:  0 Tm:      0.00 NLPi:    2 Dpth:    2 Lvs:    3 Obj: -1.05E+06 Gap:  4.78E-03

Iter:     5 I:  0 Tm:      0.00 NLPi:    3 Dpth:    2 Lvs:    5 Obj: -1.05E+06 Gap:  4.78E-03

Iter:     6 I:  0 Tm:      0.00 NLPi:    3 Dpth:    2 Lvs:    7 Obj: -1.05E+06 Gap:  4.78E-03

--Integer Solution:  -1.05E+06 Lowest Leaf:  -1.05E+06 Gap:   3.71E-03

Iter:     7 I:  0 Tm:     -0.00 NLPi:    2 Dpth:    3 Lvs:    6 Obj: -1.05E+06 Gap:  3.71E-03

...

Iter:    47 I:-11 Tm:      0.00 NLPi:    2 Dpth:   13 Lvs:    3 Obj: -1.05E+06 Gap:  7.28E-04

Iter:    48 I:  0 Tm:      0.00 NLPi:    3 Dpth:   12 Lvs:    2 Obj: -1.05E+06 Gap:  7.28E-04

Iter:    49 I:  0 Tm:      0.00 NLPi:    3 Dpth:   12 Lvs:    1 Obj: -8.79E+05 Gap:  7.28E-04

 No additional trial points, returning the best integer solution

 Successful solution

 

Objective      :  -1050396.901745295

 

Does the objective scaling help the solver find a better solution? That is also possible, but it is difficult to confirm without the source code for the problem. Please consider posting the source to StackOverflow with tag [gekko].

 

Thanks,

John Hedengren

--
--
APMonitor user's group e-mail list.
- To post a message, send email to apmo...@googlegroups.com
- To unsubscribe, send email to apmonitor+...@googlegroups.com
- Visit this group at http://groups.google.com/group/apmonitor
---
You received this message because you are subscribed to the Google Groups "apmonitor" group.
To unsubscribe from this group and stop receiving emails from it, send an email to apmonitor+...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/apmonitor/fba60aac-9cc4-4398-b52a-27bcdcc1c296n%40googlegroups.com.

Reply all
Reply to author
Forward
0 new messages