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

Objective value is higher when integers are used #46

Closed
willigott opened this issue Dec 2, 2018 · 2 comments
Closed

Objective value is higher when integers are used #46

willigott opened this issue Dec 2, 2018 · 2 comments

Comments

@willigott
Copy link

I ran this example 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?

@abe-mart
Copy link
Contributor

abe-mart commented Dec 2, 2018 via email

@willigott
Copy link
Author

Ooops, of course, stupid me. Thanks for the immediate reply!

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

No branches or pull requests

2 participants