RE: next question - find some element of a set

"Meketon, Marc" via "Users list for GLPK \(GNU Linear Programming Kit\)" <[email protected]>
Newsgroups gmane.comp.gnu.glpk
Message-ID <DM6PR11MB2651771AD636D9B10CE244E492550@DM6PR11MB2651.namprd11.prod.outlook.com>
Here is more clarification.  I have a set  S  and an array  cost[].  I wanted to get a cost -- any cost -- that is found in the array  cost.  I didn't want to have to specify in the data section a sample element of  S, I just wanted to use GMPL to find one.  In the example below, I want to find  SOME_ELEMENT_IN_S  as an index to the array  cost[].

set S;
param cost{S};

param some_valid_cost := cost[SOME_ELEMENT_IN_S];

data;
param : S : cost :=
 A 100
 B 105
 C 198
;

-----Original Message-----
From: Help-glpk <[email protected]> On Behalf Of Mate Hegyhati
Sent: Thursday, December 12, 2019 2:29 AM
To: [email protected]
Subject: Re: next question - find some element of a set

Hi!

I'm not exactly sure, what you would like to do, but you could just say, but maybe this answers your question:

set sports;
param  favorite symbolic in sports;

var train{sports} >=0;

s.t. foobar: train[favorite] >=2;

minimize work: sum{f in sports} train[f];

data;

set sports := running cycling swimming;
param favorite := 'running';

end;


So put ' around the name for a symbolic parameter, and also don't put comma between set elements.

I hope this helped. If not, please clarify your situation.

All the best,

Mate


> set := A, B, C;
>
> param some_element_in_set, symbolic := ?????;
>
> The closest I saw was in this old help-glpk email:
> https://lists.gnu.org/archive/html/help-glpk/2006-11/msg00059.html
>
> Which says:
>
> set S;
>
> param ref{i in 1..card(S)}, symbolic, in S;
>
> # ref[i] refers to i-th element of S;
>
> param a{S};
>
> ... a[ref[i]]   ...  # means a[i-th element of S]
>
> But I cannot get this to work.  If I could get it to work, then I
> would do something like: param some_element_in_set := ref[1];
>
> BTW, I’m still hoping that someone will help solve how to work the
> sudoku_excel.mod example in the ‘examples\sql’ directory of the GLPK
> directory under Windows 10 64bit.  I still cannot get that to work.
>
> -Marc
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.