Skip to content

Commit 6281a6a

Browse files
committed
Fixed problem with memory allocation of new arrivals when using the RelocSimulation class.
1 parent 08fa8b6 commit 6281a6a

1 file changed

Lines changed: 10 additions & 7 deletions

File tree

RelSys/RelocSimulation.cpp

Lines changed: 10 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -56,8 +56,8 @@ RelocSimulation::~RelocSimulation() {
5656
void RelocSimulation::initializeSystem(){
5757
calculateArrivalRates();
5858

59-
//pre-allocate memory for services
60-
//nextArrival.resize(1);
59+
//pre-allocate memory for services and arrivals
60+
nextArrival = new Customer(0.0,0.0,0,0);
6161
maxOcc = 0;
6262
for (int widx=0; widx<nWards; widx++){
6363
maxOcc += getWardCapacity(widx);
@@ -170,12 +170,15 @@ void RelocSimulation::generateArrival(){
170170
}
171171
}
172172

173-
//create
174-
nextArrival = new Customer(nextArrivalTime[min_widx][min_pidx],
175-
genServiceTime(min_pidx),min_widx,min_pidx);
176-
updateArrivalTime(min_widx,min_pidx);
177-
173+
//create new patient arrival
174+
nextArrival->arrivalClock = nextArrivalTime[min_widx][min_pidx];
175+
nextArrival->serviceTime = genServiceTime(min_pidx);
176+
nextArrival->patientType = min_pidx;
177+
nextArrival->wardTarget = min_widx;
178+
nextArrival->active = true;
179+
nextArrival->serviceClock = numeric_limits<double>::max();
178180

181+
updateArrivalTime(min_widx,min_pidx);
179182

180183
}
181184

0 commit comments

Comments
 (0)