using the variable to control the index

26 views
Skip to first unread message

YouYaxiong

unread,
May 24, 2012, 9:21:55 AM5/24/12
to gamsworld
hello,everyone
i want to use a variable to control the index just like in C
language,for example
integer variable s(i,j);
parameter e_t(j)

e_t(j+s(i,j)) is what i want
but there always be a error

or e_t(j)$( ord(j)=s(i,j) ) is also wrong


i really need to use this expression,can anyone help me ,thanks very
much

Your sincerely
You Yaxiong

A.R. Bahari

unread,
May 24, 2012, 10:09:39 AM5/24/12
to gams...@googlegroups.com
Hi
I think you don't able to use it during the solve process. After the program is resolved, you will be able to use it as follows
e_t(j)$(  ord(j)=s.L(i,j)  )


--
You received this message because you are subscribed to the Google Groups "gamsworld" group.
To post to this group, send email to gams...@googlegroups.com.
To unsubscribe from this group, send email to gamsworld+...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/gamsworld?hl=en.


Arne Stolbjerg Drud

unread,
May 24, 2012, 11:24:17 AM5/24/12
to gams...@googlegroups.com
Hi You Yaxiong

It is not possible to do this directly. You can think about this way: you have a MIP or MINLP model and in order to solve it you need to be able to solve a relaxed model, i.e. a model in which s is continuous. What does e_t(j+2.5) mean? Or in another way, depending on where you are in your solution process you suddenly have a model with a different set of variables. We do not have algorithms that can handle this.

The trick is usually to have a set that represent the possible value of s, e.g.

set sb / 0*15 /;

and a binary variable that tells you which of these values have been chosen, plus a copy of your e_t variable with an extra sb index:

binary variable y(i,j,sb);
positive variable e_tb(i,j,sb)

plus an upper bound on e_t (safe but not too large -- the following is a big-M formulation)

parameter e_tmax(j) / values .../;

You then have the relationship

Equation ydef(i,j); ydef(i,j) .. s(i,j) =E= sum(sb, ord(sb)*y(i,j,sb) );
Equation et_def1(i,j); et_def1(j).. e_t(i,j) =E= sum(sb, e_tb(i,j,sb));
Equation et_def2(i,j,sb); et_def2(j) .. e_tb(i,j,sb) =L= e_tmax(j)*y(i,j,sb);

You can then use e_tb(i,j,sb) instead of e_t(j-s(i,j)).

This is a lot of machinery and meant as an initial inspiration. If you work with your own model you should be able to reduce it to something simpler. But it will never be simple.

Regards

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: ad...@arki.dk
Reply all
Reply to author
Forward
0 new messages