I am trying to work on an optimization problem using python and I started working on GEKKO since it solves nonlinear programs. I have written a simple model in LINGO to check the answer which didn't have the same value as the answer I got from GEKKO (same model).
Python Code:-
from gekko import GEKKO
# Initialize Model
smplmdl = GEKKO()
# Create Variables
x = smplmdl.Array(smplmdl.Var, 3, lb = 0)
a = smplmdl.Array(smplmdl.Var, 3, lb = 0)
Constant_Val = [10, 15, 20]
for i in range(3):
smplmdl.Equation(x[i]*(sum(a[j] for j in range(3))) == Constant_Val[i])
# Objective Function
smplmdl.Obj(sum(x[i] for i in range(3)))
smplmdl.options.IMODE = 3
smplmdl.solve()
smplmdl.options.OBJFCNVAL
print('x:', x)
print('a:', a)
print(smplmdl.options.OBJFCNVAL)
LINGO Code:-
Min = x1 + x2 + x3;
x1*(a1 + a2 + a3) = 10;
x2*(a1 + a2 + a3) = 15;
x3*(a1 + a2 + a3) = 20;