Forwarding a macro that returns a variable?

Just make the syntax:

p1 = Player(QuadraticPayoff(0, [2, 1]))
@variable(p1.model, x1 >= 0)

p2 = Player(QuadraticPayoff(0, [1, 2]))
@variable(p2.model, x2 >= 0)
P = [p1, p2]
x_init = find_feasible(P)
x_opt = solve(P)

Defining a new macro is should be a last resort. JuMP uses macros so that we can intercept x >= 0 as bound and constraints instead of comparisons, and so we can build linear expressions more efficiently.

If you tell people “just write p.model, then you can use all of JuMP” it is much simpler than opting into a subset of the JuMP features or defining new macros.

1 Like