Closed willigott closed 5 years ago
Gekko actually minimizes the objective function, so constraining the variables to be integers produces a solution that is five times worse than the unconstrained version.
On Sun, Dec 2, 2018, 9:05 AM willigott <notifications@github.com wrote:
I ran this example https://gekko.readthedocs.io/en/latest/examples.html#mixed-integer-nonlinear-programming from the documentation and got the same output:
Solver : APOPT (v1.0) Solution time : 1.639999999315478E-002 sec Objective : 17.5322673012512 Successful solution
Results x1: [1.358909] x2: [4.599279] x3: [4.0] x4: [1.0] Objective: 17.5322673
I then checked how the solution would look like when all xi would be integers, so I changed the definitions for x1 and x2 to
Initialize variables
x1 = m.Var(value=1, lb=1, ub=5, integer=True) x2 = m.Var(value=5, lb=1, ub=5, integer=True)
which then gives
Successful solution
Solver : APOPT (v1.0) Solution time : 0.103800000011688 sec Objective : 82.0000000000000 Successful solution
Results x1: [4.0] x2: [4.0] x3: [2.0] x4: [2.0] Objective: 82.0
As one can see, the constraints are fulfilled, however, the objective value is now almost 5 times higher than before when x1 and x2 were not restricted to be integers.
Why is this solution not picked up when x1 and x2 are not constrained to be integers? Which optimization parameters would I have to fine-tune to avoid this local optimum?
— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/BYU-PRISM/GEKKO/issues/46, or mute the thread https://github.com/notifications/unsubscribe-auth/ASiTodO4PcrawcYSlftEsHQUgVabA7CFks5u0_pDgaJpZM4Y9eAU .
Ooops, of course, stupid me. Thanks for the immediate reply!
I ran this example from the documentation and got the same output:
I then checked how the solution would look like when all
xi
would be integers, so I changed the definitions forx1
andx2
towhich then gives
As one can see, the constraints are fulfilled, however, the objective value is now almost 5 times higher than before when
x1
andx2
were not restricted to be integers.Why is this solution not picked up when
x1
andx2
are not constrained to be integers? Which optimization parameters would I have to fine-tune to avoid this local optimum?