GithubHelp home page GithubHelp logo

jump-dev / highs.jl Goto Github PK

View Code? Open in Web Editor NEW
98.0 9.0 13.0 310 KB

A Julia interface to the HiGHS solver

Home Page: https://highs.dev

License: MIT License

Julia 100.00%
julia linear-programming simplex optimization dual-simplex jump-jl

highs.jl's Introduction

HiGHS.jl

Build Status codecov

HiGHS.jl is a wrapper for the HiGHS solver.

It has two components:

Affiliation

This wrapper is maintained by the JuMP community and is not an official project of the HiGHS developers.

Getting help

If you need help, please ask a question on the JuMP community forum.

If you have a reproducible example of a bug, please open a GitHub issue.

License

HiGHS.jl is licensed under the MIT License.

The underlying solver, ERGO-Code/HiGHS, is licensed under the MIT license.

Installation

Install HiGHS as follows:

import Pkg
Pkg.add("HiGHS")

In addition to installing the HiGHS.jl package, this will also download and install the HiGHS binaries. You do not need to install HiGHS separately.

To use a custom binary, read the Custom solver binaries section of the JuMP documentation.

Use with JuMP

To use HiGHS with JuMP, use HiGHS.Optimizer:

using JuMP, HiGHS
model = Model(HiGHS.Optimizer)
set_attribute(model, "presolve", "on")
set_attribute(model, "time_limit", 60.0)

MathOptInterface API

The HiGHS optimizer supports the following constraints and attributes.

List of supported objective functions:

List of supported variable types:

List of supported constraint types:

List of supported model attributes:

Options

See the HiGHS documentation for a full list of the available options.

C API

The C API can be accessed via HiGHS.Highs_xxx functions, where the names and arguments are identical to the C API.

Threads

HiGHS uses a global scheduler that is shared between threads.

Before changing the number of threads using MOI.Threads(), you must call Highs_resetGlobalScheduler(1):

using JuMP, HiGHS
model = Model(HiGHS.Optimizer)
Highs_resetGlobalScheduler(1)
set_attribute(model, MOI.NumberOfThreads(), 1)

If modifying the number of HiGHS threads across different Julia threads, be sure to read the docstring of Highs_resetGlobalScheduler. In particular, resetting the scheduler is not thread-safe.

highs.jl's People

Contributors

bhalonen avatar blegat avatar galabovaa avatar jd-lara avatar kpamnany avatar matbesancon avatar metab0t avatar mlubin avatar odow avatar sambuddhac avatar timholy avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

highs.jl's Issues

Getting error when retrieving results of optimization

model.zip

With the model attached to this, if I run

julia> m = read_from_file("model.mps")
julia> set_optimizer(m, Cbc.Optimizer)
julia> optimize!(m)
julia> termination_status(m)
julia> objective_value(m)

I get:

OPTIMAL::TerminationStatusCode = 1
5.234147524505995e8

When I do the same with HiGHS (i.e, set_optimizer(m, HiGHS.Optimizer)
I get:

OPTIMAL::TerminationStatusCode = 1

ERROR: Result index of attribute MathOptInterface.ObjectiveValue(1) out of bounds. There are currently 0 solution(s) in the model.
Stacktrace:
 [1] check_result_index_bounds
   @ C:\Users\renau\.julia\packages\MathOptInterface\YDdD3\src\attributes.jl:139 [inlined]
 [2] get
   @ C:\Users\renau\.julia\packages\HiGHS\UdLoV\src\MOI_wrapper.jl:1669 [inlined]
 [3] get(b::MathOptInterface.Bridges.LazyBridgeOptimizer{HiGHS.Optimizer}, attr::MathOptInterface.ObjectiveValue)
   @ MathOptInterface.Bridges C:\Users\renau\.julia\packages\MathOptInterface\YDdD3\src\Bridges\bridge_optimizer.jl:913
 [4] get(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}, attr::MathOptInterface.ObjectiveValue)
   @ MathOptInterface.Utilities C:\Users\renau\.julia\packages\MathOptInterface\YDdD3\src\Utilities\cachingoptimizer.jl:716
 [5] _moi_get_result(model::MathOptInterface.Utilities.CachingOptimizer{MathOptInterface.AbstractOptimizer, MathOptInterface.Utilities.UniversalFallback{MathOptInterface.Utilities.GenericModel{Float64, MathOptInterface.Utilities.ModelFunctionConstraints{Float64}}}}, args::MathOptInterface.ObjectiveValue)
   @ JuMP C:\Users\renau\.julia\packages\JuMP\b3hGi\src\JuMP.jl:1199
 [6] get(model::Model, attr::MathOptInterface.ObjectiveValue)
   @ JuMP C:\Users\renau\.julia\packages\JuMP\b3hGi\src\JuMP.jl:1212
 [7] objective_value(model::Model; result::Int64)
   @ JuMP C:\Users\renau\.julia\packages\JuMP\b3hGi\src\objective.jl:42
 [8] objective_value(model::Model)
   @ JuMP C:\Users\renau\.julia\packages\JuMP\b3hGi\src\objective.jl:42
 [9] top-level scope
   @ REPL[32]:1

The screen output shows that HiGHS found the optimal solution.

Crash when loading problem from JuMP

I noticed the update and gave HiGHS another try with the same test problem as in #65

While the updated version of HiGHS_jll solves the problem without problems, it crashes on me when loading via JuMP:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

(dev-highs) pkg> st
      Status `~/projects/dev-highs/Project.toml`
  [87dc4568] HiGHS v0.3.0 `https://github.com/jump-dev/HiGHS.jl.git#master`
  [4076af6c] JuMP v0.22.0 `https://github.com/jump-dev/JuMP.jl.git#master`
  [a1760a79] Wordhunt v0.2.0 `~/code/Wordhunt.jl`
  [8fd58aa0] HiGHS_jll v1.1.0+0 `~/code/HiGHS_jll.jl`

julia> using HiGHS, JuMP
[ Info: Precompiling JuMP [4076af6c-e467-56ae-b986-b466b2749572]

julia> m = JuMP.read_from_file("grid4.mps");

julia> set_optimizer(m, HiGHS.Optimizer)

julia> optimize!(m)

Presolving model
334 rows, 228 cols, 996 nonzeros
148 rows, 183 cols, 609 nonzeros
148 rows, 97 cols, 437 nonzeros
corrupted double-linked list

HiGHS_jll can load and solve the same file without issues in the same environment:

               _
   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.6.3 (2021-09-23)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using HiGHS_jll

julia> HiGHS_jll.highs() do exe
        run(`$(exe) ./grid4.mps`)
        end
Running HiGHS 1.1.0 [date: , git hash: ]
Copyright (c) 2021 ERGO-Code under MIT licence terms
Number of BV entries in BOUNDS section is 145
MIP  grid4 has 429 rows; 240 cols; 1103 nonzeros; 145 integer variables

Presolving model
178 rows, 213 cols, 669 nonzeros
148 rows, 183 cols, 609 nonzeros
148 rows, 97 cols, 437 nonzeros
148 rows, 97 cols, 437 nonzeros

Solving MIP model with:
   148 rows
   97 cols (88 binary, 0 integer, 0 implied int., 9 continuous)
   437 nonzeros

( 0.0s) Starting symmetry detection
( 0.0s) Found 1 generators

Solving root node LP relaxation

        Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work

     Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time

         0       0         0   0.00%   -34.83199078    inf                  inf        0      0      0       123     0.0s
 R       0       0         0   0.00%   -33.35742548    -30.03535534      11.06%     3108     39    239       589     0.3s
 L       0       0         0   0.00%   -33.29078267    -30.07071068      10.71%     6450     50    250       888     0.8s
 L       0       0         0   0.00%   -33.29078267    -31.0559017        7.20%     5692     33    250       898     0.8s
 B       0       0         0   0.00%   -33.29078267    -31.07071068       7.15%     5699     33    262      1018     1.1s

Solving report
  Status            Optimal
  Primal bound      -31.0707106781
  Dual bound        -31.0707106781
  Solution status   feasible
                    -31.0707106781 (objective)
                    0 (bound viol.)
                    0 (int. viol.)
                    0 (row viol.)
  Timing            1.23 (total)
                    0.01 (presolve)
                    0.00 (postsolve)
  Nodes             1
  LP iterations     9243 (total)
                    7908 (strong br.)
                    765 (separation)
                    130 (heuristics)

HiGHS File Handle Leak

Running JuMP.optimize many times will cause the julia process to run out of file handles. Running lsof shows that Highs.log is opened many times and never closed.

The easiest way to reproduce is to try optimizing many times with julia --project -i and then either it will fail or lsof will show hundreds of Highs.log files opened.

using HiGHS
using JuMP

function run_once()
    vector_model = Model(HiGHS.Optimizer)

    A = [
        1 1 9 5
        3 5 0 8
        2 0 6 13
    ]

    b = [7; 3; 5]

    c = [1; 3; 5; 2]

    @variable(vector_model, x[1:4] >= 0)
    @constraint(vector_model, A * x .== b)
    @objective(vector_model, Min, c' * x)

    @timed JuMP.optimize!(vector_model)
end

for i in 1:1000
    run_once()
end

I've been testing against HiGHS version 0.3.10 and HiGHS_jll version 1.1.1+0. JuMP version is 0.22.2.

Missing == in MOI_wrapper assertions

@assert model.solution.model_status kHighsModelStatusUnknown

Also at

@assert model.solution.model_status kHighsModelStatusUnknown

I only noticed this after making the change I mentioned in #105, since Highs_run warnings were now going through the if..else lists in MOI.get(..., ::MOI.TerminationStatus) and MOI.get(..., ::MOI.RawStatusString) and erroring on the malformed assertions, with TypeError: non-boolean used in boolean context.

Error when nonzero coefficient close to zero

Hello! I get an error when I run the following code:

using JuMP
using HiGHS
model = Model(HiGHS.Optimizer)
@variable(model, x)
@constraint(model, 1e-9*x <= 1) # works with @constraint(model, 0*x <= 1)
optimize!(model)
WARNING: LP matrix packed vector contains 1 |values| in [1e-09, 1e-09] less than 1e-09: ignored
ERROR: Encountered an error in HiGHS (Status 1). Check the log for details.

(log file empty)
Version info:

Julia Version 1.7.0
Commit 3bf9d17731 (2021-11-30 12:12 UTC)
Platform Info:
  OS: Windows (x86_64-w64-mingw32)
  CPU: Intel(R) Core(TM) i7-7600U CPU @ 2.80GHz
  WORD_SIZE: 64
  LIBM: libopenlibm
  LLVM: libLLVM-12.0.1 (ORCJIT, skylake)
  [87dc4568] HiGHS v0.3.0
  [4076af6c] JuMP v0.22.1

MethodError: no method matching _set_option(::HiGHS.Optimizer, ::String, ::Nothing)

Hi, I am facing the following error while trying to run our GenX model written in Julia/JuMP with HiGHS. Can someone please help?

ERROR: LoadError: MethodError: no method matching _set_option(::HiGHS.Optimizer, ::String, ::Nothing)
Closest candidates are:
  _set_option(::HiGHS.Optimizer, ::String, ::Bool) at /Users/sc87/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:485
  _set_option(::HiGHS.Optimizer, ::String, ::Integer) at /Users/sc87/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:489
  _set_option(::HiGHS.Optimizer, ::String, ::AbstractFloat) at /Users/sc87/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:493
  ...
Stacktrace:
 [1] set(model::HiGHS.Optimizer, param::MathOptInterface.RawParameter, value::Nothing)
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:506
 [2] _instantiate_and_check(optimizer_constructor::MathOptInterface.OptimizerWithAttributes)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:88
 [3] instantiate(optimizer_constructor::MathOptInterface.OptimizerWithAttributes; with_bridge_type::Type{Float64}, with_names::Bool)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:120
 [4] set_optimizer(model::JuMP.Model, optimizer_constructor::MathOptInterface.OptimizerWithAttributes; bridge_constraints::Bool)
   @ JuMP ~/.julia/packages/JuMP/Xrr7O/src/optimizer_interface.jl:109
 [5] JuMP.Model(optimizer_factory::MathOptInterface.OptimizerWithAttributes; bridge_constraints::Bool, kwargs::Base.Iterators.Pairs{Union{}, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ JuMP ~/.julia/packages/JuMP/Xrr7O/src/JuMP.jl:287
 [6] Model
   @ ~/.julia/packages/JuMP/Xrr7O/src/JuMP.jl:286 [inlined]
 [7] generate_model(setup::Dict{Any, Any}, inputs::Dict{Any, Any}, OPTIMIZER::MathOptInterface.OptimizerWithAttributes, modeloutput::Nothing)
   @ GenX ~/code/GenX_Fork/GenX/src/model/generate_model.jl:99
 [8] generate_model(setup::Dict{Any, Any}, inputs::Dict{Any, Any}, OPTIMIZER::MathOptInterface.OptimizerWithAttributes)
   @ GenX ~/code/GenX_Fork/GenX/src/model/generate_model.jl:92
 [9] top-level scope
   @ ~/code/GenX_Fork/GenX/Example_Systems/SmallNewEngland/OneZone/Run.jl:63
in expression starting at /Users/sc87/code/GenX_Fork/GenX/Example_Systems/SmallNewEngland/OneZone/Run.jl:63

Our code segment consists of a function that looks like this:

function configure_highs(solver_settings_path::String)
  	solver_settings = YAML.load(open(solver_settings_path))

	# Optional solver parameters ############################################
	MyFeasibilityTol = 1e-6 # Constraint (primal) feasibility tolerances. See https://github.com/jump-dev/HiGHS.jl, https://github.com/ERGO-Code/HiGHS, and https://highs.dev/
		if(haskey(solver_settings, "Feasib_Tol")) MyFeasibilityTol = solver_settings["Feasib_Tol"] end
	MyOptimalityTol = 1e-6  # Dual feasibility tolerances. See https://github.com/jump-dev/HiGHS.jl, https://github.com/ERGO-Code/HiGHS, and https://highs.dev/
		if(haskey(solver_settings, "Optimal_Tol")) MyOptimalityTol = solver_settings["Optimal_Tol"] end
	MyPresolve = "choose" 	# Controls presolve level. See https://github.com/jump-dev/HiGHS.jl, https://github.com/ERGO-Code/HiGHS, and https://highs.dev/
		if(haskey(solver_settings, "Pre_Solve")) MyPresolve = solver_settings["Pre_Solve"] end
	MyTimeLimit = Inf	# Limits total time solver. See https://www.gurobi.com/documentation/8.1/refman/timelimit.html
		if(haskey(solver_settings, "TimeLimit")) MyTimeLimit = solver_settings["TimeLimit"] end

.....

OPTIMIZER = optimizer_with_attributes(HiGHS.Optimizer,
		"primal_feasibility_tolerance" => MyFeasibilityTol,
		"dual_feasibility_tolerance" => MyOptimalityTol,
		"time_limit" => MyTimeLimit
	)

	return OPTIMIZER

end

This OPTIMIZER is then used to build our model.

HiGHS reports infeasible for a feasible model

I am using the model below. I get the right answer when setting bigM to 1_000 but I am getting a (wrong) infeasible answer when setting bigM to 1_000_000. I understand a large bigM can create numerical issues but other solvers like Cbc return the right results even with the large bigM. I am wondering if there is something that can be done to better handle this case.

Thanks!

Infeasiblity report:
Presolving model
1 rows, 0 cols, 0 nonzeros
0 rows, 0 cols, 0 nonzeros
Presolve: Optimal
WARNING: Untransformed solution with objective 0 is violated by 1 for the original model

Solving report
  Status            Optimal
  Primal bound      0
  Dual bound        0
  Solution status   infeasible
                    0 (objective)
                    0 (bound viol.)
                    0 (int. viol.)
                    1 (row viol.)
  Timing            0.00 (total)
                    0.00 (presolve)
                    0.00 (postsolve)
  Nodes             0
  LP iterations     0 (total)
                    0 (strong br.)
                    0 (separation)
                    0 (heuristics)

Model:

using HiGHS
function get_orders(arrivals, lead_times, arriving_orders, minimum_order_quantity, maximum_order_quantity)
    m = Model(HiGHS.Optimizer)
    
    bigM = 1_000_000

    times = 1:length(arrivals)
    @variable(m, orders[times] >= 0)
    @variable(m, has_orders[times], Bin)

    @constraint(m, [t=times], orders[t] <= bigM * has_orders[t])

    if minimum_order_quantity > 0
        @constraint(m, [t=times], orders[t] >= minimum_order_quantity * has_orders[t])
    end
    if !isinf(maximum_order_quantity)
        @constraint(m, [t=times], orders[t] <= maximum_order_quantity)
    end

    @constraint(m, [t=times], arrivals[t] == sum(orders[t1] for t1 in times if t1 + lead_times[t1] == t) + arriving_orders[t])

    optimize!(m)

    return value.(m[:orders])
end

Call: get_orders([1,1,0,3,4], [1,1,1,1,1], [1,0,0,0,0],0,10)

performance issue

Hi,
I noticed adding variables for HiGHS solver is very slow compare to cplex solver. It seems there is a lot of allocations going on. Below is the code:

using HiGHS
using CPLEX
import MathOptInterface as MOI

highs_model=HiGHS.Optimizer()
cplex_model=CPLEX.Optimizer()

@time MOI.add_variables(highs_model,100000)
1.811086 seconds (100.01 k allocations: 8.694 MiB, 7.26% gc time)

@time MOI.add_variables(cplex_model,100000)
0.011854 seconds (400.01 k allocations: 15.561 MiB)

Add support for indicator constraints

When solving a model with indicator constraints I get the below error message. It would be great to have support for indicator constraints.

MOI.VectorAffineFunction{Float64}`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` constraints are not supported and cannot be bridged into supported constrained variables and constraints. See details below:
   [1] constrained variables in `MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` are not supported because no added bridge supports bridging it.
     Cannot add free variables and then constrain them because:
     (2) `MOI.VectorOfVariables`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` constraints are not supported
   [4] constrained variables in `MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` are not supported because no added bridge supports bridging it.
     Cannot add free variables and then constrain them because:
     (9) `MOI.VectorOfVariables`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` constraints are not supported
   [5] constrained variables in `MOI.SOS1{Float64}` are not supported because no added bridge supports bridging it.
     Cannot add free variables and then constrain them because:
     (10) `MOI.VectorOfVariables`-in-`MOI.SOS1{Float64}` constraints are not supported
   (1) `MOI.VectorAffineFunction{Float64}`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` constraints are not supported because:
     Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}}` because:
     [1] constrained variables in `MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` are not supported
     Cannot use `MOIB.Constraint.IndicatorActiveOnFalseBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.EqualTo{Float64}}` because:
     (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` constraints are not supported
   (2) `MOI.VectorOfVariables`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` constraints are not supported because:
     Cannot use `MOIB.Constraint.VectorFunctionizeBridge{Float64, MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}}` because:
     (1) `MOI.VectorAffineFunction{Float64}`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ZERO, MOI.EqualTo{Float64}}` constraints are not supported
   (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` constraints are not supported because:
     Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}}` because:
     [4] constrained variables in `MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` are not supported
     Cannot use `MOIB.Constraint.IndicatorSOS1Bridge{Float64, MOI.EqualTo{Float64}, Nothing}` because:
     (10) `MOI.VectorOfVariables`-in-`MOI.SOS1{Float64}` constraints are not supported
   (9) `MOI.VectorOfVariables`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` constraints are not supported because:
     Cannot use `MOIB.Constraint.VectorFunctionizeBridge{Float64, MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}}` because:
     (8) `MOI.VectorAffineFunction{Float64}`-in-`MOI.IndicatorSet{MOI.ACTIVATE_ON_ONE, MOI.EqualTo{Float64}}` constraints are not supported
     Cannot use `MOIB.Constraint.IndicatorSOS1Bridge{Float64, MOI.EqualTo{Float64}, Nothing}` because:
     (10) `MOI.VectorOfVariables`-in-`MOI.SOS1{Float64}` constraints are not supported
   (10) `MOI.VectorOfVariables`-in-`MOI.SOS1{Float64}` constraints are not supported because:
     Cannot use `MOIB.Constraint.VectorFunctionizeBridge{Float64, MOI.SOS1{Float64}}` because:
     (11) `MOI.VectorAffineFunction{Float64}`-in-`MOI.SOS1{Float64}` constraints are not supported
   (11) `MOI.VectorAffineFunction{Float64}`-in-`MOI.SOS1{Float64}` constraints are not supported because:
     Cannot use `MOIB.Constraint.VectorSlackBridge{Float64, MOI.VectorAffineFunction{Float64}, MOI.SOS1{Float64}}` because:
     [5] constrained variables in `MOI.SOS1{Float64}` are not supported

_OPTIMIZE_WARNED status?

I find it a bit heavy that model.solution.status is set to _OPTIMIZE_ERRORED for any nonzero return value of Highs_run, at

x.status = ret == 0 ? _OPTIMIZE_OK : _OPTIMIZE_ERRORED
. Highs_run return value of 1 indicates a warning, -1 indicates an error.

Locally I've made the change below, adding an _OPTIMIZE_WARNED status to the _OptimizeStatus enum. In the case of a Highs_run warning, this lets me see more easily the MOI.TerminationStatus and MOI.RawStatusString, and act on the result. In my use case, I'm frequently encountering an optimal solution but with a warning. I'd like to know there's a warning and see the solver result rather than have it be shunted into MOI.OTHER_ERROR.

diff --git a/src/MOI_wrapper.jl b/src/MOI_wrapper.jl
index e485382..4aff9d3 100644
--- a/src/MOI_wrapper.jl
+++ b/src/MOI_wrapper.jl
@@ -162,7 +162,7 @@ function _set(c::_ConstraintInfo)
     end
 end
 
-@enum(_OptimizeStatus, _OPTIMIZE_NOT_CALLED, _OPTIMIZE_OK, _OPTIMIZE_ERRORED)
+@enum(_OptimizeStatus, _OPTIMIZE_NOT_CALLED, _OPTIMIZE_OK, _OPTIMIZE_ERRORED, _OPTIMIZE_WARNED)
 
 """
     _Solution
@@ -1553,7 +1553,7 @@ Get the solution from a run of HiGHS.
 """
 function _store_solution(model::Optimizer, ret::HighsInt)
     x = model.solution
-    x.status = ret == 0 ? _OPTIMIZE_OK : _OPTIMIZE_ERRORED
+    x.status = ret == kHighsStatusOk ? _OPTIMIZE_OK : ret == kHighsStatusWarning ? _OPTIMIZE_WARNED : _OPTIMIZE_ERRORED
     x.primal_solution_status = kHighsSolutionStatusNone
     x.dual_solution_status = kHighsSolutionStatusNone
     x.has_dual_ray = false

Support MOI.copy_to

I have a mass balance type LP, and thought I'd try out HiGHS. Some quick benchmarking showed HiGHS to be significantly slower than Clp on my problem. Since the README says sharing such examples could be helpful, I thought I'd post a toy example that illustrates the performance delta I observed. Hope it's helpful, if not, feel free to close this.Either way, I'll be following HiGHS with interest! ๐Ÿ˜„

using JuMP
using Clp
using HiGHS
using BenchmarkTools


function mass(v, n)  
    m = map(a -> repeat([a], Int(n/4)), v)  |> 
        b -> reduce((x, y) -> vcat(x, y), b)

    return m
end


function solve_lp(c, n, m1, m2, optimizer)

    model = Model(optimizer)

    @variable(model, 0 <= x[i = 1:n] <= 5)
    @variable(model, 0 <= y[i = 1:n] <= 3)

    @variable(model, l[i = 1:n] >= 0)

    @constraint(model, vlim[i = 1:n], x[i] + y[i] <= m1[i])

    @constraint(model, ylim[i = 1:n], y[i] <= m2[i])

    @constraint(model, dynamics[i = 2:n], l[i] <= x[i-1] * m1[i-1] + y[i-1] * m2[i-1])

    @objective(model, Max, sum(c .* x))

    optimize!(model)

    return (raw_status(model), objective_value(model))

end


# definitions
c = [5:0.1:25; 20:-0.1:1]

n = length(c)

m1 = mass([2, 0, 1, 4], n)
m2 = mass([0, 2, 3, 4], n)


# solve with Clp
@benchmark solve_lp(c, n, m1, m2, Clp.Optimizer) samples=100
# memory estimate:  5.04 MiB
# allocs estimate:  49097
# --------------
# minimum time:     5.534 ms (0.00% GC)
# median time:      6.297 ms (0.00% GC)
# mean time:        7.050 ms (10.43% GC)
# maximum time:     15.391 ms (55.42% GC)
# --------------
# samples:          100
# evals/sample:     1


# solve with HiGHS
@benchmark solve_lp(c, n, m1, m2, HiGHS.Optimizer) samples=100
# memory estimate:  4.27 MiB
# allocs estimate:  51562
# --------------
# minimum time:     19.587 ms (0.00% GC)
# median time:      20.602 ms (0.00% GC)
# mean time:        21.578 ms (3.40% GC)
# maximum time:     32.377 ms (26.83% GC)
# --------------
# samples:          100
# evals/sample:     1

Error when calling Highs_writeOptions

From the intro docs,

To print the list of options supported by HiGHS, do:

using HiGHS
model = HiGHS.Optimizer()
Highs_writeOptions(model, "options.txt")
println(read("options.txt", String))

I get this error:

Julia-1.7.1> Highs_writeOptions(model, "options.txt")
ERROR: could not load symbol "Highs_writeOptions":
The specified procedure could not be found.
Stacktrace:
 [1] Highs_writeOptions(highs::HiGHS.Optimizer, filename::String)
   @ HiGHS C:\Users\plowman\.julia\packages\HiGHS\gxmTb\src\gen\libhighs_api.jl:120
 [2] top-level scope
   @ REPL[3]:1

problem on HiGHS version

When I use the following command to install highs,

import Pkg
Pkg.add("HiGHS")

the version of HiGHS installed is v0.2.3. How do I install the latest version of HiGHS (v1.1)?
Thanks.

Cannot load HiGHS through JuMP

I'm unable to access HiGHS in JuMP. I'm running Julia 1.7.0 on macOS 12.2.1. Minimal example:

   _       _ _(_)_     |  Documentation: https://docs.julialang.org
  (_)     | (_) (_)    |
   _ _   _| |_  __ _   |  Type "?" for help, "]?" for Pkg help.
  | | | | | | |/ _` |  |
  | | |_| | | | (_| |  |  Version 1.7.0 (2021-11-30)
 _/ |\__'_|_|_|\__'_|  |  Official https://julialang.org/ release
|__/                   |

julia> using JuMP, HiGHS

julia> model = Model(HiGHS.Optimizer)
ERROR: UndefVarError: libhighs not defined
Stacktrace:
 [1] Highs_create
   @ ~/.julia/packages/HiGHS/YP79q/src/gen/libhighs_api.jl:28 [inlined]
 [2] empty!(model::HiGHS.Optimizer)
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:376
 [3] HiGHS.Optimizer()
   @ HiGHS ~/.julia/packages/HiGHS/YP79q/src/MOI_wrapper.jl:345
 [4] _instantiate_and_check(optimizer_constructor::Type{HiGHS.Optimizer})
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:62
 [5] instantiate(optimizer_constructor::Type; with_bridge_type::Type{Float64}, with_names::Bool)
   @ MathOptInterface ~/.julia/packages/MathOptInterface/YDdD3/src/instantiate.jl:120
 [6] set_optimizer(model::Model, optimizer_constructor::Type; bridge_constraints::Bool)
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/optimizer_interface.jl:109
 [7] Model(optimizer_factory::Type; bridge_constraints::Bool, kwargs::Base.Pairs{Symbol, Union{}, Tuple{}, NamedTuple{(), Tuple{}}})
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/JuMP.jl:287
 [8] Model(optimizer_factory::Type)
   @ JuMP ~/.julia/packages/JuMP/klrjG/src/JuMP.jl:286
 [9] top-level scope
   @ REPL[1]:1

Handle INFEASIBLE_POINT statuses

For the attached MOF file HiGH prints the following log to the REPL:

julia> optimize!(m)
0, 150795.719209, 41, 0.015529, 0.000609, 388, 0.000000, 0.000000
1000, 144677.302916, 65, 0.110455, 0.000520, 285, 0.000000, 0.002797
1370, 144677.302624, 65, 0.155823, 0.000320, 254, 0.000000, 0.002797
ERROR:   QP solver claims optimality, but with num/sum/max primal(3/0.000319877/0.000142008) and dual(3/3319.88/3316.94) infeasibilities
Model   status      : Optimal
Simplex   iterations: 488
QP ASM    iterations: 1370
Objective value     :  1.4467730262e+05
HiGHS run time      :          0.16

However, the return status from JuMP is NO_SOLUTION.

The same problem in IPOPT has the following output:

his is Ipopt version 3.14.4, running with linear solver MUMPS 5.4.1.

Number of nonzeros in equality constraint Jacobian...:     2496
Number of nonzeros in inequality constraint Jacobian.:     3024
Number of nonzeros in Lagrangian Hessian.............:      120

Total number of variables............................:      984
                     variables with only lower bounds:        0
                variables with lower and upper bounds:      216
                     variables with only upper bounds:        0
Total number of equality constraints.................:      840
Total number of inequality constraints...............:     2160
        inequality constraints with only lower bounds:     1080
   inequality constraints with lower and upper bounds:        0
        inequality constraints with only upper bounds:     1080

iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
   0  3.8477488e+03 9.32e-01 5.87e+00  -1.0 0.00e+00    -  0.00e+00 0.00e+00   0
   1  1.7083487e+05 6.66e-16 5.63e+01  -1.0 6.63e-01    -  1.73e-02 1.00e+00h  1
   2  1.4738956e+05 9.99e-16 2.52e+01  -1.0 1.49e+00    -  2.92e-01 5.52e-01f  1
   3  1.4488590e+05 8.88e-16 1.88e+01  -1.0 7.12e-01    -  9.50e-01 2.56e-01f  1
   4  1.4244691e+05 2.66e-15 6.57e+00  -1.0 3.79e+00    -  9.72e-01 6.53e-01f  1
   5  1.4230740e+05 3.55e-15 1.00e-06  -1.0 3.70e+00    -  1.00e+00 1.00e+00f  1
   6  1.4165823e+05 5.33e-15 4.30e-03  -2.5 2.45e+00    -  8.81e-01 8.87e-01f  1
   7  1.4157997e+05 3.55e-15 1.87e-01  -2.5 2.52e-01    -  1.00e+00 6.13e-01f  1
   8  1.4153211e+05 5.33e-15 2.83e-08  -2.5 3.79e-02    -  1.00e+00 1.00e+00f  1
   9  1.4151379e+05 7.11e-15 2.48e-04  -3.8 4.05e-02    -  1.00e+00 9.96e-01f  1
iter    objective    inf_pr   inf_du lg(mu)  ||d||  lg(rg) alpha_du alpha_pr  ls
  10  1.4151276e+05 5.33e-15 1.84e-11  -5.7 4.86e-04    -  1.00e+00 1.00e+00f  1
  11  1.4151274e+05 3.55e-15 2.66e-14  -8.6 2.28e-05    -  1.00e+00 1.00e+00f  1

Number of Iterations....: 11

                                   (scaled)                 (unscaled)
Objective...............:   3.5378185780472641e+03    1.4151274312189055e+05
Dual infeasibility......:   2.6645352591003757e-14    1.0658141036401503e-12
Constraint violation....:   3.5527136788005009e-15    3.5527136788005009e-15
Variable bound violation:   9.7471085828473771e-09    9.7471085828473771e-09
Complementarity.........:   2.6310850719202676e-09    1.0524340287681070e-07
Overall NLP error.......:   2.6310850719202676e-09    1.0524340287681070e-07


Number of objective function evaluations             = 12
Number of objective gradient evaluations             = 12
Number of equality constraint evaluations            = 12
Number of inequality constraint evaluations          = 12
Number of equality constraint Jacobian evaluations   = 1
Number of inequality constraint Jacobian evaluations = 1
Number of Lagrangian Hessian evaluations             = 1
Total seconds in IPOPT                               = 0.330

EXIT: Optimal Solution Found.

and JuMP return the status that the primal status is FEASIBLE_POINT

Status of IPM code?

@odow mentioned that the IPM solver is not yet enabled through the Julia interface. What's blocking it? I'm interested in running experiments with HiGHS/IPM as a baseline.

error() in optimize!

I have an instance that triggers this code path:

https://github.com/ERGO-Code/HiGHS/blob/cfe064e60fdca9dc8008fd956fff04d7b562e210/src/simplex/HApp.h#L281-L286

This causes run() to return HighsStatus::Error:

https://github.com/ERGO-Code/HiGHS/blob/cfe064e60fdca9dc8008fd956fff04d7b562e210/src/simplex/HApp.h#L316-L322

In Julia, this triggers an error from optimize! that supersedes the regular status reporting mechanism:

HiGHS.jl/src/MOI_wrapper.jl

Lines 1521 to 1528 in 7a05981

ret = Highs_run(model)
# `ret` is an `HighsStatus` enum: {OK = 0, Warning, Error}.
if ret == 2
error(
"Encountered an error in HiGHS: HighsStatus::Error. " *
"Check the log for details",
)
end

This could be an issue with HiGHS not providing enough clarity in status codes, but I'll start the discussion on the Julia side. If you look at highsStatusFromHighsModelStatus, the statuses that map to HighsStatus::Error are better covered by MOI statuses instead of throwing a Julia error. Somehow this particular case should end up begin reported as an MOI.OTHER_ERROR or MOI.NUMERICAL_ERROR.

The underlying numerical issue is also related to failing to clean up unscaled infeasibilities (like #46). Here's the solve log with some level of verbose output: https://pastebin.com/bjBTAFg1

@jajhall

Updating to latest HiGHS master

Hi folks - we are testing out HiGHS within the Spine energy system modelling framework (https://github.com/Spine-project) and so far, it looks very promising. Within Spine, we have a very powerful Julia interface (https://github.com/Spine-project/SpineInterface.jl) which allows you to quickly develop optimisation models in Julia along with a supporting data management framework.

Anyway, the point of this issue, is that I'm wondering what the process is for keeping HiGHS.jl up to date with the HiGHS project itself. In particular there have been a few recent changes including the introduction of the mip_gap_limit option ERGO-Code/HiGHS#647 which was very kindly implemented after an enquiry from myself.

I would even offer to help with the process but I am a little unsure how everything fits together, in particular the compilation of the binaries etc.

Thanks in advance

Add support for modifying the constraint matrix

# TODO(odow): add support for modifying the constraint matrix.
modify_lhs = false,

# TODO(odow): HiGHS doesn't support modifying the constraint matrix, so use
# a caching optimizer.
MOI.empty!(OPTIMIZER)
cache = MOI.Utilities.CachingOptimizer(
MOI.Utilities.Model{Float64}(),
OPTIMIZER,
)

HiGHS.jl/src/MOI_wrapper.jl

Lines 1395 to 1412 in 41a9038

# TODO(odow): doesn't look like HiGHS supports these.
#
# function MOI.modify(
# model::Optimizer,
# c::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64},S},
# chg::MOI.ScalarCoefficientChange{Float64}
# ) where {S<:_SCALAR_SETS}
# return
# end
#
# function MOI.set(
# model::Optimizer,
# ::MOI.ConstraintFunction,
# c::MOI.ConstraintIndex{MOI.ScalarAffineFunction{Float64}, <:_SCALAR_SETS},
# f::MOI.ScalarAffineFunction{Float64}
# )
# return
# end

Current blocked by upstream. Needs new release of HiGHS_jll which will expose Highs_changeCoeff.

MathOptInterface.TerminationStatus() unsupported for HiGHS

ArgumentError: ModelLike of type HiGHS.Optimizer does not support accessing the attribute MathOptInterface.TerminationStatus()
Stacktrace:
  [1] get_fallback(::HiGHS.Optimizer, ::MathOptInterface.TerminationStatus)
    @ MathOptInterface ~/.julia/dev/MathOptInterface/src/attributes.jl:292
  [2] get(::HiGHS.Optimizer, ::MathOptInterface.TerminationStatus)

is there any plan to support this? seems fairly essential to using the solver.

Assertion error in MOI.get(model::Optimizer, ::MOI.TerminationStatus)

I've seen this assertion error trigger:

HiGHS.jl/src/MOI_wrapper.jl

Lines 1587 to 1590 in 7a05981

else
@assert status == DUAL_INFEASIBLE
return MOI.DUAL_INFEASIBLE
end

The status in this case is HiGHS.NOTSET. It looks like this happens because HiGHS follows this branch that never sets the model status when it fails to resolve infeasibilities due to scaling. Should this be reported as MOI.OTHER_ERROR? (or MOI.NUMERICAL_ERROR if HiGHS expands its statuses accordingly)

@jajhall

Add constraint is very slow

using HiGHS
q=MOI.add_variable(optimizer)
@Btime MOI.add_constraint(optimizer,q*1.0,MOI.LessThan(0.0))

4.688 ms (9 allocations: 432 bytes)


using CPLEX
q=MOI.add_variable(optimizer)
@Btime MOI.add_constraint(optimizer,q*1.0,MOI.LessThan(0.0))

804.895 ns (15 allocations: 560 bytes)

Option "mip_rel_gap" is unknown

According to the readme and browsing the latest HiGHS repo, it looks like option mip_rel_gap is supported.

However:

using JuMP
import HiGHS
model = Model(HiGHS.Optimizer)
set_optimizer_attribute(model, "mip_rel_gap", 0.05)

results in

ERROR:   getOptionIndex: Option "mip_rel_gap" is unknown
ERROR: LoadError: MathOptInterface.UnsupportedAttribute{MathOptInterface.RawParameter}: Attribute MathOptInterface.RawParameter("mip_rel_gap") is not supported by the model.

Why QP failures are allowed?

These are allowed to fail in many tests.

const _QP_FAILURES = [
    "test_objective_qp_ObjectiveFunction_edge_cases",
    "test_objective_qp_ObjectiveFunction_zero_ofdiag",
    "test_quadratic_duplicate_terms",
    "test_quadratic_integration",
    "test_quadratic_nonhomogeneous",
]

Is it a problem upstream?

Creating 'big' models is very slow

Hello,

I am trying to build a large model (~100,000 variables and constraints) and the call to optimize! takes a long time (10+ min before the optimization even starts).

I have attached a partial trace (I stopped executing after a minute or so) and my understanding of it is that adding the rows and constraints is costly.

Is there a way to speed things in the Julia wrapper or is this an issue with HiGHS (or with my code...)?

Thank you.
trace.txt

Finishing up the wrapper

I spoke to @jajhall today, and it hadn't been clear to him the state of the JuMP interface and what's blocking on whose side.

From skimming the issues, the items on HiGHS's side are:

On the JuMP interface side:

  • Pass MOI's LP solver tests

After the wrapper's ready, I'm happy to advertise it to current Clp users as @odow suggested in ERGO-Code/HiGHS#210 (comment).

CC @matbesancon @odow @mtanneau @feldmeier

Tests segfault on M1

(jump-tests) pkg> test HiGHS
     Testing HiGHS
      Status `/private/var/folders/tz/_3rffzvd1hs3rrxssmntjnpw0000gn/T/jl_oW9CvQ/Project.toml`
  [87dc4568] HiGHS v1.1.3
  [b8f27783] MathOptInterface v1.2.0
  [8fd58aa0] HiGHS_jll v1.2.2+0
  [2f01184e] SparseArrays `@stdlib/SparseArrays`
  [8dfed614] Test `@stdlib/Test`
      Status `/private/var/folders/tz/_3rffzvd1hs3rrxssmntjnpw0000gn/T/jl_oW9CvQ/Manifest.toml`
  [6e4b80f9] BenchmarkTools v1.3.1
  [523fee87] CodecBzip2 v0.7.2
  [944b1d66] CodecZlib v0.7.0
  [87dc4568] HiGHS v1.1.3
  [692b3bcd] JLLWrappers v1.4.1
  [682c06a0] JSON v0.21.3
  [b8f27783] MathOptInterface v1.2.0
  [d8a4904e] MutableArithmetics v1.0.0
  [bac558e1] OrderedCollections v1.4.1
  [69de0a69] Parsers v2.3.1
  [21216c6a] Preferences v1.3.0
  [3bb67fe8] TranscodingStreams v0.9.6
  [6e34b625] Bzip2_jll v1.0.8+0
  [8fd58aa0] HiGHS_jll v1.2.2+0
  [0dad84c5] ArgTools `@stdlib/ArgTools`
  [56f22d72] Artifacts `@stdlib/Artifacts`
  [2a0f44e3] Base64 `@stdlib/Base64`
  [ade2ca70] Dates `@stdlib/Dates`
  [f43a241f] Downloads `@stdlib/Downloads`
  [b77e0a4c] InteractiveUtils `@stdlib/InteractiveUtils`
  [b27032c2] LibCURL `@stdlib/LibCURL`
  [76f85450] LibGit2 `@stdlib/LibGit2`
  [8f399da3] Libdl `@stdlib/Libdl`
  [37e2e46d] LinearAlgebra `@stdlib/LinearAlgebra`
  [56ddb016] Logging `@stdlib/Logging`
  [d6f4376e] Markdown `@stdlib/Markdown`
  [a63ad114] Mmap `@stdlib/Mmap`
  [ca575930] NetworkOptions `@stdlib/NetworkOptions`
  [44cfe95a] Pkg `@stdlib/Pkg`
  [de0858da] Printf `@stdlib/Printf`
  [9abbd945] Profile `@stdlib/Profile`
  [3fa0cd96] REPL `@stdlib/REPL`
  [9a3f8284] Random `@stdlib/Random`
  [ea8e919c] SHA `@stdlib/SHA`
  [9e88b42a] Serialization `@stdlib/Serialization`
  [6462fe0b] Sockets `@stdlib/Sockets`
  [2f01184e] SparseArrays `@stdlib/SparseArrays`
  [10745b16] Statistics `@stdlib/Statistics`
  [fa267f1f] TOML `@stdlib/TOML`
  [a4e569a6] Tar `@stdlib/Tar`
  [8dfed614] Test `@stdlib/Test`
  [cf7118a7] UUIDs `@stdlib/UUIDs`
  [4ec0a83e] Unicode `@stdlib/Unicode`
  [e66e0078] CompilerSupportLibraries_jll `@stdlib/CompilerSupportLibraries_jll`
  [deac9b47] LibCURL_jll `@stdlib/LibCURL_jll`
  [29816b5a] LibSSH2_jll `@stdlib/LibSSH2_jll`
  [c8ffd9c3] MbedTLS_jll `@stdlib/MbedTLS_jll`
  [14a3606d] MozillaCACerts_jll `@stdlib/MozillaCACerts_jll`
  [4536629a] OpenBLAS_jll `@stdlib/OpenBLAS_jll`
  [83775a58] Zlib_jll `@stdlib/Zlib_jll`
  [8e850b90] libblastrampoline_jll `@stdlib/libblastrampoline_jll`
  [8e850ede] nghttp2_jll `@stdlib/nghttp2_jll`
  [3f19e933] p7zip_jll `@stdlib/p7zip_jll`
     Testing Running tests...
Test Summary: | Pass  Total
C_wrapper.jl  |    5      5

Presolve is switched off

Solving MIP model with:
   1 rows
   30 cols (30 binary, 0 integer, 0 implied int., 0 continuous)
   30 nonzeros

( 0.0s) Starting symmetry detection
( 0.0s) No symmetry present

        Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work      
     Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time

         0       0         0   0.00%   16.76270083     -inf                 inf        0      0      0         0     0.0s
 S       0       0         0   0.00%   16.76270083     14.84850282       12.89%        0      0      0         0     0.0s
         0       0         0   0.00%   15.00872874     14.84850282        1.08%        0      0      0         1     0.0s

Solving report
  Status            Optimal
  Primal bound      14.9216412841
  Dual bound        14.9216412841
  Gap               0% (tolerance: 0.01%)
  Solution status   feasible
                    14.9216412841 (objective)
                    0 (bound viol.)
                    1.99840144433e-15 (int. viol.)
                    0 (row viol.)
  Timing            0.00 (total)
                    0.00 (presolve)
                    0.00 (postsolve)
  Nodes             1
  LP iterations     9 (total)
                    0 (strong br.)
                    8 (separation)
                    0 (heuristics)

Presolve is switched off

Solving MIP model with:
   1 rows
   30 cols (30 binary, 0 integer, 0 implied int., 0 continuous)
   30 nonzeros

( 0.0s) Starting symmetry detection
( 0.0s) No symmetry present

        Nodes      |    B&B Tree     |            Objective Bounds              |  Dynamic Constraints |       Work      
     Proc. InQueue |  Leaves   Expl. | BestBound       BestSol              Gap |   Cuts   InLp Confl. | LpIters     Time

         0       0         0   0.00%   16.76270083     -inf                 inf        0      0      0         0     0.0s
 S       0       0         0   0.00%   16.76270083     14.84850282       12.89%        0      0      0         0     0.0s
         0       0         0   0.00%   15.00872874     14.84850282        1.08%        0      0      0         1     0.0s

Solving report
  Status            Optimal
  Primal bound      14.9216412841
  Dual bound        14.9216412841
  Gap               0% (tolerance: 0.01%)
  Solution status   feasible
                    14.9216412841 (objective)
                    0 (bound viol.)
                    1.99840144433e-15 (int. viol.)
                    0 (row viol.)
  Timing            0.00 (total)
                    0.00 (presolve)
                    0.00 (postsolve)
  Nodes             1
  LP iterations     9 (total)
                    0 (strong br.)
                    8 (separation)
                    0 (heuristics)
Solving LP without presolve or with basis
Using EKK dual simplex solver - serial
  Iteration        Objective     Infeasibilities num(sum)
          0    -5.3687537354e+04 Ph1: 1(28324.3); Du: 30(53.6875) 0s
          1    -4.5344862766e+04 Ph1: 0(0); Du: 29(45.3449) 0s
          1     5.4698212166e+00 Pr: 0(0); Du: 29(45.3449) 0s
Using EKK primal simplex solver
  Iteration        Objective     Infeasibilities num(sum)
          1     5.4698224911e+00 Pr: 0(0); Du: 29(11.1913) 0s
          1     5.4698212166e+00 Pr: 0(0); Du: 29(11.1913) 0s
Model   status      : Unbounded
Simplex   iterations: 1
Objective value     :  5.4698212166e+00
HiGHS run time      :          0.00
Solving LP without presolve or with basis
IPX model has 1 rows, 30 columns and 30 nonzeros
Input
    Number of variables:                                30
    Number of free variables:                           30
    Number of constraints:                              1
    Number of equality constraints:                     0
    Number of matrix entries:                           30
    Matrix range:                                       [3e-03, 9e-01]
    RHS range:                                          [1e+01, 1e+01]
    Objective range:                                    [2e-02, 1e+00]
    Bounds range:                                       [0e+00, 0e+00]
Preprocessing
    Dualized model:                                     no
    Number of dense columns:                            0
    Range of scaling factors:                           [1.00e+00, 2.56e+02]
IPX version 1.0
Interior Point Solve
 Iter     P.res    D.res            P.obj           D.obj        mu     Time
   0   1.74e+00 5.87e+01  -4.43937239e+01 -4.43937239e+01  1.68e+01       0s
   1   1.74e-06 5.85e+01  -1.21593225e+03 -4.66256987e+01  1.57e+00       0s
   2   1.91e-11 5.85e+01  -3.58021136e+03 -4.67516149e+01  4.68e-30       0s
   3   1.59e+88 2.75e+73  4.59625327e+104 -2.75047935e+74  2.69e+177       0s
   4   0.00e+00 2.75e+67  4.59625327e+104 -2.75047935e+68  2.69e+171       0s
   5   0.00e+00 2.75e+61  4.59625327e+104 -2.75047935e+62  2.69e+165       0s
   6   1.59e+88 2.75e+55  4.59625327e+104 -2.75047935e+56  2.69e+159       0s
   7   1.59e+88 2.75e+49  4.59625327e+104 -2.75047936e+50  2.69e+153       0s
   8   3.18e+88 2.75e+43  4.59625327e+104 -2.75047935e+44  2.69e+147       0s
   9   1.59e+88 2.75e+37  4.59625327e+104 -2.75047936e+38  2.69e+141       0s
  10   0.00e+00 2.75e+31  4.59625327e+104 -2.75047936e+32  2.69e+135       0s
  11   0.00e+00 2.75e+25  4.59625327e+104 -2.75047936e+26  2.69e+129       0s
  12   0.00e+00 2.75e+19  4.59625327e+104 -2.75047936e+20  2.69e+123       0s
  13   0.00e+00 2.75e+13  4.59625327e+104 -2.75047936e+14  2.69e+117       0s
  14   0.00e+00 2.75e+07  4.59625326e+104 -2.75047977e+08  2.69e+111       0s
  15   0.00e+00 4.24e+01  4.59612050e+104 -3.16919045e+02  3.09e+105       0s
  16   0.00e+00 5.88e+01  -1.10537366e+106 -4.22562247e+01  3.09e+104       0s
  17   4.38e+88 5.87e+01  -7.53039543e+106 -4.45213262e+01  4.45e-30       0s
 Constructing starting basis...
Summary
    Runtime:                                            0.00s
    Status interior point solve:                        dual infeas
    Status crossover:                                   not run
WARNING: Ipx: IPM       dual infeasible
WARNING: Ipx: Crossover not run
WARNING: Imprecise solution returned from IPX, so use simplex to clean up
Using EKK dual simplex solver - serial
  Iteration        Objective     Infeasibilities num(sum)
          0    -3.6574154110e+04 Ph1: 1(54003); Du: 30(36.5742) 0s
          1    -3.2869539556e+04 Ph1: 0(0); Du: 29(32.8695) 0s
          1     3.9749160170e+00 Pr: 0(0); Du: 29(32.8695) 0s
Using EKK primal simplex solver
  Iteration        Objective     Infeasibilities num(sum)
          1     3.9749169432e+00 Pr: 0(0); Du: 29(10.2852) 0s
          1     3.9749160170e+00 Pr: 0(0); Du: 29(10.2852) 0s
Model   status      : Unbounded
Simplex   iterations: 1
IPM       iterations: 17
Objective value     :  3.9749160170e+00
HiGHS run time      :          0.00
Presolving model
0 rows, 0 cols, 0 nonzeros
0 rows, 0 cols, 0 nonzeros
Presolve : Reductions: rows 0(-4); columns 0(-4); elements 0(-8) - Reduced to empty
Solving the original LP from the solution after postsolve
Model   status      : Optimal
Objective value     :  6.0000000000e+00
HiGHS run time      :          0.00
WARNING: checkOptionValue: Value -1 for option "time_limit" is below lower bound of 0
ERROR:   setLocalOptionValue: Option "write_solution_to_file" cannot be assigned an int
ERROR:   setLocalOptionValue: Option "time_limit" cannot be assigned an int
ERROR:   setLocalOptionValue: Option "presolve" cannot be assigned an int

signal (11): Segmentation fault: 11
in expression starting at /Users/oscardowson/.julia/packages/HiGHS/85iZH/test/MOI_wrapper.jl:287
_flag_to_set_type at /Users/oscardowson/.julia/packages/MathOptInterface/ajp5T/src/Utilities/variables_container.jl:0
Allocations: 488431866 (Pool: 488237119; Big: 194747); GC: 443
ERROR: Package HiGHS errored during testing (exit code: 139)

Time limit not working

Hi,

I wrote a linear MIP. No matter what I set for the time limit parameter, the solver doesn't stop before finding the optimal solution. I was wondering if it is just my problem.

m = Model(HiGHS.Optimizer)
set_optimizer_attribute(m, "presolve", "on")
set_optimizer_attribute(m, "time_limit", stime)

Thanks

Fix MOI.Silent

HiGHS.jl/src/MOI_wrapper.jl

Lines 448 to 456 in 41a9038

function MOI.set(model::Optimizer, ::MOI.Silent, flag::Bool)
if flag
Highs_runQuiet(model)
elseif model.silent && !flag
@warn("Unable to restore printing. Sorry.")
end
model.silent = flag
return
end

If we call Highs_runQuiet, there is currently no API to restore printing to stdout.

Currently blocked upstream. The next version of HiGHS_jll to be released will include Highs_setHighsOutput and Highs_setHighsLogfile which should allow us to restore the printing. Edit: maybe not. There's a larger discussion upstream: ERGO-Code/HiGHS#454

Fix ObjectiveBound

HiGHS.jl/src/MOI_wrapper.jl

Lines 1777 to 1786 in 94ae3b5

function MOI.get(model::Optimizer, ::MOI.ObjectiveBound)
# TODO(odow): there is a bug in HiGHS where it reports incorrect values for
# mip_dual_bound in the LP case. As a work-around, just return the most
# optimistic of the primal and dual values.
p = Ref{Cdouble}()
Highs_getDoubleInfoValue(model, "mip_dual_bound", p)
sense = _sense_corrector(model)
primal = Highs_getObjectiveValue(model)
return sense == -1 ? max(primal, -p[]) : min(primal, p[])
end

TagBot trigger issue

This issue is used to trigger TagBot; feel free to unsubscribe.

If you haven't already, you should update your TagBot.yml to include issue comment triggers.
Please see this post on Discourse for instructions and more details.

If you'd like for me to do this for you, comment TagBot fix on this issue.
I'll open a PR within a few hours, please be patient!

Update HiGHS_jll version

Hi, great work on making HiGHS available with Julia and JuMP!

I just learned about the MIP solver in HiGHS and gave it a try, unfortunately it crashed on my test problem:

334 rows, 228 cols, 996 nonzeros
148 rows, 183 cols, 609 nonzeros
148 rows, 97 cols, 437 nonzeros
148 rows, 97 cols, 437 nonzeros

Solving MIP model with:
   148 rows
   97 cols (88 binary, 0 integer, 0 implied int., 8 continuous)
   437 nonzeros

( 0.0s) Starting symmetry detection
( 0.0s) No symmetry present

Solving root node LP relaxation
corrupted size vs. prev_size

signal (6): Aborted
in expression starting at REPL[13]:1

MPS for the test problem here:
https://gist.github.com/hellemo/7b549f496f7a6ad2803d0e53794c9330

Error reported on TimeLimit settings parameter

I get the following error when I have the TimeLimit parameter set to Inf:

ERROR: LoadError: MathOptInterface.SetAttributeNotAllowed{MathOptInterface.RawOptimizerAttribute}: Setting attribute MathOptInterface.RawOptimizerAttribute("time_limit") cannot be performed: 

Invalid value `Inf::String` for option "time_limit".

 You may want to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call `reset_optimizer` before doing this operation if the `CachingOptimizer` is in `MANUAL` mode.

So, I set it to false. I then get this error:


ERROR: LoadError: MathOptInterface.SetAttributeNotAllowed{MathOptInterface.RawOptimizerAttribute}: Setting attribute MathOptInterface.RawOptimizerAttribute("time_limit") cannot be performed: 

Invalid value `false::Bool` for option "time_limit".

 You may want to use a `CachingOptimizer` in `AUTOMATIC` mode or you may need to call `reset_optimizer` before doing this operation if the `CachingOptimizer` is in `MANUAL` mode.

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.