Defining the parameters in GAMS

Hi,
I am trying to define the parameters in GAMS such that these
parameters will be read from a GDX file. I want to indicate that
assings the values for specific parameter where the value is following
two if condition (not null and handle to it is not (a))
I have the same problem indicating the variables. I want to use the
values from GDX where they are following a condition (=null) as the
variables to be estimated.

Thank you

\

Hello

I hope I have understood your problem currently. I assume that you want to LOAD your parameters/variables (as initial value) from a GDX file. Also you want the assignment to happen if a certain condition is met. If so:

Let’s assume that you have a GDX file ready. You can import the data while compiling (using LOAD) or while executing gams file (using Execute_load). More information are provided here. You can further narrow down the assignment using conditional assignment by $.

Please let me know if you need more information.
Regards

محمد صادق تولّلی
Mohammad Sadegh Tavallali
National University of Singapore



On Fri, Jun 17, 2011 at 11:00 PM, Hamideh wrote:

Hi,
I am trying to define the parameters in GAMS such that these
parameters will be read from a GDX file. I want to indicate that
assings the values for specific parameter where the value is following
two if condition (not null and handle to it is not (a))
I have the same problem indicating the variables. I want to use the
values from GDX where they are following a condition (=null) as the
variables to be estimated.

Thank you


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Hi,

Thank you so much for your explanatory information. I have already imported the GDX file and have loaded the data. The problem is I do not know how to use $ function in GAMS to narrow down my search for assigning the right data to my parameters and variables.

Thank you for the website.

Regards,
Hamideh

On Mon, Jun 20, 2011 at 8:40 AM, Tavallali wrote:

Hello

I hope I have understood your problem currently. I assume that you want to LOAD your parameters/variables (as initial value) from a GDX file. Also you want the assignment to happen if a certain condition is met. If so:

Let’s assume that you have a GDX file ready. You can import the data while compiling (using LOAD) or while executing gams file (using Execute_load). More information are provided here. You can further narrow down the assignment using conditional assignment by $.

Please let me know if you need more information.
Regards

محمد صادق تولّلی
Mohammad Sadegh Tavallali
National University of Singapore



On Fri, Jun 17, 2011 at 11:00 PM, Hamideh wrote:

Hi,
I am trying to define the parameters in GAMS such that these
parameters will be read from a GDX file. I want to indicate that
assings the values for specific parameter where the value is following
two if condition (not null and handle to it is not (a))
I have the same problem indicating the variables. I want to use the
values from GDX where they are following a condition (=null) as the
variables to be estimated.

Thank you


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Best regards

Hamideh Etemadnia, Ph.D.
Research Associate
Department of Agricultural Economics and Rural Sociology
Penn State University

—Happiness is neither within us only, or without us; it is the union of
ourselves with God. ~Pascal


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Dear Hamideh

First I suggest that you read $ sign as " SUCH AS…". Therefore in an assignment like :

SET i /1*10/;
PARAMETER A(i);

A(i) $ ( ORD(i) 5 ) = 200;
*A(i) , such that i is more than 5, is 200;

You can find more information HERE.

Now, understanding how $ works, you can execute_load or load your data and narrow down the assignment. An example is given here :

SET i /1*10/;
PARAMETER A(i) , B(i);

execute_load ‘data.gdx’ B(i);

A(i) ( B(i) 10 ) = B(i); *B(i) is already stored in the gdx file. We load that, and then assign them to A(i), however, the assignment is done only for those elements that B(i) is not equal to ten. Remember that the rest of A(i), meaning A(i)( B(i)=10) will remain zero.

I hope it will help. Please do not hesitate to contact me in case of further inquiries.
Regards

محمد صادق تولّلی
Mohammad Sadegh Tavallali
National University of Singapore



On Mon, Jun 20, 2011 at 9:36 PM, Hamideh Etemaadnia wrote:

Hi,

Thank you so much for your explanatory information. I have already imported the GDX file and have loaded the data. The problem is I do not know how to use $ function in GAMS to narrow down my search for assigning the right data to my parameters and variables.

Thank you for the website.

Regards,
Hamideh

On Mon, Jun 20, 2011 at 8:40 AM, Tavallali wrote:

Hello

I hope I have understood your problem currently. I assume that you want to LOAD your parameters/variables (as initial value) from a GDX file. Also you want the assignment to happen if a certain condition is met. If so:

Let’s assume that you have a GDX file ready. You can import the data while compiling (using LOAD) or while executing gams file (using Execute_load). More information are provided here. You can further narrow down the assignment using conditional assignment by $.

Please let me know if you need more information.
Regards

محمد صادق تولّلی
Mohammad Sadegh Tavallali
National University of Singapore



On Fri, Jun 17, 2011 at 11:00 PM, Hamideh wrote:

Hi,
I am trying to define the parameters in GAMS such that these
parameters will be read from a GDX file. I want to indicate that
assings the values for specific parameter where the value is following
two if condition (not null and handle to it is not (a))
I have the same problem indicating the variables. I want to use the
values from GDX where they are following a condition (=null) as the
variables to be estimated.

Thank you


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Best regards

Hamideh Etemadnia, Ph.D.
Research Associate
Department of Agricultural Economics and Rural Sociology
Penn State University

—Happiness is neither within us only, or without us; it is the union of
ourselves with God. ~Pascal


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

Thank you so much.

On Mon, Jun 20, 2011 at 9:26 PM, Tavallali wrote:

Dear Hamideh

First I suggest that you read $ sign as " SUCH AS…". Therefore in an assignment like :

SET i /1*10/;
PARAMETER A(i);

A(i) $ ( ORD(i) 5 ) = 200;
*A(i) , such that i is more than 5, is 200;

You can find more information HERE.

Now, understanding how $ works, you can execute_load or load your data and narrow down the assignment. An example is given here :

SET i /1*10/;
PARAMETER A(i) , B(i);

execute_load ‘data.gdx’ B(i);

A(i) ( B(i) 10 ) = B(i); *B(i) is already stored in the gdx file. We load that, and then assign them to A(i), however, the assignment is done only for those elements that B(i) is not equal to ten. Remember that the rest of A(i), meaning A(i)( B(i)=10) will remain zero.

I hope it will help. Please do not hesitate to contact me in case of further inquiries.
Regards

محمد صادق تولّلی
Mohammad Sadegh Tavallali
National University of Singapore



On Mon, Jun 20, 2011 at 9:36 PM, Hamideh Etemaadnia wrote:

Hi,

Thank you so much for your explanatory information. I have already imported the GDX file and have loaded the data. The problem is I do not know how to use $ function in GAMS to narrow down my search for assigning the right data to my parameters and variables.

Thank you for the website.

Regards,
Hamideh

On Mon, Jun 20, 2011 at 8:40 AM, Tavallali wrote:

Hello

I hope I have understood your problem currently. I assume that you want to LOAD your parameters/variables (as initial value) from a GDX file. Also you want the assignment to happen if a certain condition is met. If so:

Let’s assume that you have a GDX file ready. You can import the data while compiling (using LOAD) or while executing gams file (using Execute_load). More information are provided here. You can further narrow down the assignment using conditional assignment by $.

Please let me know if you need more information.
Regards

محمد صادق تولّلی
Mohammad Sadegh Tavallali
National University of Singapore



On Fri, Jun 17, 2011 at 11:00 PM, Hamideh wrote:

Hi,
I am trying to define the parameters in GAMS such that these
parameters will be read from a GDX file. I want to indicate that
assings the values for specific parameter where the value is following
two if condition (not null and handle to it is not (a))
I have the same problem indicating the variables. I want to use the
values from GDX where they are following a condition (=null) as the
variables to be estimated.

Thank you


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Best regards

Hamideh Etemadnia, Ph.D.
Research Associate
Department of Agricultural Economics and Rural Sociology
Penn State University

—Happiness is neither within us only, or without us; it is the union of
ourselves with God. ~Pascal


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.

\

To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.



\

Best regards

Hamideh Etemadnia, Ph.D.
Research Associate
Department of Agricultural Economics and Rural Sociology
Penn State University

—Happiness is neither within us only, or without us; it is the union of
ourselves with God. ~Pascal


To post to this group, send email to gamsworld@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.