# I added 1 Million constraints to an LP unwittingly

**URL:** <https://discourse.julialang.org/t/i-added-1-million-constraints-to-an-lp-unwittingly/127668>\
**Category:** Optimization (Mathematical)\
**Tags:** question, jump, examples, gurobi, experience\
**Created:** [April 3, 2025, 11:12am UTC](https://discourse.julialang.org/t/i-added-1-million-constraints-to-an-lp-unwittingly/127668 "2025-04-03T11:12:09Z")\
**Posts on this page:** 1\
**Showing post:** 7

<div class="post-metadata">

**Author:** ![WalterMadelim](https://avatars.discourse-cdn.com/v4/letter/w/3e96dc/32.png) [@WalterMadelim](https://discourse.julialang.org/u/WalterMadelim)\
**Post date:** [April 3, 2025, 11:11pm UTC](https://discourse.julialang.org/t/i-added-1-million-constraints-to-an-lp-unwittingly/127668/7 "2025-04-03T23:11:43Z")

</div>

Here is one more question. I have 2 vectors: `r`, `c` and one _asymmetric_ matrix `X`.  
`r` is a `101-element SparseArrays.SparseVector{Float64, Int64} with 101 stored entries:`  
`c` is a `170-element SparseArrays.SparseVector{Float64, Int64} with 3 stored entries:`  
`X` is a `101×170 Matrix{JuMP.AffExpr}:`  
I now need to write the constraint `@constraint(model, r' * X * c >= 0)`,  
Which style should I choose, to **maximize the performance** (assume I need to add 1 million of this type of constraint, assume `101` and `170` both increase)

1. `@constraint(model, transpose(r) * X * c >= 0)`
2. `@constraint(model, transpose(r) * (X * c) >= 0)`
3. `@constraint(model, dot(r, X, c) >= 0)`
4. `@constraint(model, tr(c * transpose(r) * X) >= 0)`
5. `@constraint(model, sm(r * transpose(c), X) >= 0)`, where `sm` is [here](https://discourse.julialang.org/t/inner-product-grammar-is-neater-than-sum-index-in-jump-modeling-but-triggers-warning/124528/28).
6. should I use `transpose()` or `'` (adjoint)?

And this list can be enlarged because there are many equivalent forms.

---

_[View the full topic](https://discourse.julialang.org/t/i-added-1-million-constraints-to-an-lp-unwittingly/127668)._
