jump-dev / KNITRO.jl

A Julia interface to the Artelys Knitro solver
https://www.artelys.com/knitro
Other
78 stars 23 forks source link

Fix setting MOI.TimeLimitSec properly #300

Closed odow closed 2 months ago

odow commented 2 months ago

Fix #299 properly this time.

The issue was that the TimeLimitSec was not being re-set on MOI.empty!.

Now I get:

julia> using JuMP, KNITRO, PowerModels

julia> minlp_solver = JuMP.optimizer_with_attributes(KNITRO.Optimizer, MOI.TimeLimitSec() => 0.0)
MathOptInterface.OptimizerWithAttributes(KNITRO.Optimizer, Pair{MathOptInterface.AbstractOptimizerAttribute, Any}[MathOptInterface.TimeLimitSec() => 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
maxtime_real:            0
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.012s)
# of gradient evaluations           =  1 (0.048s)
# of hessian evaluations            =  0 (0.000s)
# of hessian-vector evaluations     =  0
# of subproblems processed          =  0 (0.000s)
Total program time (secs)           =  0.07092 (0.061 CPU time)
Time spent in evaluations (secs)    =  0.05981

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.06144
  "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
codecov[bot] commented 2 months ago

Codecov Report

All modified and coverable lines are covered by tests :white_check_mark:

Project coverage is 85.25%. Comparing base (9f9a7e6) to head (000553c).

Additional details and impacted files ```diff @@ Coverage Diff @@ ## master #300 +/- ## ========================================== - Coverage 85.27% 85.25% -0.02% ========================================== Files 3 3 Lines 1005 1004 -1 ========================================== - Hits 857 856 -1 Misses 148 148 ```

:umbrella: View full report in Codecov by Sentry.
:loudspeaker: Have feedback on the report? Share it here.