Reputation: 215
When coding in GAMS and defining my EQUATIONS, I sometimes need to reuse a certain function of the variables. How do I define this function so that I can reuse it, as opposed to having to constantly write it out in my equation definitions?
Upvotes: 2
Views: 301
Reputation: 556
You can use a macro to do this. The syntax is documented here: https://www.gams.com/latest/docs/UG_DollarControlOptions.html#UG_DollarControl_MacrosInGAMS
You could for example define a function 'sqrtsqr'
$macro sqrtsqr(x) sqrt(x*x)
And use it in your equations
my_equation.. sqrtsqr(x) =E= y;
Upvotes: 1