Created
September 1, 2014 15:57
-
-
Save philipithomas/93ea4d5fae999d509a46 to your computer and use it in GitHub Desktop.
Failing dictionary keys as variables
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
ERROR: key not found: "x" | |
in getindex at dict.jl:615 | |
in getindex at no file | |
in include at /Applications/Julia-0.3.0.app/Contents/Resources/julia/lib/julia/sys.dylib | |
in include_from_node1 at loading.jl:128 | |
in process_options at /Applications/Julia-0.3.0.app/Contents/Resources/julia/lib/julia/sys.dylib | |
in _start at /Applications/Julia-0.3.0.app/Contents/Resources/julia/lib/julia/sys.dylib (repeats 2 times) | |
while loading /path/to/file/test.jl, in expression starting on line 239 |
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() | |
vars = Dict() | |
# Adding below still does not work | |
# vars["x"] = 0 | |
# vars["y"] = 0 | |
@defVar(m, 0 <= vars["x"] <= 2) | |
@defVar(m, 0 <= vars["y"] <= 30) | |
@setObjective(m, Max, 5* vars["x"] + 3*vars["y"]) | |
@addConstraint(m, 1*vars["x"]+ 5*vars["y"] <= 3.0) | |
print(m) | |
status = solve(m) | |
println("Objective value: ", getObjectiveValue(m)) | |
println("x = ", getValue(vars["x"])) | |
println("y = ", getValue(vars["y"]) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment