trigonometric functions

Hi friends, I have some problems in programming some equations in gams, I am new using gams and I don’t have very clear how to program equation with trigonometric functions.

One of the equations that I am having problems with is this:

P=∑ ViVj(Gijcos(Oi-Oj)+Bijsin(Oi-Oj))

j=1

The tutorial says that gams Currently have no support for other functions, including the trigonometric functions cos(x),sin(x), etc.


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.

GAMS does support the math functions you have identified. Go to the McCarl’s guide and search on functions and select Other Mathematical functions and you will see a broad list of supported math functions. You can calculate these values using gams outside of an optimization model, however if you are using the equation inside the optimization you will need a non linear solver.

When we have problems of these types we usually calculate these equations in the pre-model for all possible combinations and then write an optimization to select the values that either minimize or maximize the objective function. Then you can use a traditional solver which is always a lot faster than a non linear solver approach.

Regards,
John


On Tue, Jan 6, 2015 at 11:33 AM, asier bernardo mugarra flores wrote:

Hi friends, I have some problems in programming some equations in gams, I am new using gams and I don’t have very clear how to program equation with trigonometric functions.

One of the equations that I am having problems with is this:

P=∑ ViVj(Gijcos(Oi-Oj)+Bijsin(Oi-Oj))

j=1

The tutorial says that gams Currently have no support for other functions, including the trigonometric functions cos(x),sin(x), etc.


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.

\

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.

For Power Flow Equation best internet resource for GAMS is

https://www.princeton.edu/~rvdb/ampl/nlmodels/power/index.html

best regards

Abraham

On Tue, Jan 6, 2015 at 9:33 PM, asier bernardo mugarra flores wrote:

Hi friends, I have some problems in programming some equations in gams, I am new using gams and I don’t have very clear how to program equation with trigonometric functions.

One of the equations that I am having problems with is this:

P=∑ ViVj(Gijcos(Oi-Oj)+Bijsin(Oi-Oj))

j=1

The tutorial says that gams Currently have no support for other functions, including the trigonometric functions cos(x),sin(x), etc.


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.

\

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.

Hi, I was studding in how to implement trigonometric functions.

I founded this site, about Extrinsic Functions.
https://www.gams.com/latest/docs/UG_ExtrinsicFunctions.html#UG_ExtrinsicFunctions_BuildYourOwn-TrigonometricLibraryExample

I need to use the angle with radian unit. So at GAMS website they suggest to use Function Libraries, an example, trilib01.gms , trilib02.gms and trilib03.gms .
https://www.gams.com/latest/testlib_ml/libhtml/testlib_trilib01.html C
https://www.gams.com/latest/testlib_ml/libhtml/testlib_trilib02.html Delphi
https://www.gams.com/latest/testlib_ml/libhtml/testlib_trilib03.html Fortran

But how I suppose to use this examples in my mproblem.

Is just save in my folder, or a specific folder?

What the difference of using:

Function <InternalFuncName> /<InternalLibName>.<FuncName>/;

or

$ifThen set nocomp
*  Use precompiled library provided by testlib
$  batinclude precomp.inc tricclib
$else
*  Compile library from source code
$  batinclude compilec.inc tri
$endIf

function myCos        / myLib.Cosine /
         mySin        / myLib.Sine   /
         myPi         / myLib.Pi     /;

??

Tnks

GAMS supports trigonometric functions.
What are the functions you have problems with?
Extrinsic functions are to implements your own functions.

Best

My problems is with this equation:

* Diameter for each tube with flow
 dred(a)..   dr(a)    =e= vcPower((abc1(a)*man*qr(a)/sqrt(ir(a))),(3/8));
 eq1(a)..    abc1(a) =e= vcPower(3.0844*theta(a),(1/4))/abc2(a);
 eq2(a)..    abc2(a) =e= vcPower((theta(a) - sin(theta(a))),(5/8));

That return a Error:
Error at line …: division by zero (0)

than I tried to insert a condition “$(theta(a) gt 0)”:

* Diameter for each tube with flow
 dred(a)..   dr(a)                            =e= vcPower((abc1(a)*man*qr(a)/sqrt(ir(a))),(3/8));
 eq1(a)..    abc1(a)$(theta(a) gt 0)  =e= vcPower(3.0844*theta(a),(1/4))/abc2(a);
 eq2(a)..    abc2(a)$(theta(a) gt 0)  =e= vcPower((theta(a) - sin(theta(a))),(5/8));

(theta in radians)
this code not work even of I used “$(qn(a) gt 0)” to indicate if the tube have flow or not.

a error appear:
Endogenous $ operation not allowed

I’m using :

Solve network using MINLP minimizing cost

Best

That is not a GAMS valid sentence. Maybe you are confused in the way “GAMS” works. I think i can’t help you
Best

Hi
This might be resolved by setting a starting value that is not equal to zero. If you don’t set a starting value for your variables, Gams assumes zero.
You could for example set THETA.L = 1;
Cheers
Renger

Yes! this help with this problems.
Thanks