-
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
maxtime_cpu is not respected #295
Comments
Use: minlp_solver = JuMP.optimizer_with_attributes(KNITRO.Optimizer, MOI.TimeLimitSec() => 30) We don't do anything special with parameters, so this might depend on the version of KNITRO that you have installed. |
Thank you for the prompt response, Oscar! I included the time limit via MOI as you suggested. Here is the code I use now:
However, it seems the 30-second time limit is not taken by the solver. I include the solver log below. And here is my versions information: Knitro: 13.0.1, KNITRO.jl: v0.11.1, JuMP.jl: v0.22.3, PowerModels.jl: v 0.19.10. Operating system: macOS Sonoma with M1 chip.
|
Interesting. It's useful to have an example that fails. This looks like an issue in the upstream KNITRO solver, because all we do here is pass the options. I'll take a look |
Wait. The most recent version of KNITRO.jl is v0.14.2. Can you try updating??? |
Ah. I can't test this locally because I only have a limited size license I think this is just a bug in KNITRO julia> model = KNITRO.Optimizer();
##### This license is only intended for use by JuMP dev. #####
##### License is valid until Dec 31, 2024 #####
julia> p = Ref{Cint}(0)
Base.RefValue{Int32}(0)
julia> KN_get_param_id(model.inner, "maxtime_cpu", p)
-521
julia> p
Base.RefValue{Int32}(0)
julia> KN_get_param_id(model.inner, "maxtimecpu", p)
0
julia> p
Base.RefValue{Int32}(1024)
julia> KN_set_double_param_by_name(model.inner, "maxtime_cpu", 30.0)
0
julia> KN_set_double_param_by_name(model.inner, "maxtimecpu", 30.0)
-516
|
Thank you, Oscar! Is there a way to fix this bug in KNITRO.jl source code? |
Can you try using JuMP, KNITRO, PowerModels
minlp_solver = JuMP.optimizer_with_attributes(KNITRO.Optimizer, MOI.TimeLimitSec() => 30.0)
solve_ots("pglib_opf_case24_ieee_rts__sad.m", ACPPowerModel, minlp_solver) |
It seems the time limit is still not taken, after using the most updated KNITRO.jl version. After updating, I am now using the following packages: KNITRO.jl: v0.14.2, JuMP.jl: v1.22.2, PowerModels.jl: v0.21.2. I ran the following code (I reduced the time limit to 15 seconds):
And here is the solver log, which does not seem to indicate that the time limit is taken:
|
What about: using JuMP, KNITRO, PowerModels
minlp_solver = JuMP.optimizer_with_attributes(KNITRO.Optimizer, "maxtime_real" => 15.0) We should probably contact Artelys support about this. |
Can you check that any options work? julia> using JuMP, KNITRO, PowerModels
julia> minlp_solver = JuMP.optimizer_with_attributes(KNITRO.Optimizer, "outlev" => 0)
MathOptInterface.OptimizerWithAttributes(KNITRO.Optimizer, Pair{MathOptInterface.AbstractOptimizerAttribute, Any}[MathOptInterface.RawOptimizerAttribute("outlev") => 0])
julia> solve_ots("pglib_opf_case14_ieee__api.m", ACPPowerModel, minlp_solver)
[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 5: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]
##### This license is only intended for use by JuMP dev. #####
##### License is valid until Dec 31, 2024 #####
##### This license is only intended for use by JuMP dev. #####
##### License is valid until Dec 31, 2024 #####
Dict{String, Any} with 8 entries:
"solve_time" => 0.000871
"optimizer" => "Knitro"
"termination_status" => INTERRUPTED
"dual_status" => UNKNOWN_RESULT_STATUS
"primal_status" => UNKNOWN_RESULT_STATUS
"objective" => 0.0
"solution" => Dict{String, Any}("baseMVA"=>100.0, "branch"=>Dict{String, Any}("4"=>Dict{…
"objective_lb" => -1.79769e308 |
The For
And here is the log. The
|
To clarify: this appears to be a problem with the upstream solver and not with KNITRO.jl. We don't do anything other than pass options straight through. |
MathOptInterface.UnsupportedAttribute
Error when using maxtime_cpu
I'm a member of Knitro development team, do not hesitate to contact us at |
Thank you very much for the follow up. I tried both options, and for both of them, I encountered the error
then I will get the error:
And the same for |
@Bougron, there does seem to be an issue with the C API: When getting the param ID, it requires julia> using KNITRO
julia> model = KNITRO.Optimizer();
##### This license is only intended for use by JuMP dev. #####
##### License is valid until Dec 31, 2024 #####
julia> kc = model.inner;
julia> param_id = Ref{Cint}(0);
julia> KN_get_param_id(kc, "mip_maxtime_cpu", param_id)
-521
julia> param_id
Base.RefValue{Int32}(0)
julia> KN_get_param_id(kc, "mip_maxtimecpu", param_id)
0
julia> param_id
Base.RefValue{Int32}(2006)
julia> KN_set_double_param_by_name(kc, "mip_maxtime_cpu", 3.0)
0
julia> KN_set_double_param_by_name(kc, "mip_maxtimecpu", 3.0)
-516 #297 works around this by using only the id version, so once merged, |
Using #297, I get: julia> using JuMP, KNITRO, PowerModels
julia> minlp_solver = JuMP.optimizer_with_attributes(KNITRO.Optimizer, "mip_maxtimereal" => 0.0)
MathOptInterface.OptimizerWithAttributes(KNITRO.Optimizer, Pair{MathOptInterface.AbstractOptimizerAttribute, Any}[MathOptInterface.RawOptimizerAttribute("mip_maxtimereal") => 0.0])
julia> solve_ots("pglib_opf_case14_ieee__api.m", ACPPowerModel, minlp_solver)
[info | PowerModels]: removing 3 cost terms from generator 4: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 1: [792.0951, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 5: Float64[]
[info | PowerModels]: removing 1 cost terms from generator 2: [2326.9494, 0.0]
[info | PowerModels]: removing 3 cost terms from generator 3: Float64[]
##### This license is only intended for use by JuMP dev. #####
##### License is valid until Dec 31, 2024 #####
##### This license is only intended for use by JuMP dev. #####
##### License is valid until Dec 31, 2024 #####
=======================================
Student License
(NOT FOR COMMERCIAL USE)
Artelys Knitro 13.1.0
=======================================
WARNING: Problem appears to have nonlinear equalities and be non-convex.
The Knitro mixed integer solver is designed for convex problems.
For non-convex problems it is only a heuristic, and the reported
bounds and optimality claims cannot be verified.
datacheck: 0
hessian_no_f: 1
numthreads: 1
mip_maxtime_real: 0
mip_numthreads: 1
Knitro changing mip_method from AUTO to 1.
Knitro changing mip_rootalg from AUTO to 1.
Knitro changing mip_lpalg from AUTO to 3.
Knitro changing mip_branchrule from AUTO to 2.
Knitro changing mip_selectrule from AUTO to 2.
Knitro changing mip_mir from AUTO to 1.
Knitro changing mip_rounding from AUTO to 3.
Knitro changing mip_heuristic_strategy from AUTO to 1.
Knitro changing mip_heuristic_feaspump from AUTO to 1.
Knitro changing mip_heuristic_misqp from AUTO to 0.
Knitro changing mip_heuristic_mpec from AUTO to 1.
Knitro changing mip_heuristic_diving from AUTO to 0.
Knitro changing mip_heuristic_lns from AUTO to 0.
Knitro changing mip_pseudoinit from AUTO to 1.
Problem Characteristics
-----------------------
Objective goal: Minimize
Objective type: linear
Number of variables: 138
bounded below only: 0
bounded above only: 0
bounded below and above: 121
fixed: 3
free: 14
Number of binary variables: 20
Number of integer variables: 0
Number of constraints: 189
linear equalities: 28
quadratic equalities: 1
gen. nonlinear equalities: 80
linear one-sided inequalities: 0
quadratic one-sided inequalities: 80
gen. nonlinear one-sided inequalities: 0
linear two-sided inequalities: 0
quadratic two-sided inequalities: 0
gen. nonlinear two-sided inequalities: 0
Number of nonzeros in Jacobian: 812
Number of nonzeros in Hessian: 302
Knitro detected 0 GUB constraints
Knitro derived 0 knapsack covers after examining 0 constraints
Knitro using Branch and Bound method with 1 thread.
Nodes Best solution Best bound Gap Time
Expl | Unexpl value value (secs)
--------------- ------------- ---------- --- ------
EXIT: Time limit reached. No integer feasible point found.
HINT: The problem may be a non-convex mixed-integer problem. Set
mip_multistart=1 to enable a mixed-integer multistart heuristic,
which may improve the chances of finding the global solution.
Final Statistics for MIP
------------------------
Final objective value =
Final bound value = 0.00000000000000e+00
Final optimality gap (abs / rel) = Infinity
# of nodes processed = 0 (0.000s)
# of strong branching evaluations = 0 (0.000s)
# of function evaluations = 2 (0.000s)
# of gradient evaluations = 1 (0.000s)
# of hessian evaluations = 0 (0.000s)
# of hessian-vector evaluations = 0
# of subproblems processed = 0 (0.000s)
Total program time (secs) = 0.00067 (0.001 CPU time)
Time spent in evaluations (secs) = 0.00016
Cuts statistics (computed / added)
----------------------------------
Knapsack cuts = 0 / 0
Mixed-Integer Rounding cuts = 0 / 0
Heuristics statistics (calls / successes / time)
------------------------------------------------
Feasibility pump = 0 / 0 / 0.000s
Rounding heuristic = 0 / 0 / 0.000s
MPEC heuristic = 0 / 0 / 0.000s
===========================================================================
Dict{String, Any} with 8 entries:
"solve_time" => 0.00072
"optimizer" => "Knitro"
"termination_status" => TIME_LIMIT
"dual_status" => INFEASIBLE_POINT
"primal_status" => INFEASIBLE_POINT
"objective" => 0.0
"solution" => Dict{String, Any}("baseMVA"=>100.0, "branch"=>Dict{String, Any}("4"=>Dict{…
"objective_lb" => 0.0 so it is working. @Bougron, as a secondary request then, shouldn't |
Yes this is expected (even though I understand it is confusing), the documentation mentions it in the description: |
Regarding the naming, we are checking it out (mip_maxtimecpu vs mip_maxtime_cpu). |
Ah, then perhaps all that is needed is that for the documentation of I see that other options have this wording, but it is missing from the |
This will be fixed when I release #301 |
This bug is similar to the one mentioned here: https://discourse.julialang.org/t/julia-with-knitro/81686.
A MWE is as follows:
The data file
pglib_opf_case24_ieee_rts__sad.m
is attached below (drop the extension.txt
before running).The code runs fine if one does not set the
maxtime_cpu
parameter in attributes, so it seems to be an issue with KNITRO.jl/MOI not being able to talk the parameter.pglib_opf_case24_ieee_rts__sad.m.txt
The text was updated successfully, but these errors were encountered: