Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Setting integer=True does not seem to work #134

Open
jxmorris12 opened this issue Dec 7, 2021 · 2 comments
Open

Setting integer=True does not seem to work #134

jxmorris12 opened this issue Dec 7, 2021 · 2 comments
Assignees
Labels
enhancement New feature or request

Comments

@jxmorris12
Copy link

I'm trying a simple example to test out GEKKO. I'm providing the keyword argument integer=True to initialize an array of variables, yet the solution found doesn't ensure that they're integers. What am I doing wrong?

from gekko import GEKKO
m = GEKKO()

x = m.Array(m.Var, 7, value=0, lb=0, ub=1, integer=True)
m.Equation(sum(x) <= 2)

print(f'Maximizing sum({x})')
m.Maximize(sum(x))

m.solve(disp=False, debug=True)
print(x)
> Maximizing sum([0 0 0 0 0 0 0])
> [[0.28571426403] [0.28571426403] [0.28571426403] [0.28571426403]
 [0.28571426403] [0.28571426403] [0.28571426403]]
@jxmorris12
Copy link
Author

Figured out how to enable mixed-integer optimization by changing the solver- just added the following line:

m.options.SOLVER=1

this wasn't very intuitive. Maybe you could throw an error if someone specifies integer=True but tries to use a solver that doesn't support mixed integer.

@APMonitor APMonitor added the enhancement New feature or request label Dec 10, 2021
@APMonitor APMonitor self-assigned this Dec 10, 2021
@APMonitor
Copy link
Member

Great suggestion! I've added it as an upcoming feature request.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
enhancement New feature or request
Projects
None yet
Development

No branches or pull requests

2 participants