Page 1 of 1

trigonometric functions

Posted: Tue Jan 06, 2015 7:33 pm
by Archiver

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=∑ Vi*Vj*(Gij*cos(Oi-Oj)+Bij*sin(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.

Re: trigonometric functions

Posted: Tue Jan 06, 2015 10:21 pm
by Archiver

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=∑ Vi*Vj*(Gij*cos(Oi-Oj)+Bij*sin(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.

Re: trigonometric functions

Posted: Wed Jan 07, 2015 3:39 am
by Archiver

For Power Flow Equation best internet resource for GAMS is

https://www.princeton.edu/~rvdb/ampl/nl ... 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=∑ Vi*Vj*(Gij*cos(Oi-Oj)+Bij*sin(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.

Re: trigonometric functions

Posted: Thu Feb 27, 2020 1:11 pm
by Alexanre.ito
Hi, I was studding in how to implement trigonometric functions.

I founded this site, about Extrinsic Functions.
https://www.gams.com/latest/docs/UG_Ext ... aryExample

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/ ... lib01.html C
https://www.gams.com/latest/testlib_ml/ ... lib02.html Delphi
https://www.gams.com/latest/testlib_ml/ ... lib03.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:

Code: Select all

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

Code: Select all

$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

Re: trigonometric functions

Posted: Fri Feb 28, 2020 1:18 pm
by Manassaldi
GAMS supports trigonometric functions.
What are the functions you have problems with?
Extrinsic functions are to implements your own functions.

Best

Re: trigonometric functions

Posted: Tue Mar 10, 2020 5:48 pm
by Alexanre.ito
Manassaldi wrote: 4 years ago 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:

Code: Select all

* 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)":

Code: Select all

* 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 :

Code: Select all

Solve network using MINLP minimizing cost
Best

Re: trigonometric functions

Posted: Tue Mar 10, 2020 7:44 pm
by Manassaldi
That is not a GAMS valid sentence. Maybe you are confused in the way "GAMS" works. I think i can't help you
Best

Re: trigonometric functions

Posted: Wed Mar 11, 2020 7:46 am
by Renger
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

Re: trigonometric functions

Posted: Wed Mar 11, 2020 10:06 pm
by Alexanre.ito
Renger wrote: 4 years ago 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