Permalink
Browse files

good costflow

  • Loading branch information...
1 parent 4f1caa9 commit df2ccef693a8094daf58c09d8d03ce8e1b1cb480 @ranxian committed Oct 17, 2012
Showing with 15 additions and 13 deletions.
  1. +3 −3 Headers/elevator.h
  2. +4 −3 Makefile
  3. +6 −4 Sources/ascii.cpp
  4. +2 −2 Sources/costflow.cpp
  5. +0 −1 Sources/emulator.cpp
View
@@ -35,8 +35,6 @@ class Elevator
int speed;
- void LetThemMove();
-
void Letout();
void Letin(int cancelCode);
@@ -45,12 +43,14 @@ class Elevator
void CloseDoor();
public:
+ void LetThemMove();
+
Elevator(); /* Constructor */
int Get_pos(); /* Get current position */
int Get_nPassenger(); /* Get current passenger number */
-
+
char Dir(); /* Get current direction. ^: upwards, v: downwards, -: stopping */
void ToggleDoor(); /* Toggle door's status, open if closed, close if opened */
View
@@ -5,8 +5,9 @@ all: ascii
ascii: Sources/ascii.cpp Sources/elevator.cpp Sources/emulator.cpp Sources/fcfs.cpp Sources/passenger.cpp \
Sources/floor.cpp Sources/PoissRand.cpp Headers/controller.h Headers/elevator.h \
- Headers/emulator.h Headers/fcfs.h Headers/floor.h Headers/instruction.h Headers/models.h Headers/internlib.h \
- Headers/passenger.h Headers/PoissRand.h Sources/order.cpp Sources/Print.cpp
+ Headers/emulator.h Headers/floor.h Headers/instruction.h Headers/models.h Headers/internlib.h \
+ Headers/passenger.h Headers/PoissRand.h Sources/order.cpp Sources/Print.cpp Sources/costflow.cpp \
+ Headers/costflow.h
$(CC) $(CFLAGS) $(LIBS) -o ascii Sources/ascii.cpp Sources/elevator.cpp Sources/emulator.cpp Sources/fcfs.cpp Sources/passenger.cpp \
- Sources/floor.cpp Sources/PoissRand.cpp Sources/order.cpp Sources/Print.cpp
+ Sources/floor.cpp Sources/PoissRand.cpp Sources/order.cpp Sources/Print.cpp Sources/costflow.cpp
View
@@ -46,10 +46,12 @@ void Born() {
void Control() {
if (Emulator::elevatorType == "PFCFS") {
Controller::Fcfs();
- } /* else if (Emulator::elevatorType == "costflow") {
- /* Controller::costflow();
- /*
- /* } */
+ } else if (Emulator::elevatorType == "costflow") {
+ Controller::CostFLow();
+ }/* else if (Emulator::elevatorType == "costflow") {
+ * Controller::costflow();
+ *
+ * } */
}
void Move() {
@@ -31,7 +31,7 @@ void addEdge(int a, int b, int f, int c)
int BytheWay(Elevator *ele, Order *order)
{
- if (ele->Get_nPassenger() == Elevator::capacity)
+ if (ele->Get_nPassenger() == Elevator::Get_capacity())
return 0;
if (ele->Dir() == '-' && ele->Get_nPassenger() == 0 && ele->Get_inst()->size() == 0)
return 1;
@@ -99,7 +99,7 @@ void Controller::CostFLow()
flow[path[i]][i] = 0, flow[i][path[i]] = 1;
/* No need to calc the mincost */
}
- printf("%d %d\n", Emulator::orders.size(), tt);
+ printf("%u %u\n", Emulator::orders.size(), tt);
//if (! tt) return;
//memset(toDel, 0, sizeof(toDel));
@@ -1,5 +1,4 @@
#include "../Headers/emulator.h"
-#include "../Headers/fcfs.h"
#include "../Headers/PoissRand.h"
#include "../Headers/internlib.h"
#include "../Headers/controller.h"

0 comments on commit df2ccef

Please sign in to comment.