# HiGHS Error: No invertible representation for getDualRay

**URL:** <https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372>\
**Category:** Optimization (Mathematical)\
**Tags:** jump\
**Created:** [July 8, 2023, 10:29pm UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372 "2023-07-08T22:29:23Z")\
**Posts on this page:** 17\
**Page:** 1

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [July 8, 2023, 10:29pm UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/1 "2023-07-08T22:29:24Z")

</div>

I get an error when I try to solve a feasibility problem in JuMP using HiGHS. I use Julia v1.9.1 with the Julia packages JuMP v1.12.0 and HiGHS v1.5.2.

```julia
$ julia JuMP_solve.jl
Running HiGHS 1.5.3 [date: 1970-01-01, git hash: 45a127b78]
Copyright (c) 2023 HiGHS under MIT licence terms
Presolving model
270074 rows, 274684 cols, 1084700 nonzeros
269789 rows, 274399 cols, 1082726 nonzeros
Objective function is integral with scale 1

Solving MIP model with:
   269789 rows
   274399 cols (274398 binary, 1 integer, 0 implied int., 0 continuous)
   1082726 nonzeros

        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% 0 inf inf 0 0 0 0 2.2s

Solving report
  Status Infeasible
  Primal bound inf
  Dual bound inf
  Gap inf
  Solution status -
  Timing 44.02 (total)
                    1.44 (presolve)
                    0.00 (postsolve)
  Nodes 1
  LP iterations 11798 (total)
                    0 (strong br.)
                    0 (separation)
                    0 (heuristics)
ERROR: No invertible representation for getDualRay
 45.992959 seconds (3.86 M allocations: 492.087 MiB, 0.48% gc time, 0.52% compilation time: 27% of which was recompilation)

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 8, 2023, 11:17pm UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/2 "2023-07-08T23:17:10Z")

</div>

Does the Julia code error? I think you can just ignore the printed warning from HiGHS

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [July 8, 2023, 11:48pm UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/3 "2023-07-08T23:48:36Z")

</div>

The Julia code does not error.

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 9, 2023, 2:24am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/4 "2023-07-09T02:24:53Z")

</div>

Then just ignore the print from HiGHS. It just says that it can’t find a dual ray, which is a proof of infeasibility.

---

<div class="post-metadata">

**Author:** ![Stuart\_Rogers](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/stuart_rogers/32/10694_2.png) [@Stuart\_Rogers](https://discourse.julialang.org/u/Stuart_Rogers)\
**Post date:** [July 9, 2023, 2:38am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/5 "2023-07-09T02:38:33Z")

</div>

Should HiGHS’ infeasibility conclusion be trusted?

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [July 9, 2023, 2:45am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/6 "2023-07-09T02:45:28Z")

</div>

> Should HiGHS’ infeasibility conclusion be trusted?

Yes. Otherwise that’s a bug. If you know a feasible solution and you have a reproducible example, please open an issue.

---

<div class="post-metadata">

**Author:** ![rodolforbcoutinho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodolforbcoutinho/32/27067_2.png) [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Post date:** [September 25, 2023, 11:22pm UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/7 "2023-09-25T23:22:36Z")

</div>

Hello everyone!  
I also get this error related to getDualRay. And also my problem should be feasible.

When I set demand = false, the code works fine and find the optimal solution.  
When I set demand =true, JuMP return the Error.  
Matrix P is all positive and its been multiplied by x which is a bool vector to select one of its rows. So all itens in Mx vector should be greater than 0.

Any hint how could I solve this? Thanks in advance!!!

Here is the code:

> Blockquote  
> function JuMP\_MOA(L::BasicLoad; demand::Bool = false)

```
    model = Model()
    set_optimizer(model, () -> MOA.Optimizer(HiGHS.Optimizer))
    set_attribute(model, MOA.Algorithm(), MOA.Hierarchical())

    u = length(L.s)
    @variable(model, x[1:u], Bin)
    @constraint(model,sum(x)==1)

    if demand
        P = Generate_PowerMatrix(L)
        @expression(model, Mx, P*x)
        @constraint(model, [i = 1:288], Mx[i] >= 0)
    end

    @expression(model, Cost_expr, sum(Cost(L,i)*x[i] for i in 1:u) ) #MIN
    @expression(model, Comf_expr, sum(Comf(L,i)*x[i] for i in 1:u) ) #MAX

    @objective(model, Max, [-Cost_expr, Comf_expr])
    optimize!(model)
    if termination_status(model) != OPTIMAL
        @warn("The model was not solved correctly.")
        return
    end
    solution_summary(model)
    
    A = value.(x)
    ix = findfirst(x-> x>0.5 ,A)
    return L.s[ix]
end

```

> Blockquote

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 26, 2023, 12:01am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/8 "2023-09-26T00:01:48Z")

</div>

> ERROR: No invertible representation for getDualRay

This error is just printed by HiGHS. It does not mean that an actual error occurred in JuMP. (HiGHS will stop printing this line in the next release: [HiGHS: Create dual ray when solving QPs · Issue #1350 · ERGO-Code/HiGHS · GitHub](https://github.com/ERGO-Code/HiGHS/issues/1350#issuecomment-1642694671))

> When I set demand =true, JuMP return the Error.

What is the full output? Does Julia throw an error?

---

<div class="post-metadata">

**Author:** ![rodolforbcoutinho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodolforbcoutinho/32/27067_2.png) [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Post date:** [September 26, 2023, 12:11am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/9 "2023-09-26T00:11:09Z")

</div>

Here a copy from terminal output. No errors in Julia at all. Line 145 is related to default Warning.  
How can I ignore this error?

> Blockquote  
> julia\> tmo = SHC.JuMP\_MOA(H[1]; demand = true)  
> Running HiGHS 1.5.1 [date: 1970-01-01, git hash: 93f1876e4]  
> Copyright (c) 2023 HiGHS under MIT licence terms  
> Presolving model  
> Presolve: Infeasible  
> Solving report  
> Status Infeasible  
> Primal bound -inf  
> Dual bound inf  
> Gap 0% (tolerance: 0.01%)  
> Solution status -  
> Timing 0.01 (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  
> ┌ Warning: The model was not solved correctly.  
> └ @ SHC C:\PJL\SHC\src\SHC.jl:145

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 26, 2023, 12:18am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/10 "2023-09-26T00:18:06Z")

</div>

Can you provide a reproducible example?

Instead of `optimize!(model)`, do `write_to_file(model, "test.mof.json")` and then attach the file.

---

<div class="post-metadata">

**Author:** ![rodolforbcoutinho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodolforbcoutinho/32/27067_2.png) [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Post date:** [September 26, 2023, 12:27am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/11 "2023-09-26T00:27:08Z")

</div>

> [@odow](#):
>
> write\_to\_file(model, “test.mof.json”)

Ok, here is the .mof.json file. I just had to add \*.jl to include here.  
I’ll do some cleanup in code and translate the comments to english.

[test.mof.json.jl](https://discourse.julialang.org/uploads/short-url/i1wubDEIrOjHiSjMyG9Xiu3E9es.jl) (292.2 KB)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 26, 2023, 12:39am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/12 "2023-09-26T00:39:58Z")

</div>

I can reproduce. Something weird is going on. Let me take a look.

---

<div class="post-metadata">

**Author:** ![rodolforbcoutinho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodolforbcoutinho/32/27067_2.png) [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Post date:** [September 26, 2023, 12:46am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/13 "2023-09-26T00:46:18Z")

</div>

And here the clean code.  
[SHC\_MAIN.jl](https://discourse.julialang.org/uploads/short-url/e2LhBiIEuEfVwWD0Nx3pJNX3nBr.jl) (9.1 KB)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 26, 2023, 1:17am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/14 "2023-09-26T01:17:01Z")

</div>

I’ve confirmed a bug in HiGHS.jl: [Bug in copy\_to · Issue #172 · jump-dev/HiGHS.jl · GitHub](https://github.com/jump-dev/HiGHS.jl/issues/172)

It’s because you have a lot of rows like `0 >= 0`. Drop all zero rows from your `P` matrix.

---

<div class="post-metadata">

**Author:** ![rodolforbcoutinho](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodolforbcoutinho/32/27067_2.png) [@rodolforbcoutinho](https://discourse.julialang.org/u/rodolforbcoutinho)\
**Post date:** [September 26, 2023, 1:55am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/15 "2023-09-26T01:55:50Z")

</div>

Drop the zeros worked nice! I have also added a function that create an upper bound to this constraint. The working constraint code block is bellow:

```julia
if demand
  P = Generate_PowerMatrix(L)
  R = Generate_DemandPeakRef(L.Δt, 4, 1)
  @expression(model, Mx, P*x)
  #@constraint(model, [i in eachindex(Mx)], Mx[i] <= R[i])
  @expression(model, Mu, unique(Mx))
  @expression(model, Ix, uniqueinds(Mx))
  @constraint(model, [i in eachindex(Mu)], Mu[i] >= 0)
  @constraint(model, [i in eachindex(Mu)], Mu[i] <= R[Ix[i]])
end

```

```julia
uniqueinds(x) = unique(i -> x[i], eachindex(x))

```

The last function is from this discussion: [Is there a function similar to numpy unique with inverse? - #6 by stevengj](https://discourse.julialang.org/t/is-there-a-function-similar-to-numpy-unique-with-inverse/80949/6)

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 26, 2023, 2:04am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/16 "2023-09-26T02:04:38Z")

</div>

I haven’t tested this, but do instead something like

```julia
if demand
    P = Generate_PowerMatrix(L)
    R = Generate_DemandPeakRef(L.Δt, 4, 1)
    for i in 1:size(P, 1)
        if any(!iszero, P[i, :])
            @constraint(model, 0 <= P[i, :]' * x <= R[i])
        end
    end
end

```

---

<div class="post-metadata">

**Author:** ![odow](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/odow/32/28685_2.png) [@odow](https://discourse.julialang.org/u/odow)\
**Post date:** [September 26, 2023, 2:48am UTC](https://discourse.julialang.org/t/highs-error-no-invertible-representation-for-getdualray/101372/17 "2023-09-26T02:48:57Z")

</div>

I fixed the bug in HiGHS, so even the `0 >= 0` model will work once [New version: HiGHS v1.6.1 by JuliaRegistrator · Pull Request #92216 · JuliaRegistries/General · GitHub](https://github.com/JuliaRegistries/General/pull/92216) is merged.
