Skip to content

Instantly share code, notes, and snippets.

@Ph0non
Created November 3, 2015 13:00
Show Gist options
  • Save Ph0non/58a6cc76502d98405458 to your computer and use it in GitHub Desktop.
Save Ph0non/58a6cc76502d98405458 to your computer and use it in GitHub Desktop.
using JuMP
using Cbc
m=Model(solver = CbcSolver());
@defVar(m, 0 <= x[1:7] <= 10000, Int);
@setObjective(m, :Min, -x[1] -x[2] );
@addConstraint(m, sum(x) == 10000); # <-- so looks the macro normally used
i = "Ni63 >= 60"
y = parse(i)
y.args[1] = :(x[[3]])
y.args[3] *= 10000
eval(Expr(:macrocall,symbol("@addConstraint"),esc(m),esc(y))) # <-- how to modify the macro itself with an expression?
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment