[Top][All Lists]
[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
Re: [Help-glpk] problem reading parameters
From: |
glpk xypron |
Subject: |
Re: [Help-glpk] problem reading parameters |
Date: |
Fri, 17 Dec 2010 18:03:45 +0100 |
Hello Christina,
you have two statements, which try to initialize G:
table pa IN "CSV" "pa.csv":PA <- [PA], G, I, c, flag;
table pn IN "CSV" "pn.csv":PN <- [PN], G, I, c, flag;
Change your code to something like:
set P := union(PA, PN);
param G{p in P} := if p in PA then G1[p] else G2[p];
....
table pa IN "CSV" "pa.csv":PA <- [PA], G1, I1, c1, flag1;
table pn IN "CSV" "pn.csv":PN <- [PN], G2, I2, c2, flag2;
or better use a single CSV file with all the data and a column
indicating the day.
Best regards
Xypron
-------- Original-Nachricht --------
> Datum: Fri, 17 Dec 2010 11:21:44 -0500
> Betreff: [Help-glpk] problem reading parameters
> Hi,
>
>
>
> I wrote in recently about having trouble connecting GLPK and excel. I
> have downloaded the latest version of GLPK, restructured my model
> slightly and it is almost working except now I am getting the error :
>
>
>
> G already provided with data
>
> GLPK reads my first table for Pa, the patients admitted the day before
> and then has given me an error when I asked it read the Incoming patient
> table. They are different sets so I'm not sure why this is happening. My
> excel tables are set up as follows:
>
> PA (or PN) G I c flag each in a column and saved as csv files.
>
>
>
> I would appreciate any advice.
>
>
>
> Thank you,
>
>
>
> Christina Cignarale
>
> 4th year Industrial and Systems Engineer
>
> Rochester Institute of Technology
>
>
>
> set PA;
> #the patients admitted the day before
>
> set PN;
> #the incoming patients
>
> set P := PA union PN;
> #set of all patients
>
> set ISOLATION;
> #set of all types of isolation needs
>
> set GENDER;
> #set of Genders
>
>
> set R ;
> #set of all available rooms
>
>
>
> param B {j in R};
>
> param G {i in P} in GENDER ;
>
> param I {i in P} in ISOLATION;
>
> param c {i in P} ;
>
> param y {i in P, j in R} binary, default 0;
>
> param flag {i in P} binary;
>
>
>
>
>
> table pa IN "CSV" "pa.csv":PA <- [PA], G, I, c, flag;
>
>
>
> table pn IN "CSV" "pn.csv":PN <- [PN], G, I, c, flag;
>
>
>
> table iso IN "CSV" "iso.csv":ISOLATION <- [iso];
>
>
>
> table gender IN "CSV" "gender.csv":GENDER <- [gender];
>
>
>
> table rooms IN "CSV" "rooms.csv": R <- [R],B;
>
>
>
> table yparam IN "CSV" "y.csv" : [P, R], y;
>
>
>
> var x {i in P, j in R} binary;
>
> var delta {g in GENDER, j in R: B[j] <> 1} binary;
>
> var gamma {i in ISOLATION, j in R: B[j] <> 1} binary;
>
>
>
>
>
>
>
> minimize PatientMoves: sum {i in PA, j in R} c[i]*(x[i,j]-y[i,j])- sum {
> i in PN,j in R:B[j] <> 0 and B[j] <> 99 and B[j] <>1 } c[i]*x[i,j];
>
>
>
> subject to const1{i in P}: sum {j in R} x[i,j] =1;
>
>
>
>
>
> subject to const2 {i in P, j in R: B[j] <> 0 and B[j] <> 99 and B[j]
> <>1}: x[i,j] <= delta[G[i],j];
>
>
>
> subject to const3 {i in P, j in R: B[j] <> 0 and B[j] <> 99 and B[j]
> <>1}: x[i,j] <= gamma[I[i],j];
>
>
>
>
>
>
> subject to const4{j in R: B[j] <> 0 and B[j] <> 99 and B[j] <>1}: sum {g
> in GENDER} delta[g,j] <=1;
>
>
>
> subject to const5 {j in R: B[j] <> 0 and B[j] <> 99 and B[j] <>1}: sum
> {i in ISOLATION} gamma[i,j] <=1;
>
>
>
> subject to const6 {j in R:B[j] <> 0 and B[j] <> 99 }: sum {i in P}
> x[i,j] <= B[j];
>
>
>
> subject to const7 {i in PA,j in R: B[j]=0}: x[i,j] = 0;
>
> subject to const8 {i in PN,j in R: B[j]= 99 }: x[i,j] =0;
>
>
>
> subject to const9 {i in P, j1 in R: B[j1]=1}:sum {j2 in R: B[j2] = 1 and
> j1 <>j2} x[i,j2]=0;
>
>
>
> subject to const10 {i in P}: sum{j in R: B[j] <> 0 and B[j] <> 99}
> x[i,j] <= 1 - flag[i];
>
>
>
> solve;
>
>
>
> table results {i in P, j in R} OUT "CSV" "RGHresults.csv": i ~ P, j ~ R,
> x[i,j] ;
>
>
>
> end;
>
--
Neu: GMX De-Mail - Einfach wie E-Mail, sicher wie ein Brief!
Jetzt De-Mail-Adresse reservieren: http://portal.gmx.net/de/go/demail