Getting Real Number Expected Error

Archive of Gamsworld Google Group
Post Reply
Archiver
User
User
Posts: 7876
Joined: 6 years ago

Getting Real Number Expected Error

Post by Archiver » 8 years ago


Hello all,

I am working on a project and want string values as parameters as compared to real numbers but seems like GAMS does not support this.

sets i /may,july,june/
j /UP,MP,HP/
k /Winter,Summer/;

Parameter ProductType(i,j,k)
/may.UP.Winter Grains
july.HP.Summer Rice
/;

So, can anybody please tell me if there is a way to pass string values in a parameter in GAMS.

--
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.

Archiver
User
User
Posts: 7876
Joined: 6 years ago

RE: Getting Real Number Expected Error

Post by Archiver » 8 years ago


Hi Shash



You can add the line



Acronym Grains, Rice;



Before your table and it should compile. But you must think carefully about what you want to do with your parameter before continuing.



Alternative it to use a multidimensional set:



Set G / grain, Rice /

Set ProductType(i,j,k,g)

/may.UP.Winter.Grains

july.HP.Summer.Rice

/;



Good luck



Arne



-------------------------------------------

Arne Stolbjerg Drud

ARKI Consulting & Development A/S

Bagsvaerdvej 246A, DK-2880 Bagsvaerd, Denmark

Phone: (+45) 44 49 03 23, Fax: (+45) 44 49 03 33, email: adrud@arki.dk



From: gamsworld@googlegroups.com [mailto:gamsworld@googlegroups.com] On Behalf Of shash
Sent: Thursday, July 10, 2014 3:00 PM
To: gamsworld@googlegroups.com
Subject: Getting Real Number Expected Error



Hello all,



I am working on a project and want string values as parameters as compared to real numbers but seems like GAMS does not support this.



sets i /may,july,june/

j /UP,MP,HP/

k /Winter,Summer/;



Parameter ProductType(i,j,k)

/may.UP.Winter Grains

july.HP.Summer Rice

/;



So, can anybody please tell me if there is a way to pass string values in a parameter in GAMS.

--
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.

Don
User
User
Posts: 11
Joined: 2 months ago

Re: Getting Real Number Expected Error

Post by Don » 2 months ago

Hi there,

I am trying to replace numbers with EDD below and i keep getting the "Real number expected" error. EDD contains a real number.

"
EDD = ED('2050')/30;

Table BusData(bus,*)
Pd
1 EDD
2 291.12
3 291.12
4 291.12;
"

User avatar
bussieck
Moderator
Moderator
Posts: 933
Joined: 6 years ago

Re: Getting Real Number Expected Error

Post by bussieck » 2 months ago

Understand the difference between GAMS compilation and execution, see https://www.gams.com/latest/docs/UG_Gam ... ll_TwoPass. The data of a table statement is compiled before GAMS executes EDD = ED('2050')/30; So what you try to do makes no sense in a GAMS context. You can assign (execution time) the value EDD at execution time: BusData('1','Pd') = EDD; Just leave the data statement for bus 1 out of the table data.

-Michael

Don
User
User
Posts: 11
Joined: 2 months ago

Re: Getting Real Number Expected Error

Post by Don » 2 months ago

Thank you, Michael.

The plan is to have all busses assigned an EDD value. When EDD changes, all values in the assignment changes, rather than changing values manually.

What I have:

Table BusData(bus,*)
Pd
1 291.12
2 291.12
3 291.12
4 291.12;

What I intend to have:

Table BusData(bus,*)
Pd
1 EDD
2 EDD
3 EDD
4 EDD;

The value for EDD has been precalculated. kindly assist.

Post Reply