Calling a polynomial from an include file

Hello everyone.

I need help in the following: I have a polinomial in an include file with a variable.

On my main program, there are two variables which need to call the polynomial on the include file.

Can this be done?

Many tks.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Bruno,

It sounds like a macro would serve you well. There is a little example below. You could define the macro in an include file if that’s helpful.

There are other ways to define functions or share commonly used code (e.g. the $batinclude facility, or extrinsic functions) but those aren’t as simple as the macro.

-Steve

$ontext
Example: using a macro to define a polynomial
$offtext

$macro mypoly(x) (0.5 * power(x,3) + 1.25 * power(x,2) + 4 * (x) + 6)

variables x, y;
equations f, g;

f… mypoly(x) =E= 10;
g… mypoly(y) =E= 20;

model m / f, g /;
solve m using mcp;

On Wed, Sep 23, 2015 at 5:05 PM, Bruno Hannud wrote:

Hello everyone.

I need help in the following: I have a polinomial in an include file with a variable.

On my main program, there are two variables which need to call the polynomial on the include file.

Can this be done?

Many tks.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdirkse@gams.com
http://www.gams.com

Tks a lot Steven.

Bruno

On Thursday, September 24, 2015 at 11:42:30 AM UTC-3, Steven Dirkse wrote:

Bruno,

It sounds like a macro would serve you well. There is a little example below. You could define the macro in an include file if that’s helpful.

There are other ways to define functions or share commonly used code (e.g. the $batinclude facility, or extrinsic functions) but those aren’t as simple as the macro.

-Steve

$ontext
Example: using a macro to define a polynomial
$offtext

$macro mypoly(x) (0.5 * power(x,3) + 1.25 * power(x,2) + 4 * (x) + 6)

variables x, y;
equations f, g;

f… mypoly(x) =E= 10;
g… mypoly(y) =E= 20;

model m / f, g /;
solve m using mcp;

On Wed, Sep 23, 2015 at 5:05 PM, Bruno Hannud wrote:

Hello everyone.

I need help in the following: I have a polinomial in an include file with a variable.

On my main program, there are two variables which need to call the polynomial on the include file.

Can this be done?

Many tks.


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+...@googlegroups.com.
To post to this group, send email to gams...@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.



\

Steven Dirkse, Ph.D.
GAMS Development Corp., Washington DC
Voice: (202)342-0180 Fax: (202)342-0181
sdi...@gams.com
http://www.gams.com


To unsubscribe from this group and stop receiving emails from it, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at http://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.