Created
July 2, 2017 01:16
-
-
Save joaquimg/71b658948848ed7d7fab4ab7fc70e078 to your computer and use it in GitHub Desktop.
JuMP query example
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
using JuMP | |
m = Model() | |
# Variables section | |
@variable(m, x[1:10] >= 0) | |
@variable(m, y[1:10] >= 0) | |
@variable(m, z >= 0) | |
# Constraints section | |
# <= | |
@constraint(m, sum(x[i] for i in 1:10) + z <= 48) | |
# >= | |
@constraint(m, -1(sum(y[i] for i in 1:10 if isodd(i) && i <= 5) + z) <= 17) | |
# igualdade | |
for i in 1:3 | |
@constraint(m, y[i] -z <= 0) | |
@constraint(m, -y[i] +z <= 0) | |
end | |
@objective(m, Min, 3x[6] + sum(y[i] for i in 2:4 if iseven(i)) - 876z) | |
c = JuMP.prepAffObjective(m) | |
b_lb, b_ub = JuMP.prepConstrBounds(m) | |
# b_lb, b_ub pode sem +-Inf | |
A = JuMP.prepConstrMatrix(m) | |
# A is sparse, for dense Adense = full(A) | |
var_lb = copy(m.colLower) | |
var_ub = copy(m.colUpper) | |
# JuMP standard form | |
# min c'*x | |
# s.t. | |
# b_lb <= Ax <= b_ub | |
# var_lb <= x <= var_ub |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment