Implementation

กก

In cpp file, the key part is the Schedule() function, as Figure 6 shows:

void Schedule(void)
{
    //assign nurse
    for(int i=0;i<nurse_no;i++)
    {
        while(nurse[i].serve_no<max_no) //1 round
        {
            if(served_no==patient_no)return;

            int minH=2000;
            int select=-1;

            //select patient
            for(int j=0;j<patient_no;j++)
            {
                if(CanServe(nurse[i],patient[j]))
                {
                    if(H(nurse[i],patient[j])<minH)
                    {
                        minH=H(nurse[i],patient[j]);
                        select=j;
                    }
                }
            }

            if(select>=0)
            {
                //select one patient
                patient[select].served=1;
                nurse[i].serve_no++;
                UpdateSchedule(nurse[i],patient[select]);
                nurse[i].current_time=minH;
                nurse[i].current_location.x=patient[select].location.x;
                nurse[i].current_location.y=patient[select].location.y;
            }
            else
            {
                //change another nurse
                nurse[i].final_schedule.slot[nurse[i].final_schedule.slot_no].FillSlot

                    (REST,nurse[i].current_time,DAY_END_TIME,

                        nurse[i].current_location,nurse[i].home);
                nurse[i].final_schedule.slot_no++;
                break;
            }
        }
    }
}

            Figure 6: Schedule() function