assigning specific elements to a subset from a set.

Problems with modeling
Post Reply
Alex_Lee
User
User
Posts: 3
Joined: 4 years ago

assigning specific elements to a subset from a set.

Post by Alex_Lee »

Hi there,

This might be a simple question, but I'd like to have some clarification.

Suppose I have a set AllPeriod with its defined elements...

Code: Select all

set
AllPeriod
/2000*2100/
...and the subset is defined as:

Code: Select all

set
Period(AllPeriod)
I know that you can put single elements into the set by

Code: Select all

Period(AllPeriod) = no;
Period("2010") = yes;
Period("2011") = yes;
What I want to do is put the elements 2010 to 2090 into the subset Period without having to manually write:

Code: Select all

Period("2010") = yes;
Period("2011") = yes;
...
Period("2089") = yes
Period("2090") = yes
Is the some simplified way of writing this, for example like Period(/2010*2090/)?

Thanks in advance.
ALe
User
User
Posts: 4
Joined: 6 years ago

Re: assigning specific elements to a subset from a set.

Post by ALe »

One possibility is to filter with ORD expressions (assuming the set AllPeriod is ordered):

Code: Select all

Period(AllPeriod)$((ord(AllPeriod)>10)$(ord(AllPeriod)<card(AllPeriod)-9))=yes;
User avatar
dirkse
Moderator
Moderator
Posts: 215
Joined: 7 years ago
Location: Fairfax, VA

Re: assigning specific elements to a subset from a set.

Post by dirkse »

In you know you will need this subset 2010*2090, you could do

Code: Select all

sets
  AllPeriod /2000*2100/
  Period(AllPeriod)
  xxxPeriod(allPeriod) /2010*2090/
  ;
period(xxxPeriod) = yes;
If the membership of period is static, you could just define the elements in the declaration, like it is for xxxPeriod above. But if you want to make the assignment to period dynamic, it's handy to declare/define something like the xxxPeriod set and use that.

-Steve
Post Reply