Hi all,

I am currently working on my thesis and was needing to know how to separate elements of a set.

eg.

forall(j in 1..n) do

ab(1,j):= EBOM(3) - EBOM(1)

end-do

ab(1,j) = {"K2","K5"}

In this example, how would I "CALL" K2 from ab(1,j)?

I want to use it for further processing

eg.

I want

A(1,1) = K2

Any help will really be appreciated. I am still a beginner with Xpress.

Thanks.

The 'substr' function can be used on a string to separate it into several parts, I would not recommend its use in the present case.

You can enumerate set elements with standard loops like 'forall', for example, for some given index 'j' you can write:

forall(i in ab(1,j)) writeln(i)

Please note that it is not possible to address a specific set element since Mosel sets are not ordered (exception: 'range' sets).

If you require the ordering property for other programming tasks, it would probably be better to work with 'list' objects:

declarations

n=5

R=1..n

mylist: array(R) of list of string

ab: array(1..1,R) of set of string

end-declarations

! For simplicity's sake, look at one particular index of 'ab':

j:=3

ab(1,j):= {"K2","K5"}

mylist(j):= sum(i in ab(1,j)) [i]

writeln("List generated from set: ", mylist(j))

writeln("First list element: ", getfirst(mylist(j)))

! Enumerate the list elements

forall(i in mylist(j)) writeln(i)

However, looking at the original example, it might even be more suitable to create an array from the set, eg:

! Copy set into an array

forall(i in ab(1,j), ct as counter) myarray(ct):= i

writeln(myarray)