Код: Выделить всё
m.options.IMODE = 3
m.options.SOLVER = 1
Код: Выделить всё
from gekko import GEKKO
m = GEKKO(remote=False)
# Define objective
def obj(x1, x2):
return x1*0.04824647331436083 + x2*0.1359023029124411 + x1*x2*(0.5659570743890336)
# Define variables
x1 = m.Var(lb=-0.7280376309420935, ub=0.2719623690579065)
x2 = m.Var(lb=-0.8912733608888134, ub=0.10872663911118663)
u = m.Intermediate(obj(x1,x2))
m.Maximize(u)
# Solve the problem
m.options.SOLVER = 'APOPT'
m.solve(disp=False)
# Print the results
print(f'x1: {x1.value[0]}')
print(f'x2: {x2.value[0]}')
print(f'u: {u.value[0]}')
Код: Выделить всё
x1: 0.27196236906
x2: 0.10872663911
u: 0.044632524297
Код: Выделить всё
x1 = -0.7124939186992643
x2 = -0.7378666097932151
obj(x1, x2)
Подробнее здесь: https://stackoverflow.com/questions/785 ... rong-point