jump-dev / HiGHS.jl

A Julia interface to the HiGHS solver
https://highs.dev
MIT License
96 stars 13 forks source link

Bug in copy_to #172

Closed odow closed 9 months ago

odow commented 9 months ago

Using the file from https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/11?u=odow

import HiGHS
import MathOptInterface as MOI
model = MOI.FileFormats.MOF.Model()
MOI.read_from_file(model, "/Users/Oscar/Downloads/test.mof.json")
MOI.set(model, MOI.ObjectiveSense(), MOI.FEASIBILITY_SENSE)
h = HiGHS.Optimizer()
MOI.copy_to(h, model)
julia> MOI.optimize!(h)
Presolving model
Presolve: Infeasible

Solving report
  Status            Infeasible
  Primal bound      inf
  Dual bound        -inf
  Gap               inf
  Solution status   -
  Timing            0.00 (total)
                    0.00 (presolve)
                    0.00 (postsolve)
  Nodes             0
  LP iterations     0 (total)
                    0 (strong br.)
                    0 (separation)
                    0 (heuristics)
ERROR:   No invertible representation for getDualRay

But the model is easy to grok that it should be feasible.

odow commented 9 months ago

Rows with 0 >= 0 are being scrambled

julia> import HiGHS

julia> import MathOptInterface as MOI

julia> model = MOI.Utilities.Model{Float64}()
MOIU.Model{Float64}

julia> x = MOI.add_variable(model)
MOI.VariableIndex(1)

julia> g = zero(MOI.ScalarAffineFunction{Float64})
0.0

julia> MOI.add_constraint(model, 2.0 * x, MOI.GreaterThan(0.0))
MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.GreaterThan{Float64}}(1)

julia> MOI.add_constraint(model, g, MOI.GreaterThan(0.0))
MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.GreaterThan{Float64}}(2)

julia> MOI.add_constraint(model, 1.0 * x, MOI.EqualTo(1.0))
MathOptInterface.ConstraintIndex{MathOptInterface.ScalarAffineFunction{Float64}, MathOptInterface.EqualTo{Float64}}(1)

julia> h = HiGHS.Optimizer(); MOI.copy_to(h, model)
Running HiGHS 1.5.3 [date: 1970-01-01, git hash: 45a127b78]
Copyright (c) 2023 HiGHS under MIT licence terms
MathOptInterface.Utilities.IndexMap with 4 entries:
  MOI.VariableIndex(1)                                         => MOI.VariableIndex(1)
  ConstraintIndex{ScalarAffineFunction{Float64}, EqualTo{Floa… => ConstraintIndex{ScalarAffineFunction{Float64}, EqualTo{Float64}}(3)
  ConstraintIndex{ScalarAffineFunction{Float64}, GreaterThan{… => ConstraintIndex{ScalarAffineFunction{Float64}, GreaterThan{Float64}}(2)
  ConstraintIndex{ScalarAffineFunction{Float64}, GreaterThan{… => ConstraintIndex{ScalarAffineFunction{Float64}, GreaterThan{Float64}}(1)

julia> print(h)
Minimize ScalarAffineFunction{Float64}:
 0.0

Subject to:

ScalarAffineFunction{Float64}-in-EqualTo{Float64}
 0.0 == 1.0

ScalarAffineFunction{Float64}-in-GreaterThan{Float64}
 0.0 + 2.0 v[1] >= 0.0
 0.0 + 1.0 v[1] >= 0.0