how to make a set a subset of another set

1,911 views
Skip to first unread message

ursula challita

unread,
Oct 24, 2012, 11:53:46 AM10/24/12
to ai...@googlegroups.com
Hello,
 
I have a model in which I have 2 sets: Scenario:t and users:k. and a parameter: numberofusers(t).
 
In the definition of the set users, i have: elementrange(1,numberofusers(t));
 
I am getting the error:" the mandatory attribute "subse of" is missing from indexed set "users"".
 
How to resolve this probelm?
 
Thanks you,
Ursula

Guido Diepen

unread,
Oct 25, 2012, 11:35:44 AM10/25/12
to ai...@googlegroups.com
Hi Ursula,

If you give a set an index domain, it means you will end up with a so-called indexed subset. One of the requirements for an indexed subset in AIMMS is that you fill in the "subset of" attribute. After you this, for each element of the index domain, a separate subset of the given Root Set will exist.

Without filling in the subset of attribute, you would end up in the situation in which you can't access the elements anymore, because it would require a 'double indexing'. Because it is a subset, you can use the in operator (e.g.  someIndex in SomeIndexedSubSet(i) ).

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Oct 29, 2012, 6:22:09 AM10/29/12
to ai...@googlegroups.com
Hi Guido,
 
I put in the "subset of" attribute of the "users set" the 'scenario set'. However, I am still getting the following error: "The scope of index "t" has not been specified".
Any suggestions?
 
Thank you.
 
Regards,
Ursula

Ursula Challita

unread,
Oct 30, 2012, 10:46:05 AM10/30/12
to ai...@googlegroups.com
How an I solve this error?
Thanks.
--
 
 

Guido Diepen

unread,
Oct 30, 2012, 10:58:19 AM10/30/12
to ai...@googlegroups.com
Hi Ursula,

The problem is that you cannot just use the index t there, as it still refers to 'all elements of the set'. So if t is not in the index domain of the identifier you are using t in, you must either ensure it is bound via an operator like sum, min, max, etc or you will get an error from AIMMS telling you that the index is not bound yet (and therefore does not point to a specific element, but still to all elements).

Guido Diepen
AIMMS Specialist

Ursula Challita

unread,
Oct 30, 2012, 12:20:18 PM10/30/12
to ai...@googlegroups.com
How can I solve it then?
I want to generate a specific number of elements for each element of the subset.

Thanks.


--
 
 

ursula challita

unread,
Nov 1, 2012, 4:56:26 PM11/1/12
to ai...@googlegroups.com
Hi Guido,
 
I did not get your idea. Is there another approach of solving it? Any other suggestions to solve this problem.
Thanks for the help.
 
Regards,
Ursula

Guido Diepen

unread,
Nov 2, 2012, 3:47:21 AM11/2/12
to ai...@googlegroups.com
Hi Ursula,

From your original message it is not 100% clear to me what you want to achieve.

You have a set Scenarios (with index t) and a set Users (with index k).

From the definition, it appears you want to achieve something like a set of users per scenario t. Is this indeed what you want to achieve?

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Nov 2, 2012, 4:18:46 AM11/2/12
to ai...@googlegroups.com
Hi Guido,
 
Indeed this is what I want.
 
In other words, the elements in set users is not fixed, it varies from one scenario to another and  the number of elements for every scenario is specified by a parameter: numberofusers(t).
 
Thanks for the help.
Ursula

On Wednesday, October 24, 2012 6:53:46 PM UTC+3, ursula challita wrote:

Guido Diepen

unread,
Nov 2, 2012, 4:52:54 AM11/2/12
to ai...@googlegroups.com
Hi Ursula,

In order to this, you will have to create a new set AllUsers. Your current set users will have to become a subset of this set AllUsers. 

Note that you cannot give an indexed subset its own index in AIMMS, so therefore you will have to make it a subset. This way, you can later on use a construct like 
k in Users(t)

In your case, you could could create the following identifiers:
SET:
   identifier :  Scenario
   index      :  t

SET:
   identifier   :  Users
   index domain :  t
   subset of    :  AllUsers
   definition   :  elementRange(1, NumberOfUsers(t))

SET:
   identifier :  AllUsers
   index      :  k
   definition :  elementrange(1, max(t, NumberOfUsers(t)) )

PARAMETER:
   identifier   :  NumberOfUsers
   index domain :  t


Guido Diepen
AIMMS Specialist

ursula challita

unread,
Nov 2, 2012, 5:34:54 PM11/2/12
to ai...@googlegroups.com
Hi Guido,
 
I want to note that in my original problem, the set Users had an index k and the set scenarios had an index t.
Would this affect other variables in my problem?
 
I am still getting the following error:
"The index "k" does not denote a subset of the undeclared identifier "~Users"."
 
How can I solve it?
 
Thanks a lot,
Ursula
 

On Wednesday, October 24, 2012 6:53:46 PM UTC+3, ursula challita wrote:

ursula challita

unread,
Nov 5, 2012, 4:55:04 AM11/5/12
to ai...@googlegroups.com
Any suggestions?
 
Thanks.

On Wednesday, October 24, 2012 6:53:46 PM UTC+3, ursula challita wrote:

Guido Diepen

unread,
Nov 5, 2012, 6:00:26 AM11/5/12
to ai...@googlegroups.com
Hi Ursula,

you will first have to remove the index k from the original set users, then create the new set AllUsers with index k, then add the index t to the index domain of the set Users and add the Subset of "AllUsers" to the set Users.

After that, at any place where you are using the index k in an index domain, you will also have to know which particular scenario t you are considering and use a domain condition like "k in Users(t)".

For some more information about using indexed sets in AIMMS, please see the section "Indexed Sets" in the AIMMS Language Reference.

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Nov 7, 2012, 4:20:54 PM11/7/12
to ai...@googlegroups.com
Hi Guido,
 
It worked out!
 
Thanks a lot for the help :)
 
Ursula

Guido Diepen

unread,
Nov 7, 2012, 4:22:10 PM11/7/12
to ai...@googlegroups.com
Hi Ursula,

thanks for the update! Great to hear that you got it to work!

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Nov 10, 2012, 5:15:08 PM11/10/12
to ai...@googlegroups.com
Hi Guido,
 
Unfortunately, I am still getting some errors. When the number of users is the same, I have no error. However, when the number is different for each scenario, the I get the following errors:
"The '01' is not allowed to be an element of Users(1)."
and
"The empty row const_4(1) .. 0 >= 93.1 is infeasible."
 
Moreover, I wanted to ask one more thing:
for the summation over the set k, how can I specify that k now depends on it. That is,

sum(k,sum(i,s(i,k,t)))) >= ((1-beta) *N_users(t))

should become

sum(k | k in Users(t),sum(i,s(i,k,t)))) >= ((1-beta) *N_users(t))??

Thanks in advance,

Ursula

Guido Diepen

unread,
Nov 12, 2012, 3:09:41 AM11/12/12
to ai...@googlegroups.com
Hi Ursula,

The second statement:
sum(k | k in Users(t),sum(i,s(i,k,t)))) >= ((1-beta) *N_users(t))

should do the trick: this only considers those k that are in the indexed subset Users(t) for the given t.

The error appears to be the result of the left-hand-side being completely empty (i.e. there are no variables at all). Did you verify that the set users contains data? Also, does the variable s have any domain condition such that it is not generated considered for these combinations of indices?

Guido Diepen
AIMMS Specialist

ursula challita

unread,
Nov 12, 2012, 3:35:04 AM11/12/12
to ai...@googlegroups.com
Hi Guido,
 
Indeed this is what I want. I want the summation to loop over the number of users in Users(t) for every t.
 
I can not see whetehr the set of users has data since I am not being able to run it due to the errors.
 
The index domain for s is:

(i,k,t)|k in users(t)

 

I am wondering why when the number of users is the same, I have no error. However, errors appear when the number is different for each scenario.

 

Thanks Guido!

Ursula

Guido Diepen

unread,
Nov 12, 2012, 3:48:40 AM11/12/12
to ai...@googlegroups.com
Hi Ursula,

can you also check the data of the set Users(t). You can do this by opening the attributes of this set and press the data button. My guess would be at the moment, that this indexed subset is somehow empty for some t. 

Guido Diepen
AIMMS Specialist

Ursula

unread,
Nov 12, 2012, 5:03:14 AM11/12/12
to ai...@googlegroups.com
Hi Guido,

Indeed it is empty!

Ursula
--
 
 

Ursula

unread,
Nov 14, 2012, 6:02:54 PM11/14/12
to ai...@googlegroups.com
What can I do to solve this problem?



On Nov 12, 2012, at 10:48 AM, Guido Diepen <Guido....@aimms.com> wrote:

--
 
 

Guido Diepen

unread,
Nov 15, 2012, 3:00:30 AM11/15/12
to ai...@googlegroups.com
Hi Ursula,

Do the sets users and allusers have any definition? In one of my earlier replies, I provided an example for a possible definition for both sets based on the function ElementRange.

Guido Diepen
AIMMS Specialist

Ursula

unread,
Nov 15, 2012, 3:53:11 AM11/15/12
to ai...@googlegroups.com
Yeah. This is what I put in the definition of users and allusers.

--
 
 

Guido Diepen

unread,
Nov 15, 2012, 4:23:53 AM11/15/12
to ai...@googlegroups.com
Are all sets empty (i.e. the root set AllUsers and the indexed set Users for all k), or are there just some sets empty?

Guido Diepen
AIMMS Specialist

Ursula

unread,
Nov 15, 2012, 4:47:38 AM11/15/12
to ai...@googlegroups.com
Thr set allusers has elements while the set users is empty. The error is " the '01' is not allowed to be an element of users(1)".

Ursula
--
 
 

Guido Diepen

unread,
Nov 15, 2012, 5:07:36 AM11/15/12
to ai...@googlegroups.com
Hi,

that appears to be something that is caused by the autofill (i.e. make all elements the same size).

You have two options. Since you are working with numbers, you could make the set AllUsers a subset of the predefined set Integers. Another possible solution is that you use an additional argument in the ElementRange function, namely:
fill: 0

which you can use as follows for example in the set users:
elementRange(1, NumberOfUsers(t), fill:0)

Note that you will have to add this fill to the elementrange function in both the rootset AllUsers as well as the subset Users.

Guido Diepen
AIMMS Specialist

Ursula

unread,
Nov 15, 2012, 5:21:19 AM11/15/12
to ai...@googlegroups.com
I really needed those results and it worked out:)
Very much thankful!

Ursula

--
 
 

Guido Diepen

unread,
Nov 15, 2012, 5:29:37 AM11/15/12
to ai...@googlegroups.com
Hi Ursula,

great to hear that the problem is solved!

Guido Diepen
AIMMS Specialist.
Reply all
Reply to author
Forward
Message has been deleted
0 new messages