I have included the main parts of the code below.

Basically I have 2 binary variables ms(s) and mp(s), that determine

the outcome of some variables ( Rq and Nq) in specified equations.

My optimal solution is not based on one of (Rq or Nq) if it was, then

it would be easy (for instance maximize Rq) ,but is based on an

equation which uses Nq and Rq,

the result of this equation is mttfTest (below) which I am trying to

maximize (math. formula as follows):

mttfTest = sum{Nq * (Rq** Nq)*(1-Rq)};*

problem is I cannot express this easily if I could exchange the number

1861640 (used to create the set below) with Nq

then I have solved it (as the runtime value of Nq actually equals

1861640) . Alternatively, if I could take the Nq value

and somehow calculate [ mttfTest = sum{Nq * (Rq** Nq)(1-Rq)}; ]

directly without using a set, then again, I would solve the problem.

Any input would be greatly appreciated (if somebody knows how to do

this using other tools please kindly point me in that direction).

Thanks,

Hamid

----------------------- Code ------------------------------

Variables

ms(s)

mp(s)

Rq

Eq

Nq

mttfTest ;

Binary variable ms(s);

Binary variable mp(s);

Equations eEq

eRq

eRqConstraint

eNq

eDisjoint

eMttf ;

eEq… Eq =e= sum(s, ep(s)*mp(s)) + sum(s, es(s)*ms(s)) +

ech;

eRq… Rq =e= (1 - prod(s, (1 - ms(s) + qfs(s)*ms(s)) )) * (1

- prod(s, (1 - mp(s) + qfp(s)*mp(s)) ));

eRqConstraint… rreq =l= Rq;

eNq… Nq =e= ceil(hq*eo*n/(hq*Eq + Ec/Tc));

SET J / 1 * 1861640/;

eMttf… mttfTest =e= sum{J, ord(J) * (Rq** ord(J))*(1-

Rq)};

eDisjoint… 0 =e= sum(s, mp(s)*ms(s));

mp.l(s) = 1;

ms.l(s) = 1;

Model energyCost /all/;

Solve energyCost using minlp maximize mttfTest;

option decimals=8;

display ms.l, mp.l, Eq.l, Rq.l, Nq.l, mttfTest.l;

----------------------- END Code ------------------------------

On Oct 18, 3:19 am, babak saleckpay wrote:

Hi

as i know,it’s impossible to define dynamic sets like this in gams.

i suggest using *set as refrence set and after your variable gets value,use

“$” or “If” statement for your subsate domain wherever you need it.

of course,i don’t know what you exactly want to do,can you explain more.

On Sun, Oct 17, 2010 at 3:16 PM, Hamid wrote:

Thank you for your reply, that doesn’t work:

- SET i / 1 * Nq/; , gets error "Could not extract number in
- list"

basically the Nq variable that I use to create the set is not found

until the Solver is run as it is in the equation eNq… , if I try to

do it manually (by other means …), then it works, for instance

if I know that Nq is going to be 1861640, and I use that manually:

SET i / 1 * 1861640/;

Then everything after that works. Any ideas on how I could use the Nq

value to define the SET i

in my situation?

On Sep 21, 3:58 pm, “.::Morteza Shabanzadeh::.”

wrote:

Hi Hamid,

Follow these rules:

************************************** GAMS code

Set i /1*Np/;

Variables

Rq

Nq

mttf

;

Equations

eRq

eNq

emttf

;

eRq… Rq = e= … ;

eNq… Nq =e= … ;

emttf… mttf =e= sum(i, ( i * (Rq ** i) * (1 -Rq) ) ) ;

Model hamid /all/;

Solve hamid using dnlp minimizing mttf;

Display mttf.l

Best regards

Morteza. Sh

On Tue, Sep 21, 2010 at 9:31 PM, Hamid wrote:

Hi all,

I am new to GAMS and to optimization in general, and I am having

difficulty in modeling my problem in GAMS, I have the following:

Equations eRq

eNq

emttf;

## eRq… Rq =

eNq… Nq =

emttf… mttf = sum [ from i = 1 to Nq , i * (Rq ** i) * (1 -

Rq) ] //this is pseudo code, I don’t know how to do this

in other words, i * (Rq ** i) * (1 - Rq) is performed for index i

which takes on values from 1 to Nq, and all results are summed.

I want to maximize mttf, how can I do this? notice that the value Nq

(upper bound of index i) used to find mttf, is in equation eNq

Any help would be appreciated

–

You received this message because you are subscribed to the Google

Groups

“gamsworld” group.

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.

–

.::Morteza.Sh::.

–

“gamsworld” group.

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.

–

Babak Saleck Pay

Group of Industrial Engineering

M.Sc

Operations Research

University of Tehran

Tehran,Iran

\