What you have seems to work. I created variables (all forced to 1 just to
display something interesting)
set I;
param J {i in I }>0, integer ;
set K {i in I }:=1..J[i];
var V{i in I, j in K[i]}, =1;
minimize SumOfV : sum{i in I, j in K[i]} V[i,j];
solve;
display V;
data;
param : I : J :=
1 1
2 1
3 2
4 2
5 3 ;
end;
When I ran this, the “display” statement produced
V[1,1].val = 1
V[2,1].val = 1
V[3,1].val = 1
V[3,2].val = 1
V[4,1].val = 1
V[4,2].val = 1
V[5,1].val = 1
V[5,2].val = 1
V[5,3].val = 1
Which meets your specifications.
From: [email protected]
[mailto:[email protected]] On Behalf Of
esma mehiaoui
Sent: Tuesday, June 16, 2015 7:46 AM
To: GLPK Help List
Subject: [Help-glpk] Modelisation of a subset
Hello Everyone,
I need to express a set of elements for each element in a set. I had a syntax
errors with the following formulation :
.MOD
set I := 1..5;
param J {i in I }>0, integer ;
set K {i in I }:=1..J[i];
.DATA
param J :=
1 1
2 1
3 2
4 2
5 3 ;
My objective is to define the variables V{i in I, j in K[i] }= {V[1,1];
V[2,1]; V[3,1]; V[3,2] ;V[4,1]; V[4,2]; V[5,1] ;V[5,2]; V[5,3]}
Do you have any idea how to do this ?
Best regards
Esma
________________________________
This e-mail and any attachments may be confidential or legally privileged. If
you received this message in error or are not the intended recipient, you
should destroy the e-mail message and any attachments or copies, and you are
prohibited from retaining, distributing, disclosing or using any information
contained herein. Please inform us of the erroneous delivery by return e-mail.
Thank you for your cooperation.
_______________________________________________
Help-glpk mailing list
[email protected]
https://lists.gnu.org/mailman/listinfo/help-glpk