Gekko optimiert mit APOPT nicht eine einzelne lineare Gleichung, die als PWL dargestellt wirdPython

Python-Programme
Guest
 Gekko optimiert mit APOPT nicht eine einzelne lineare Gleichung, die als PWL dargestellt wird

Post by Guest »

Ich bin auf ein Problem gestoßen, bei dem ich APOPT nicht dazu bringen kann, eine unbeschränkte einzelne stückweise lineare Optimierung zu optimieren, und das bringt mich wirklich aus der Fassung. Ich habe das Gefühl, dass ich etwas an model.pwl nicht verstehe, aber es ist (für mich) schwierig, Dokumentation außerhalb der GEKKO-Dokumente zu finden. Hier ist mein Minimalbeispiel:

Code: Select all

model = GEKKO(remote=False)
model.options.SOLVER = 1
model.solver_options = ["minlp_as_nlp 0"]

x = model.sos1([0, 1, 2, 3, 4]) # This can also be model.Var(lb=0, ub=4), same result.
pwl = model.Var()

model.pwl(x, pwl, [0, 1, 2, 3, 4], [30, 30.1, 30.2, 30.3, 30.4], bound_x=True)

model.Minimize(pwl)

model.solve(display=True)

print(x.value)
print(pwl.value)
print(model.options.objfcnval)
Die Ausgabe, die ich erhalte, ist:

Code: Select all

 ----------------------------------------------------------------
APMonitor, Version 1.0.3
APMonitor Optimization Suite
----------------------------------------------------------------

--------- APM Model Size ------------
Each time step contains
Objects      :            1
Constants    :            0
Variables    :            2
Intermediates:            0
Connections  :            2
Equations    :            1
Residuals    :            1

Piece-wise linear model pwl1points:            5
Number of state variables:             12
Number of total equations: -            5
Number of slack variables: -            0
---------------------------------------
Degrees of freedom       :              7

----------------------------------------------
Steady State Optimization with APOPT Solver
----------------------------------------------

Iter    Objective  Convergence
0  3.39503E+01  3.01000E+01
1  3.22900E+01  1.00000E-10
2  3.22000E+01  2.22045E-16
4  3.22000E+01  0.00000E+00
Successful solution

---------------------------------------------------
Solver         :  APOPT (v1.0)
Solution time  :   3.819999999541324E-002 sec
Objective      :    32.2000000000000
Successful solution
---------------------------------------------------

2.0
30.2
32.2
Das ist für mich unerwartet, da der offensichtliche Mindestwert 30 für die pwl ist.

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post