添加了读取指定配置文件的功能
添加了官方的测试用例
This commit is contained in:
parent
8a70c8255d
commit
fa13a63fd0
|
@ -7,4 +7,9 @@ include_directories(include)
|
|||
aux_source_directory("../src/" SRCS)
|
||||
aux_source_directory("${CMAKE_CURRENT_SOURCE_DIR}/src" ALL_TEST_SRCS)
|
||||
|
||||
add_executable(bus_all_test ${SRCS} ${ALL_TEST_SRCS} main.c)
|
||||
add_executable(bus_all_test ${SRCS} ${ALL_TEST_SRCS} main.c)
|
||||
|
||||
add_custom_command(TARGET bus_all_test POST_BUILD
|
||||
COMMAND ${CMAKE_COMMAND} -E copy_if_different
|
||||
"${CMAKE_CURRENT_SOURCE_DIR}/test_cases/"
|
||||
$<TARGET_FILE_DIR:bus_all_test>)
|
|
@ -7,12 +7,18 @@
|
|||
#include "stdio.h"
|
||||
#include "string.h"
|
||||
#include "define.h"
|
||||
#include "rail.h"
|
||||
#include "controller.h"
|
||||
|
||||
void ChooseTestCaseInput(char *path, int index);
|
||||
|
||||
void ChooseTestCaseOutput(char *path, int index);
|
||||
|
||||
rail_node_t *ChooseConfigFile(int index);
|
||||
|
||||
void ReadOutputFile(char *result, FILE *f);
|
||||
|
||||
int CheckOutput(char *program_output, char *read_output);
|
||||
|
||||
rail_node_t *ReadChosenConfigFile(char *config_file_path);
|
||||
#endif //AUTO_PILOT_BUS_TOOLS_H
|
||||
|
|
|
@ -41,7 +41,7 @@ int main()
|
|||
output_file = fopen(path, "r");
|
||||
|
||||
// 读取配置文件
|
||||
rails = ReadConfigFile();
|
||||
rails = ChooseConfigFile(index);
|
||||
|
||||
// 制造公交车
|
||||
the_bus = &main_bus;
|
||||
|
|
|
@ -57,4 +57,128 @@ int CheckOutput(char *program_output, char *read_output)
|
|||
{
|
||||
return BUS_FAlSE;
|
||||
}
|
||||
}
|
||||
|
||||
rail_node_t *ChooseConfigFile(int index)
|
||||
{
|
||||
char root_path[] = "./test_cases/";
|
||||
char config_path[] = "/dict.dic";
|
||||
char case_path[3];
|
||||
|
||||
sprintf(case_path, "%d", index);
|
||||
|
||||
char file_path[30];
|
||||
|
||||
strcat(file_path, root_path);
|
||||
strcat(file_path, case_path);
|
||||
strcat(file_path, config_path);
|
||||
|
||||
return ReadChosenConfigFile(file_path);
|
||||
}
|
||||
|
||||
rail_node_t *ReadChosenConfigFile(char *config_file_path)
|
||||
{
|
||||
FILE *config_file = NULL;
|
||||
char buffer[30];
|
||||
int total_station = 0;
|
||||
int distance = 0;
|
||||
|
||||
config_file = fopen(config_file_path, "r");
|
||||
|
||||
// 循环读取文件的每一行
|
||||
while (fgets(buffer, sizeof buffer, config_file) != NULL)
|
||||
{
|
||||
char first_char = buffer[0];
|
||||
char *p;
|
||||
|
||||
switch (first_char)
|
||||
{
|
||||
case '#':
|
||||
// 如果读取到#什么都不做
|
||||
break;
|
||||
case 'T':
|
||||
// TOTAL_STATION
|
||||
p = buffer;
|
||||
|
||||
// 把数字前面的所有字符全部干掉
|
||||
while (*p < '0' || *p > '9')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
if (*p == '1' && *(p + 1) != '\n')
|
||||
{
|
||||
total_station = 10;
|
||||
}
|
||||
else if (*(p + 1) == '\n')
|
||||
{
|
||||
total_station = *p - 48;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'S':
|
||||
// STRATEGY
|
||||
p = buffer;
|
||||
// 将=前的字符全部略去
|
||||
while (*p != '=')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
// =也去掉
|
||||
p++;
|
||||
// =和策略之间的空格也去掉
|
||||
while (*p == ' ')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
if (*p == 'F' && *(p + 1) == 'C') //FCFS
|
||||
{
|
||||
chosen_strategy = BUS_FCFS;
|
||||
}
|
||||
else if (*p == 'S' && *(p + 1) == 'S') //SSTF
|
||||
{
|
||||
chosen_strategy = BUS_SSTF;
|
||||
}
|
||||
else if (*p == 'S' && *(p + 1) == 'C') //SCAN
|
||||
{
|
||||
chosen_strategy = BUS_SCAN;
|
||||
}
|
||||
else
|
||||
{
|
||||
// 读取失败
|
||||
chosen_strategy = -1;
|
||||
}
|
||||
|
||||
break;
|
||||
case 'D':
|
||||
// DISTANCE
|
||||
p = buffer;
|
||||
|
||||
// 把数字前面的所有字符全部干掉
|
||||
while (*p < '0' || *p > '9')
|
||||
{
|
||||
p++;
|
||||
}
|
||||
|
||||
if (*(p + 1) == '\n')
|
||||
{
|
||||
distance = *p - 48;
|
||||
}
|
||||
|
||||
break;
|
||||
default:
|
||||
continue;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (distance != 0 && total_station != 0)
|
||||
{
|
||||
return CreateRails(distance, total_station);
|
||||
}
|
||||
else
|
||||
{
|
||||
return NULL;
|
||||
}
|
||||
}
|
3
all_test/test_cases/1/dict.dic
Normal file
3
all_test/test_cases/1/dict.dic
Normal file
|
@ -0,0 +1,3 @@
|
|||
TOTAL_STATION = 10
|
||||
STRATEGY = FCFS
|
||||
DISTANCE = 3
|
4
all_test/test_cases/2/dict.dic
Normal file
4
all_test/test_cases/2/dict.dic
Normal file
|
@ -0,0 +1,4 @@
|
|||
# first come first serve
|
||||
STRATEGY = FCFS
|
||||
TOTAL_STATION = 10
|
||||
DISTANCE = 2
|
30
all_test/test_cases/2/input.txt
Normal file
30
all_test/test_cases/2/input.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
clock
|
||||
clockwise 2
|
||||
clock
|
||||
clockwise 4
|
||||
clock
|
||||
clock
|
||||
clockwise 6
|
||||
clock
|
||||
target 8
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 10
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
end
|
176
all_test/test_cases/2/output.txt
Normal file
176
all_test/test_cases/2/output.txt
Normal file
|
@ -0,0 +1,176 @@
|
|||
TIME:0
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:1
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:2
|
||||
BUS:
|
||||
position:1
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0100000000
|
||||
counterclockwise:0000000000
|
||||
TIME:3
|
||||
BUS:
|
||||
position:2
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0101000000
|
||||
counterclockwise:0000000000
|
||||
TIME:4
|
||||
BUS:
|
||||
position:2
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0001000000
|
||||
counterclockwise:0000000000
|
||||
TIME:5
|
||||
BUS:
|
||||
position:3
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0001010000
|
||||
counterclockwise:0000000000
|
||||
TIME:6
|
||||
BUS:
|
||||
position:4
|
||||
target:0000000100
|
||||
STATION:
|
||||
clockwise:0001010000
|
||||
counterclockwise:0000000000
|
||||
TIME:7
|
||||
BUS:
|
||||
position:5
|
||||
target:0000000100
|
||||
STATION:
|
||||
clockwise:0001010000
|
||||
counterclockwise:0000000000
|
||||
TIME:8
|
||||
BUS:
|
||||
position:6
|
||||
target:0000000100
|
||||
STATION:
|
||||
clockwise:0001010000
|
||||
counterclockwise:0000000000
|
||||
TIME:9
|
||||
BUS:
|
||||
position:6
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000010000
|
||||
counterclockwise:0000000000
|
||||
TIME:10
|
||||
BUS:
|
||||
position:7
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000010000
|
||||
counterclockwise:0000000000
|
||||
TIME:11
|
||||
BUS:
|
||||
position:8
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000010000
|
||||
counterclockwise:0000000000
|
||||
TIME:12
|
||||
BUS:
|
||||
position:9
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000010000
|
||||
counterclockwise:0000000000
|
||||
TIME:13
|
||||
BUS:
|
||||
position:10
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000010000
|
||||
counterclockwise:0000000000
|
||||
TIME:14
|
||||
BUS:
|
||||
position:10
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:15
|
||||
BUS:
|
||||
position:11
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:16
|
||||
BUS:
|
||||
position:12
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:17
|
||||
BUS:
|
||||
position:13
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:18
|
||||
BUS:
|
||||
position:14
|
||||
target:0000000101
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:19
|
||||
BUS:
|
||||
position:14
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:20
|
||||
BUS:
|
||||
position:15
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:21
|
||||
BUS:
|
||||
position:16
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:22
|
||||
BUS:
|
||||
position:17
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:23
|
||||
BUS:
|
||||
position:18
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:24
|
||||
BUS:
|
||||
position:18
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
end
|
4
all_test/test_cases/3/dict.dic
Normal file
4
all_test/test_cases/3/dict.dic
Normal file
|
@ -0,0 +1,4 @@
|
|||
# first come first serve
|
||||
STRATEGY = FCFS
|
||||
TOTAL_STATION = 10
|
||||
DISTANCE = 2
|
30
all_test/test_cases/3/input.txt
Normal file
30
all_test/test_cases/3/input.txt
Normal file
|
@ -0,0 +1,30 @@
|
|||
clock
|
||||
clockwise 2
|
||||
clock
|
||||
target 10
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clockwise 3
|
||||
clock
|
||||
clock
|
||||
target 9
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
end
|
183
all_test/test_cases/3/output.txt
Normal file
183
all_test/test_cases/3/output.txt
Normal file
|
@ -0,0 +1,183 @@
|
|||
TIME:0
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:1
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:2
|
||||
BUS:
|
||||
position:1
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0100000000
|
||||
counterclockwise:0000000000
|
||||
TIME:3
|
||||
BUS:
|
||||
position:2
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0100000000
|
||||
counterclockwise:0000000000
|
||||
TIME:4
|
||||
BUS:
|
||||
position:2
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:5
|
||||
BUS:
|
||||
position:1
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:6
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:7
|
||||
BUS:
|
||||
position:19
|
||||
target:0000000001
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:8
|
||||
BUS:
|
||||
position:18
|
||||
target:0000000011
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:9
|
||||
BUS:
|
||||
position:18
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:10
|
||||
BUS:
|
||||
position:19
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:11
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:12
|
||||
BUS:
|
||||
position:1
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:13
|
||||
BUS:
|
||||
position:2
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:14
|
||||
BUS:
|
||||
position:3
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:15
|
||||
BUS:
|
||||
position:4
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0010000000
|
||||
counterclockwise:0000000000
|
||||
TIME:16
|
||||
BUS:
|
||||
position:4
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:17
|
||||
BUS:
|
||||
position:3
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:18
|
||||
BUS:
|
||||
position:2
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:19
|
||||
BUS:
|
||||
position:1
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:20
|
||||
BUS:
|
||||
position:0
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:21
|
||||
BUS:
|
||||
position:19
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:22
|
||||
BUS:
|
||||
position:18
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:23
|
||||
BUS:
|
||||
position:17
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:24
|
||||
BUS:
|
||||
position:16
|
||||
target:0000000010
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
TIME:25
|
||||
BUS:
|
||||
position:16
|
||||
target:0000000000
|
||||
STATION:
|
||||
clockwise:0000000000
|
||||
counterclockwise:0000000000
|
||||
end
|
4
all_test/test_cases/4/dict.dic
Normal file
4
all_test/test_cases/4/dict.dic
Normal file
|
@ -0,0 +1,4 @@
|
|||
DISTANCE = 4
|
||||
STRATEGY = SCAN
|
||||
TOTAL_STATION = 6
|
||||
# scan serve
|
34
all_test/test_cases/4/input.txt
Normal file
34
all_test/test_cases/4/input.txt
Normal file
|
@ -0,0 +1,34 @@
|
|||
clock
|
||||
clockwise 2
|
||||
clock
|
||||
clock
|
||||
counterclockwise 6
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 1
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
counterclockwise 5
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
end
|
211
all_test/test_cases/4/output.txt
Normal file
211
all_test/test_cases/4/output.txt
Normal file
|
@ -0,0 +1,211 @@
|
|||
TIME:0
|
||||
BUS:
|
||||
position:0
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:1
|
||||
BUS:
|
||||
position:0
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:2
|
||||
BUS:
|
||||
position:1
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:000000
|
||||
TIME:3
|
||||
BUS:
|
||||
position:2
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:000000
|
||||
TIME:4
|
||||
BUS:
|
||||
position:3
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:000001
|
||||
TIME:5
|
||||
BUS:
|
||||
position:4
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:000001
|
||||
TIME:6
|
||||
BUS:
|
||||
position:4
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:7
|
||||
BUS:
|
||||
position:3
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:8
|
||||
BUS:
|
||||
position:2
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:9
|
||||
BUS:
|
||||
position:1
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:10
|
||||
BUS:
|
||||
position:0
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:11
|
||||
BUS:
|
||||
position:23
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:12
|
||||
BUS:
|
||||
position:22
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:13
|
||||
BUS:
|
||||
position:21
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:14
|
||||
BUS:
|
||||
position:20
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000001
|
||||
TIME:15
|
||||
BUS:
|
||||
position:20
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:16
|
||||
BUS:
|
||||
position:21
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:17
|
||||
BUS:
|
||||
position:22
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:18
|
||||
BUS:
|
||||
position:23
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:19
|
||||
BUS:
|
||||
position:0
|
||||
target:100000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:20
|
||||
BUS:
|
||||
position:0
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:21
|
||||
BUS:
|
||||
position:23
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:22
|
||||
BUS:
|
||||
position:22
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:23
|
||||
BUS:
|
||||
position:21
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:24
|
||||
BUS:
|
||||
position:20
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:25
|
||||
BUS:
|
||||
position:19
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:26
|
||||
BUS:
|
||||
position:18
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:27
|
||||
BUS:
|
||||
position:17
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:28
|
||||
BUS:
|
||||
position:16
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000010
|
||||
TIME:29
|
||||
BUS:
|
||||
position:16
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
end
|
4
all_test/test_cases/5/dict.dic
Normal file
4
all_test/test_cases/5/dict.dic
Normal file
|
@ -0,0 +1,4 @@
|
|||
DISTANCE = 4
|
||||
STRATEGY = SCAN
|
||||
TOTAL_STATION = 6
|
||||
# scan serve
|
26
all_test/test_cases/5/input.txt
Normal file
26
all_test/test_cases/5/input.txt
Normal file
|
@ -0,0 +1,26 @@
|
|||
clock
|
||||
clockwise 2
|
||||
counterclockwise 3
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 4
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clockwise 5
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
end
|
155
all_test/test_cases/5/output.txt
Normal file
155
all_test/test_cases/5/output.txt
Normal file
|
@ -0,0 +1,155 @@
|
|||
TIME:0
|
||||
BUS:
|
||||
position:0
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:1
|
||||
BUS:
|
||||
position:0
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:2
|
||||
BUS:
|
||||
position:1
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:001000
|
||||
TIME:3
|
||||
BUS:
|
||||
position:2
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:001000
|
||||
TIME:4
|
||||
BUS:
|
||||
position:3
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:001000
|
||||
TIME:5
|
||||
BUS:
|
||||
position:4
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:010000
|
||||
counterclockwise:001000
|
||||
TIME:6
|
||||
BUS:
|
||||
position:4
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:001000
|
||||
TIME:7
|
||||
BUS:
|
||||
position:5
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:001000
|
||||
TIME:8
|
||||
BUS:
|
||||
position:6
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:001000
|
||||
TIME:9
|
||||
BUS:
|
||||
position:7
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:001000
|
||||
TIME:10
|
||||
BUS:
|
||||
position:8
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:001000
|
||||
TIME:11
|
||||
BUS:
|
||||
position:8
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:12
|
||||
BUS:
|
||||
position:9
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:13
|
||||
BUS:
|
||||
position:10
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
TIME:14
|
||||
BUS:
|
||||
position:11
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:15
|
||||
BUS:
|
||||
position:12
|
||||
target:000100
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:16
|
||||
BUS:
|
||||
position:12
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:17
|
||||
BUS:
|
||||
position:13
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:18
|
||||
BUS:
|
||||
position:14
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:19
|
||||
BUS:
|
||||
position:15
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:20
|
||||
BUS:
|
||||
position:16
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000010
|
||||
counterclockwise:000000
|
||||
TIME:21
|
||||
BUS:
|
||||
position:16
|
||||
target:000000
|
||||
STATION:
|
||||
clockwise:000000
|
||||
counterclockwise:000000
|
||||
end
|
4
all_test/test_cases/6/dict.dic
Normal file
4
all_test/test_cases/6/dict.dic
Normal file
|
@ -0,0 +1,4 @@
|
|||
TOTAL_STATION = 5
|
||||
DISTANCE = 3
|
||||
# shortest seek time first
|
||||
STRATEGY = SSTF
|
47
all_test/test_cases/6/input.txt
Normal file
47
all_test/test_cases/6/input.txt
Normal file
|
@ -0,0 +1,47 @@
|
|||
clock
|
||||
clockwise 4
|
||||
clockwise 2
|
||||
counterclockwise 4
|
||||
clock
|
||||
clockwise 2
|
||||
clock
|
||||
clock
|
||||
counterclockwise 1
|
||||
clock
|
||||
clock
|
||||
clockwise 3
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 5
|
||||
clock
|
||||
target 3
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 4
|
||||
target 1
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
end
|
260
all_test/test_cases/6/output.txt
Normal file
260
all_test/test_cases/6/output.txt
Normal file
|
@ -0,0 +1,260 @@
|
|||
TIME:0
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:1
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:2
|
||||
BUS:
|
||||
position:1
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:01010
|
||||
counterclockwise:00010
|
||||
TIME:3
|
||||
BUS:
|
||||
position:2
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:01010
|
||||
counterclockwise:00010
|
||||
TIME:4
|
||||
BUS:
|
||||
position:3
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:01010
|
||||
counterclockwise:00010
|
||||
TIME:5
|
||||
BUS:
|
||||
position:3
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00010
|
||||
counterclockwise:10010
|
||||
TIME:6
|
||||
BUS:
|
||||
position:2
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00010
|
||||
counterclockwise:10010
|
||||
TIME:7
|
||||
BUS:
|
||||
position:1
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:10010
|
||||
TIME:8
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:10010
|
||||
TIME:9
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:10
|
||||
BUS:
|
||||
position:1
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:11
|
||||
BUS:
|
||||
position:2
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:12
|
||||
BUS:
|
||||
position:3
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:13
|
||||
BUS:
|
||||
position:4
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:14
|
||||
BUS:
|
||||
position:5
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:15
|
||||
BUS:
|
||||
position:6
|
||||
target:00101
|
||||
STATION:
|
||||
clockwise:00110
|
||||
counterclockwise:00010
|
||||
TIME:16
|
||||
BUS:
|
||||
position:6
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00010
|
||||
counterclockwise:00010
|
||||
TIME:17
|
||||
BUS:
|
||||
position:7
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00010
|
||||
counterclockwise:00010
|
||||
TIME:18
|
||||
BUS:
|
||||
position:8
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00010
|
||||
counterclockwise:00010
|
||||
TIME:19
|
||||
BUS:
|
||||
position:9
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00010
|
||||
counterclockwise:00010
|
||||
TIME:20
|
||||
BUS:
|
||||
position:9
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:21
|
||||
BUS:
|
||||
position:10
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:22
|
||||
BUS:
|
||||
position:11
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:23
|
||||
BUS:
|
||||
position:12
|
||||
target:10011
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:24
|
||||
BUS:
|
||||
position:12
|
||||
target:10010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:25
|
||||
BUS:
|
||||
position:13
|
||||
target:10010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:26
|
||||
BUS:
|
||||
position:14
|
||||
target:10010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:27
|
||||
BUS:
|
||||
position:0
|
||||
target:10010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:28
|
||||
BUS:
|
||||
position:0
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:29
|
||||
BUS:
|
||||
position:14
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:30
|
||||
BUS:
|
||||
position:13
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:31
|
||||
BUS:
|
||||
position:12
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:32
|
||||
BUS:
|
||||
position:11
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:33
|
||||
BUS:
|
||||
position:10
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:34
|
||||
BUS:
|
||||
position:9
|
||||
target:00010
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:35
|
||||
BUS:
|
||||
position:9
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:36
|
||||
BUS:
|
||||
position:9
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
end
|
4
all_test/test_cases/7/dict.dic
Normal file
4
all_test/test_cases/7/dict.dic
Normal file
|
@ -0,0 +1,4 @@
|
|||
TOTAL_STATION = 5
|
||||
DISTANCE = 3
|
||||
# shortest seek time first
|
||||
STRATEGY = SSTF
|
42
all_test/test_cases/7/input.txt
Normal file
42
all_test/test_cases/7/input.txt
Normal file
|
@ -0,0 +1,42 @@
|
|||
clock
|
||||
clockwise 2
|
||||
counterclockwise 4
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
counterclockwise 3
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 5
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
counterclockwise 4
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 1
|
||||
clockwise 3
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
target 2
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
clock
|
||||
end
|
239
all_test/test_cases/7/output.txt
Normal file
239
all_test/test_cases/7/output.txt
Normal file
|
@ -0,0 +1,239 @@
|
|||
TIME:0
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:1
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:2
|
||||
BUS:
|
||||
position:1
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:01000
|
||||
counterclockwise:00010
|
||||
TIME:3
|
||||
BUS:
|
||||
position:2
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:01000
|
||||
counterclockwise:00010
|
||||
TIME:4
|
||||
BUS:
|
||||
position:3
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:01000
|
||||
counterclockwise:00010
|
||||
TIME:5
|
||||
BUS:
|
||||
position:3
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00010
|
||||
TIME:6
|
||||
BUS:
|
||||
position:4
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00010
|
||||
TIME:7
|
||||
BUS:
|
||||
position:5
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:8
|
||||
BUS:
|
||||
position:6
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:9
|
||||
BUS:
|
||||
position:7
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:10
|
||||
BUS:
|
||||
position:8
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:11
|
||||
BUS:
|
||||
position:9
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:12
|
||||
BUS:
|
||||
position:9
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:13
|
||||
BUS:
|
||||
position:10
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:14
|
||||
BUS:
|
||||
position:11
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:15
|
||||
BUS:
|
||||
position:12
|
||||
target:00001
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:16
|
||||
BUS:
|
||||
position:12
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:17
|
||||
BUS:
|
||||
position:11
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:18
|
||||
BUS:
|
||||
position:10
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:19
|
||||
BUS:
|
||||
position:9
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00110
|
||||
TIME:20
|
||||
BUS:
|
||||
position:9
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:21
|
||||
BUS:
|
||||
position:8
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00100
|
||||
TIME:22
|
||||
BUS:
|
||||
position:7
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00100
|
||||
counterclockwise:00100
|
||||
TIME:23
|
||||
BUS:
|
||||
position:6
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00100
|
||||
counterclockwise:00100
|
||||
TIME:24
|
||||
BUS:
|
||||
position:6
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:25
|
||||
BUS:
|
||||
position:5
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:26
|
||||
BUS:
|
||||
position:4
|
||||
target:11000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:27
|
||||
BUS:
|
||||
position:3
|
||||
target:11000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:28
|
||||
BUS:
|
||||
position:3
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:29
|
||||
BUS:
|
||||
position:2
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:30
|
||||
BUS:
|
||||
position:1
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:31
|
||||
BUS:
|
||||
position:0
|
||||
target:10000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:32
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
TIME:33
|
||||
BUS:
|
||||
position:0
|
||||
target:00000
|
||||
STATION:
|
||||
clockwise:00000
|
||||
counterclockwise:00000
|
||||
end
|
Loading…
Reference in New Issue
Block a user