-
Notifications
You must be signed in to change notification settings - Fork 0
/
Simulate.h
46 lines (34 loc) · 996 Bytes
/
Simulate.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
#ifndef SIMULATE_H
#define SIMULATE_H
#define MAX_CAPACITY 8
#define WAIT_TIME 1
#define FLOOR_TIME 3
#include<stdio.h>
#include<stdlib.h>
#include "Lift.h"
//declaration of a state data structure.
//VARIABLE EXPLANATION:-
// lift_no:
// time:
// floor:
// direction:
// dst:
// num_people:
// place_time[10000]:
typedef struct State_{
int lift_no;
int time;
int floor;
int direction; //1 when moving up -1 when moving down and 0 otherwise
int * dst; //Represents how many people want to go to each floor
int num_people;
float place_time[10000];
} State;
State * State_new(int curr_floor, int num_floors, int time, int dir, int lift_num);
void State_delete(State * st);
void GoTo(int begin, int end, State * st, pqueue ** qf, int floor, int reserve);
void Pickup(int floor, State * st, pqueue ** qf);
void Drop(int begin, int end, State * st, pqueue ** qf, int floor);
void Simulate(pqueue ** qf, pqueue * mq, int num_floors);
float CalculateMeanTime(pqueue * mq);
#endif