-
Notifications
You must be signed in to change notification settings - Fork 23
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
Fix updating NLPBlock after solve #236
Merged
Merged
Conversation
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Codecov Report
@@ Coverage Diff @@
## master #236 +/- ##
==========================================
- Coverage 71.28% 71.26% -0.03%
==========================================
Files 12 12
Lines 1919 1921 +2
==========================================
+ Hits 1368 1369 +1
- Misses 551 552 +1
Help us with your feedback. Take ten seconds to tell us how you rate us. Have a feature suggestion? Share it here. |
With this PR I get: julia> using JuMP
julia> using KNITRO
julia> # small test problem
model = JuMP.Model(
optimizer_with_attributes(
KNITRO.Optimizer,
"honorbnds" => 1,
),
)
##### This license is only intended for use by JuMP-dev team. #####
##### License is valid until Aug 31, 2023 #####
A JuMP Model
Feasibility problem with:
Variables: 0
Model mode: AUTOMATIC
CachingOptimizer state: EMPTY_OPTIMIZER
Solver name: Knitro
julia> @variable(model, 0 <= x[1:5] <= 10)
5-element Vector{VariableRef}:
x[1]
x[2]
x[3]
x[4]
x[5]
julia> @constraint(model, sum(x) == 10)
x[1] + x[2] + x[3] + x[4] + x[5] = 10.0
julia> epsilon = @NLparameter(model, epsilon==1)
epsilon == 1.0
julia> @NLconstraint(model, x[1] + exp(x[2]*epsilon) <= 10)
(x[1] + exp(x[2] * epsilon)) - 10.0 ≤ 0
julia> @NLconstraint(model, x[2] + exp(x[3]*epsilon) <= 5)
(x[2] + exp(x[3] * epsilon)) - 5.0 ≤ 0
julia> @objective(model, Max, x[2])
x[2]
julia> # solve with first parameter
set_value(epsilon, 1e-1) # okay
0.1
julia> optimize!(model)
##### This license is only intended for use by JuMP-dev team. #####
##### License is valid until Aug 31, 2023 #####
=======================================
Student License
(NOT FOR COMMERCIAL USE)
Artelys Knitro 13.1.0
=======================================
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables and 0 constraints.
datacheck: 0
hessian_no_f: 1
honorbnds: 1
numthreads: 1
Problem Characteristics ( Presolved)
-----------------------
Objective goal: Maximize
Objective type: linear
Number of variables: 5 ( 5)
bounded below only: 0 ( 0)
bounded above only: 0 ( 0)
bounded below and above: 5 ( 5)
fixed: 0 ( 0)
free: 0 ( 0)
Number of constraints: 3 ( 3)
linear equalities: 1 ( 1)
quadratic equalities: 0 ( 0)
gen. nonlinear equalities: 0 ( 0)
linear one-sided inequalities: 0 ( 0)
quadratic one-sided inequalities: 0 ( 0)
gen. nonlinear one-sided inequalities: 2 ( 2)
linear two-sided inequalities: 0 ( 0)
quadratic two-sided inequalities: 0 ( 0)
gen. nonlinear two-sided inequalities: 0 ( 0)
Number of nonzeros in Jacobian: 9 ( 9)
Number of nonzeros in Hessian: 2 ( 2)
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| CGits
-------- -------------- ---------- ---------- ---------- -------
0 4.628316e+00 1.321e+01
4 4.000000e+00 3.907e-08 3.907e-08 1.267e-03 0
EXIT: Locally optimal solution found.
Final Statistics
----------------
Final objective value = 4.00000001980378e+00
Final feasibility error (abs / rel) = 3.91e-08 / 2.96e-09
Final optimality error (abs / rel) = 3.91e-08 / 3.91e-08
# of iterations = 4
# of CG iterations = 0
# of function evaluations = 6
# of gradient evaluations = 6
# of Hessian evaluations = 4
Total program time (secs) = 1.57684 ( 1.574 CPU time)
Time spent in evaluations (secs) = 0.82033
===============================================================================
julia> # solve with second parameter
set_value(epsilon, 1e-2) # error :(
0.01
julia> optimize!(model)
##### This license is only intended for use by JuMP-dev team. #####
##### License is valid until Aug 31, 2023 #####
##### This license is only intended for use by JuMP-dev team. #####
##### License is valid until Aug 31, 2023 #####
=======================================
Student License
(NOT FOR COMMERCIAL USE)
Artelys Knitro 13.1.0
=======================================
No start point provided -- Knitro computing one.
Knitro presolve eliminated 0 variables and 0 constraints.
datacheck: 0
hessian_no_f: 1
honorbnds: 1
numthreads: 1
Problem Characteristics ( Presolved)
-----------------------
Objective goal: Maximize
Objective type: linear
Number of variables: 5 ( 5)
bounded below only: 0 ( 0)
bounded above only: 0 ( 0)
bounded below and above: 5 ( 5)
fixed: 0 ( 0)
free: 0 ( 0)
Number of constraints: 3 ( 3)
linear equalities: 1 ( 1)
quadratic equalities: 0 ( 0)
gen. nonlinear equalities: 0 ( 0)
linear one-sided inequalities: 0 ( 0)
quadratic one-sided inequalities: 0 ( 0)
gen. nonlinear one-sided inequalities: 2 ( 2)
linear two-sided inequalities: 0 ( 0)
quadratic two-sided inequalities: 0 ( 0)
gen. nonlinear two-sided inequalities: 0 ( 0)
Number of nonzeros in Jacobian: 9 ( 9)
Number of nonzeros in Hessian: 2 ( 2)
Knitro using the Interior-Point/Barrier Direct algorithm.
Iter Objective FeasError OptError ||Step|| CGits
-------- -------------- ---------- ---------- ---------- -------
0 4.628316e+00 1.321e+01
4 4.000000e+00 2.217e-09 2.217e-09 4.859e-03 0
EXIT: Locally optimal solution found.
Final Statistics
----------------
Final objective value = 4.00000000054325e+00
Final feasibility error (abs / rel) = 2.22e-09 / 1.68e-10
Final optimality error (abs / rel) = 2.22e-09 / 2.22e-09
# of iterations = 4
# of CG iterations = 0
# of function evaluations = 6
# of gradient evaluations = 6
# of Hessian evaluations = 4
Total program time (secs) = 0.00249 ( 0.002 CPU time)
Time spent in evaluations (secs) = 0.00009
=============================================================================== |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Closes #204