Reputation: 1
Good day, I’m currently using the CPLEX Studio IDE v.22.1.0 for my university project and it’s my first time. I am working on “Reducing Overcrowding in an Emergency Department” by optimizing five (5) hospital resources using a Stochastic Mixed Integer Program. I have successfully written the model but when I run, the decision variables shows “no value”. I would really appreciate some help with a correct version of the model please. Thank you
The model and dat.file is shown below
The Model:
{string} resources = {"Doctors", "Nurses", "Lab Scientists", "Imaging", "Beds"};
int capacity[resources] = [2, 3, 4, 2, 10];
// Defining the Indices for the Time Periods and Queues
//=====================================================
int t = ...;
int q = ...;
range timeperiods = 1..3;
range queues = 1..5;
// Defining the Scenarios
//=======================
range scenarios = 1..3;
// Defining the Arrival Rate of Patients and Service Capacity of Resources
//========================================================================
int arrivalrate[scenarios][timeperiods][queues] = ...;
int servicecapacity[scenarios][timeperiods][queues] = ...;
//Defining the Decision Variables
//===============================
dvar int R[timeperiods][resources];
dvar int W[scenarios][timeperiods][queues];
dvar int S[scenarios][timeperiods][queues];
//Objective
//=========
//Expressions
dexpr int WP = sum (s in scenarios, t in timeperiods, q in queues) W[s][t][q];
dexpr int SP = sum (s in scenarios, t in timeperiods, q in queues) S[s][t][q];
dexpr int NWP = WP - SP;
// Objective Function
//===================
minimize NWP;
//Constraints
//===========
subject to {
//Initialized Number of Patients Waiting in each Queue in each Scenario
//=====================================================================
forall (s in scenarios, t1 in timeperiods, q1, q2, q3, q4, q5, q in queues) {
W[s][t1][q1] == arrivalrate[s][1][q];
W[s][t1][q2] == 0;
W[s][t1][q3] == 0;
W[s][t1][q4] == 0;
W[s][t1][q5] == 0;
S[s][t1][q1] == 0;
S[s][t1][q2] == 0;
S[s][t1][q3] == 0;
S[s][t1][q4] == 0;
S[s][t1][q5] == 0;
}
//Update on the Number of Patients in each Queue at every Period
//==============================================================
forall (s in scenarios, t2, t3 in timeperiods, q1 in queues) {
W[s][t][q1] == W[s][t-1][q1] + arrivalrate[s][t][1] - S[s][t-1][q1];
}
forall (s in scenarios, t2, t3 in timeperiods, q1, q2 in queues) {
W[s][t][q2] == W[s][t-1][q2] + S[s][t-1][q1] - S[s][t-1][q2];
}
forall (s in scenarios, t2, t3 in timeperiods, q1, q3 in queues) {
W[s][t][q3] == W[s][t-1][q3] + S[s][t-1][q1] - S[s][t-1][q3];
}
forall (s in scenarios, t2, t3 in timeperiods, q2, q3, q4 in queues) {
W[s][t][q4] == W[s][t-1][q4] + S[s][t-1][q2] + S[s][t-1][q3] - S[s][t-1][q4];
}
forall (s in scenarios, t2, t3 in timeperiods, q2, q3, q5 in queues) {
W[s][t][q5] == W[s][t-1][q5] + S[s][t-1][q2] + S[s][t-1][q3] - S[s][t-1][q5];
}
// Bounds for Number of Patients Served in a Period
//=================================================
forall (s in scenarios, t in timeperiods, q in queues) {
S[s][t][q] <= W[s][t][q];
}
// Limit for Number of Patients Served in each Queue at each Period
//=================================================================
forall (s in scenarios, t in timeperiods, q1 in queues) {
S[s][t][q1] <= sum (s in scenarios, t in timeperiods, q in queues) servicecapacity[s][t][1] * 1;
}
forall (s in scenarios, t in timeperiods, q2 in queues) {
S[s][t][q2] <= sum (s in scenarios, t in timeperiods, q in queues) servicecapacity[s][t][2] * 1;
}
forall (s in scenarios, t in timeperiods, q3 in queues) {
S[s][t][q3] <= sum (s in scenarios, t in timeperiods, q in queues) servicecapacity[s][t][3] * 1;
}
forall (s in scenarios, t in timeperiods, q4 in queues) {
S[s][t][q4] <= sum (s in scenarios, t in timeperiods, q in queues) servicecapacity[s][t][4] * 1;
}
forall (s in scenarios, t in timeperiods, q5 in queues, r5 in resources) {
S[s][t][q5] <= R[t][r5];
}
//Number of Staffing Hours Available for Each Human Resources (8 hours each)
//==========================================================================
forall (r1 in resources) {
sum (t in timeperiods) R[t][r1] <= 8;
}
forall (r2 in resources) {
sum (t in timeperiods) R[t][r2] <= 8;
}
forall (r3 in resources) {
sum (t in timeperiods) R[t][r3] <= 8;
}
//Availability of atleast One Resource of each Type in each Period
//================================================================
forall (t in timeperiods, r1 in resources) {
R[t][r1] >= 1;
}
forall (t in timeperiods, r2 in resources) {
R[t][r2] >= 1;
}
forall (t in timeperiods, r3 in resources) {
R[t][r3] >= 1;
}
forall (t in timeperiods, r4 in resources) {
R[t][r4] >= 1;
}
forall (t in timeperiods, r5 in resources) {
R[t][r5] >= 1;
}
}
The Data for testing the Model:
t = 3;
q = 5;
arrivalrate = [
[[14,10,95,34,23],
[90,80,60,34,23],
[50,30,20,34,23]],
[[14,13,11,34,23],
[50,30,20,34,23],
[12,31,27,34,23]],
[[14,10,95,34,23],
[90,80,60,34,23],
[50,30,20,34,23]],
];
servicecapacity = [
[[14,10,95,34,23],
[90,80,60,34,23],
[50,30,20,34,23]],
[[14,13,11,34,23],
[50,30,20,34,23],
[12,31,27,34,23]],
[[14,10,95,34,23],
[90,80,60,34,23],
[50,30,20,34,23]],
];
Upvotes: 0
Views: 63
Reputation: 10062
You model is not feasible and that is why you do not get any solution. If you name 2 constraints in order to get some relaxation / conflict
cta:W[s][t1][q1] == arrivalrate[s][1][q];
ctb:W[s][t1][q2] == 0;
Then you get a conflict between cta and ctb
If you comment
//forall (s in scenarios, t1 in timeperiods, q1, q2, q3, q4, q5, q in queues) {
//
//cta:W[s][t1][q1] == arrivalrate[s][1][q];
//
////ctb:W[s][t1][q2] == 0;
//
////ctc:W[s][t1][q3] == 0;
//
////ctd:W[s][t1][q4] == 0;
//
////cte:W[s][t1][q5] == 0;
////
////ctf:S[s][t1][q1] == 0;
////
////ctg:S[s][t1][q2] == 0;
////
////cth:S[s][t1][q3] == 0;
////
////S[s][t1][q4] == 0;
////
////S[s][t1][q5] == 0;
//
//}
//Update on the Number of Patients in each Queue at every Period
//==============================================================
//forall (s in scenarios, t2, t3 in timeperiods, q1 in queues) {
//
//ct2:W[s][t][q1] == W[s][t-1][q1] + arrivalrate[s][t][1] - S[s][t-1][q1];
//
//}
then you will get a feasible solution and adding constraint one by one you can see what is wrong with your constraints
Upvotes: 1