How to define this vector within a function

Hi everyone.

I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

Once I set i, I have T(i), and therefore G(i).

The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn’t even allow us to write G(T(i)). G(T) goes ok, but I need many T’s (i.e. a vector)

Is there a way out?

Thaks for your help.







\

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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Hi,
You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

$setglobal ide “ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1”
$call =gams yourprogram.gms %ide%
$if errorlevel 1 $abort your_model failed
$gdxin yourfilename.gdx

On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

Hi everyone.

I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

Once I set i, I have T(i), and therefore G(i).

The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn’t even allow us to write G(T(i)). G(T) goes ok, but I need many T’s (i.e. a vector)

Is there a way out?

Thaks for your help.







\

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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Tks Omid.

I still don’t see how could I get the variable T(i). It is a variable, not a parameter. On the process of optimization, the variable T(i) should assume changing values until the final conversion. How could the gdx file help?



On Saturday, January 9, 2016 at 12:22:12 PM UTC-2, omid ziaee wrote:

Hi,
You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

$setglobal ide “ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1”
$call =gams yourprogram.gms %ide%
$if errorlevel 1 $abort your_model failed
$gdxin yourfilename.gdx

On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

Hi everyone.

I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

Once I set i, I have T(i), and therefore G(i).

The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn’t even allow us to write G(T(i)). G(T) goes ok, but I need many T’s (i.e. a vector)

Is there a way out?

Thaks for your help.







\

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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Bruno,

I do not understand what you try to do. Since you have not gotten useful answer can you try to be more specific in your question. Can you write this in pseudo code or some other formal language?

Best,
Michael Bussieck - GAMSWorld Coordinator

On Friday, January 15, 2016 at 4:26:22 PM UTC-5, Bruno Hannud wrote:

Tks Omid.

I still don’t see how could I get the variable T(i). It is a variable, not a parameter. On the process of optimization, the variable T(i) should assume changing values until the final conversion. How could the gdx file help?



On Saturday, January 9, 2016 at 12:22:12 PM UTC-2, omid ziaee wrote:

Hi,
You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

$setglobal ide “ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1”
$call =gams yourprogram.gms %ide%
$if errorlevel 1 $abort your_model failed
$gdxin yourfilename.gdx

On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

Hi everyone.

I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

Once I set i, I have T(i), and therefore G(i).

The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn’t even allow us to write G(T(i)). G(T) goes ok, but I need many T’s (i.e. a vector)

Is there a way out?

Thaks for your help.







\

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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Michael, thank you very much for your willingness to help.

I have a polynomial (specific heat capacity, to be exact) which is a function of the temperature. It has different forms for two ranges of temperatures.

For instance, not in gams language, but in algebraic form, it has the form:

Cp(T) = a1Tˆ3 + a2Tˆ2 (for T2000) where a7 and a8 are parameters

The problem I am encountering is that the “a’s” parameters of the Cp polynomial are different for different species (O2, H2, H2O). So, what I did, was create an set “k”, which attributes a different polynomial Cpk, to each species.

I then have

Cp(k, T) = a1kTˆ3 + a2kTˆ2 etc…

Additional to this, I must be able to have different values of the variable T for the polynomial, for instance T(i), where when I use a different value of i, I have a different temperature.

I envisaged using

Cp(k, T(i)), but this is not allowed in GAMS (this is why I used “i” to distinguish the temperatures).

I then used

Cp(k, i) and defined the polynomial as:

Cp(k, i) = a1kT(i)ˆ3 + a2T(i)ˆ2 etc…

The problem with doing this is that when I use Cp in my program, I don’t see how can I recover the variable T(i), since the indices in Cp are “i, k”, not “T(i), k”.

This is why my question asks the question of how to define a vector (T(i)), within a function (Cp(i, T(i)), which is apparently not allowed in GAMS.

Please advise if my problem is clearly presented.

Tks a lot.

Bruno


Sent with Unibox

On Jan 18, 2016, at 1:19 PM, Michael Bussieck wrote:

Bruno,

I do not understand what you try to do. Since you have not gotten useful answer can you try to be more specific in your question. Can you write this in pseudo code or some other formal language?

Best,
Michael Bussieck - GAMSWorld Coordinator

On Friday, January 15, 2016 at 4:26:22 PM UTC-5, Bruno Hannud wrote:

Tks Omid.

I still don't see how could I get the variable T(i). It is a variable, not a parameter. On the process of optimization, the variable T(i) should assume changing values until the final conversion. How could the gdx file help?



On Saturday, January 9, 2016 at 12:22:12 PM UTC-2, omid ziaee wrote:

    Hi,
    You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

    $setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1"
    $call =gams yourprogram.gms %ide%
    $if errorlevel 1 $abort your_model failed
    $gdxin yourfilename.gdx

    On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

        Hi everyone.

        I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

        Once I set i, I have T(i), and therefore G(i).

        The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn't even allow us to write G(T(i)). G(T) goes ok, but I need many T's (i.e. a vector)

        Is there a way out?

        Thaks for your help.


You received this message because you are subscribed to a topic in the Google Groups “gamsworld” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/OqdpzHJgRfI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Bruno,

I might still not fully understand but to me this looks like that $macro does what you want to do. Take a look at the example program:

$macro Cp(k,T) ifthen(T2000) where a7 and a8 are parameters

The problem I am encountering is that the “a’s” parameters of the Cp polynomial are different for different species (O2, H2, H2O). So, what I did, was create an set “k”, which attributes a different polynomial Cpk, to each species.

I then have

Cp(k, T) = a1kTˆ3 + a2kTˆ2 etc…

Additional to this, I must be able to have different values of the variable T for the polynomial, for instance T(i), where when I use a different value of i, I have a different temperature.

I envisaged using

Cp(k, T(i)), but this is not allowed in GAMS (this is why I used “i” to distinguish the temperatures).

I then used

Cp(k, i) and defined the polynomial as:

Cp(k, i) = a1kT(i)ˆ3 + a2T(i)ˆ2 etc…

The problem with doing this is that when I use Cp in my program, I don’t see how can I recover the variable T(i), since the indices in Cp are “i, k”, not “T(i), k”.

This is why my question asks the question of how to define a vector (T(i)), within a function (Cp(i, T(i)), which is apparently not allowed in GAMS.

Please advise if my problem is clearly presented.

Tks a lot.

Bruno


Sent with Unibox

On Jan 18, 2016, at 1:19 PM, Michael Bussieck  wrote:

Bruno,

I do not understand what you try to do. Since you have not gotten useful answer can you try to be more specific in your question. Can you write this in pseudo code or some other formal language?

Best,
Michael Bussieck - GAMSWorld Coordinator

On Friday, January 15, 2016 at 4:26:22 PM UTC-5, Bruno Hannud wrote:

    Tks Omid.

    I still don't see how could I get the variable T(i). It is a variable, not a parameter. On the process of optimization, the variable T(i) should assume changing values until the final conversion. How could the gdx file help?



    On Saturday, January 9, 2016 at 12:22:12 PM UTC-2, omid ziaee wrote:

        Hi,
        You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

        $setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1"
        $call =gams yourprogram.gms %ide%
        $if errorlevel 1 $abort your_model failed
        $gdxin yourfilename.gdx

        On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

            Hi everyone.

            I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

            Once I set i, I have T(i), and therefore G(i).

            The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn't even allow us to write G(T(i)). G(T) goes ok, but I need many T's (i.e. a vector)

            Is there a way out?

            Thaks for your help.








--
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/OqdpzHJgRfI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to <gamsworld+unsubscribe@googlegroups.com>.
To post to this group, send email to <gamsworld@googlegroups.com>.
Visit this group at https://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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Upps, the macro definition should have been without the terminating ‘;’:

$macro Cp(k,T) ifthen(T2000) where a7 and a8 are parameters

The problem I am encountering is that the “a’s” parameters of the Cp polynomial are different for different species (O2, H2, H2O). So, what I did, was create an set “k”, which attributes a different polynomial Cpk, to each species.

I then have

Cp(k, T) = a1kTˆ3 + a2kTˆ2 etc…

Additional to this, I must be able to have different values of the variable T for the polynomial, for instance T(i), where when I use a different value of i, I have a different temperature.

I envisaged using

Cp(k, T(i)), but this is not allowed in GAMS (this is why I used “i” to distinguish the temperatures).

I then used

Cp(k, i) and defined the polynomial as:

Cp(k, i) = a1kT(i)ˆ3 + a2T(i)ˆ2 etc…

The problem with doing this is that when I use Cp in my program, I don’t see how can I recover the variable T(i), since the indices in Cp are “i, k”, not “T(i), k”.

This is why my question asks the question of how to define a vector (T(i)), within a function (Cp(i, T(i)), which is apparently not allowed in GAMS.

Please advise if my problem is clearly presented.

Tks a lot.

Bruno


Sent with Unibox

    On Jan 18, 2016, at 1:19 PM, Michael Bussieck  wrote:

    Bruno,

    I do not understand what you try to do. Since you have not gotten useful answer can you try to be more specific in your question. Can you write this in pseudo code or some other formal language?

    Best,
    Michael Bussieck - GAMSWorld Coordinator

    On Friday, January 15, 2016 at 4:26:22 PM UTC-5, Bruno Hannud wrote:

        Tks Omid.

        I still don't see how could I get the variable T(i). It is a variable, not a parameter. On the process of optimization, the variable T(i) should assume changing values until the final conversion. How could the gdx file help?



        On Saturday, January 9, 2016 at 12:22:12 PM UTC-2, omid ziaee wrote:

            Hi,
            You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

            $setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1"
            $call =gams yourprogram.gms %ide%
            $if errorlevel 1 $abort your_model failed
            $gdxin yourfilename.gdx

            On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

                Hi everyone.

                I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

                Once I set i, I have T(i), and therefore G(i).

                The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn't even allow us to write G(T(i)). G(T) goes ok, but I need many T's (i.e. a vector)

                Is there a way out?

                Thaks for your help.








    --
    You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
    To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/OqdpzHJgRfI/unsubscribe.
    To unsubscribe from this group and all its topics, send an email to <gamsworld+unsubscribe@googlegroups.com>.
    To post to this group, send email to <gamsworld@googlegroups.com>.
    Visit this group at https://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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.

Michael, this seems to do the job!

Many thanks.

Bruno


Sent with Unibox

On Jan 18, 2016, at 3:20 PM, Michael Bussieck wrote:

Bruno,

I might still not fully understand but to me this looks like that $macro does what you want to do. Take a look at the example program:

$macro Cp(k,T) ifthen(T
set i / 15 /, k / O2, H2, H2O /;
Table a(
,k)
O2 H2 H2O
1 1 5 9
2 2 6 10
7 3 7 11
8 4 8 12;

parameter T(i), CpT(i);

T(i) = uniformInt(100,10000);
CpT(i) = Cp(‘H2O’,T(i));
display CpT;
CpT(i) = Cp(‘H2’,T(i));
display CpT;
CpT(i) = Cp(‘O2’,T(i));
display CpT;

You can have T(i) also being a variable and use this inside equation algebra of a model. Hope this goes in the right direction.

Michael Bussieck - GAMSWorld Coordinator

On Monday, January 18, 2016 at 11:03:56 AM UTC-5, Bruno Hannud wrote:

Michael, thank you very much for your willingness to help.

I have a polynomial (specific heat capacity, to be exact) which is a function of the temperature. It has different forms for two ranges of temperatures.

For instance, not in gams language, but in algebraic form, it has the form:

Cp(T) = a1*Tˆ3 + a2*Tˆ2 (for T     Cp(T) = a7*Tˆ3 + a8*Tˆ2 (for T>2000) where a7 and a8 are parameters

The problem I am encountering is that the “a's” parameters of the  Cp polynomial are different for different species (O2, H2, H2O). So, what I did, was create an set “k”, which attributes a different polynomial Cpk, to each species.

I then have

Cp(k, T) = a1k*Tˆ3 + a2k*Tˆ2 etc…

Additional to this, I must be able to have different values of the variable T for the polynomial, for instance T(i), where when I use a different value of i, I have a different temperature.

I envisaged using

Cp(k, T(i)), but this is not allowed in GAMS (this is why I used “i” to distinguish the temperatures).

I then used

Cp(k, i) and defined the polynomial as:

Cp(k, i) = a1k*T(i)ˆ3 + a2*T(i)ˆ2 etc…

The problem with doing this is that when I use Cp in my program, I don’t see how can I recover the variable T(i), since the indices in Cp are “i, k”, not “T(i), k”.

This is why my question asks the question of how to define a vector (T(i)), within a function (Cp(i, T(i)), which is apparently not allowed in GAMS.

Please advise if my problem is clearly presented.

Tks a lot.

Bruno


Sent with Unibox
On Jan 18, 2016, at 1:19 PM, Michael Bussieck  wrote:

Bruno,

I do not understand what you try to do. Since you have not gotten useful answer can you try to be more specific in your question. Can you write this in pseudo code or some other formal language?

Best,
Michael Bussieck - GAMSWorld Coordinator

On Friday, January 15, 2016 at 4:26:22 PM UTC-5, Bruno Hannud wrote:

    Tks Omid.

    I still don't see how could I get the variable T(i). It is a variable, not a parameter. On the process of optimization, the variable T(i) should assume changing values until the final conversion. How could the gdx file help?



    On Saturday, January 9, 2016 at 12:22:12 PM UTC-2, omid ziaee wrote:

        Hi,
        You can use call to run another gams file. Then put the results in a .gdx file and use the results in your program. Look at the following sample code,

        $setglobal ide "ide=%gams.ide% lo=%gams.lo% errorlog=%gams.errorlog% errmsg=1"
        $call =gams yourprogram.gms %ide%
        $if errorlevel 1 $abort your_model failed
        $gdxin yourfilename.gdx

        On Tuesday, January 5, 2016 at 1:49:26 AM UTC-6, Bruno Hannud wrote:

            Hi everyone.

            I have a polynomial G(i) which is a function of a parameter T(i) (eg G(i) = T(i)**3).

            Once I set i, I have T(i), and therefore G(i).

            The problem arises when I want to use T(i) as a variable, to be obtained from another program. GAMS doesn't even allow us to write G(T(i)). G(T) goes ok, but I need many T's (i.e. a vector)

            Is there a way out?

            Thaks for your help.








--
You received this message because you are subscribed to a topic in the Google Groups "gamsworld" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/OqdpzHJgRfI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to <gamsworld+unsubscribe@googlegroups.com>.
To post to this group, send email to <gamsworld@googlegroups.com>.
Visit this group at https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.


You received this message because you are subscribed to a topic in the Google Groups “gamsworld” group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/gamsworld/OqdpzHJgRfI/unsubscribe.
To unsubscribe from this group and all its topics, send an email to gamsworld+unsubscribe@googlegroups.com.
To post to this group, send email to gamsworld@googlegroups.com.
Visit this group at https://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 https://groups.google.com/group/gamsworld.
For more options, visit https://groups.google.com/d/optout.