forked from CorinnaKrebs/SolutionValidator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathDispatchedItemsTest.cpp
More file actions
93 lines (78 loc) · 2.94 KB
/
DispatchedItemsTest.cpp
File metadata and controls
93 lines (78 loc) · 2.94 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
#include "pch.h"
#include "CppUnitTest.h"
#include "../Validator/ConstraintsRouting.h"
#include <string>
#include <vector>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace validator;
namespace RoutingConstraints {
TEST_CLASS(DispatchedItemsTest) {
public:
TEST_METHOD(Demand2NotFulfilled) {
ItemType type1(1, 0, 0, 0, 0, false, 0);
ItemType type2(2, 0, 0, 0, 0, false, 0);
Item item1(0, 1, 0, type1);
Item item2(1, 1, 0, type1);
Item item3(2, 1, 0, type1);
Item item4(3, 1, 0, type2);
Item item5(4, 1, 0, type2);
// Instance Creation
Customer depot(0, 0, 0, 0, 0, 0, 0, 0, 0);
Customer customer(1, 0, 0, 5, 0, 0, 0, 0, 0);
std::vector<Customer> customers{ depot, customer };
std::vector<ItemType> itemtypes{ type1, type2 };
Instance instance("", Vehicle(0, 0, 0, 0, 0, 0, 0, 0, 0), itemtypes, customers, 0, 0);
instance.items.emplace_back(item1);
instance.items.emplace_back(item2);
instance.items.emplace_back(item3);
instance.items.emplace_back(item4);
instance.items.emplace_back(item5);
std::pair<int, int> demand1(1, 3);
std::pair<int, int> demand2(2, 3);
instance.customers.at(1).demands.emplace_back(demand1);
instance.customers.at(1).demands.emplace_back(demand2);
// Tour Creation
std::vector<unsigned int> customer_ids{ 1 };
std::vector<unsigned int> item_ids{ 0, 1, 2, 3, 4 };
Tour tour(1, customer_ids, item_ids);
// Solution Creation
std::vector<Tour> tours{ tour };
Solution solution(tours);
// Test
Assert::AreEqual(false, ConstraintsRouting::checkDispatchedItems(solution, instance, false));
}
TEST_METHOD(DemandFulfilled) {
ItemType type1(1, 0, 0, 0, 0, false, 0);
ItemType type2(2, 0, 0, 0, 0, false, 0);
Item item1(0, 1, 0, type1);
Item item2(1, 1, 0, type1);
Item item3(2, 1, 0, type1);
Item item4(3, 1, 0, type2);
Item item5(4, 1, 0, type2);
// Instance Creation
Customer depot(0, 0, 0, 0, 0, 0, 0, 0, 0);
Customer customer(1, 0, 0, 5, 0, 0, 0, 0, 0);
std::vector<Customer> customers{ depot, customer };
std::vector<ItemType> itemtypes{ type1, type2 };
Instance instance("", Vehicle(0, 0, 0, 0, 0, 0, 0, 0, 0), itemtypes, customers, 0, 0);
instance.items.emplace_back(item1);
instance.items.emplace_back(item2);
instance.items.emplace_back(item3);
instance.items.emplace_back(item4);
instance.items.emplace_back(item5);
std::pair<int, int> demand1(1, 3);
std::pair<int, int> demand2(2, 2);
instance.customers.at(1).demands.emplace_back(demand1);
instance.customers.at(1).demands.emplace_back(demand2);
// Tour Creation
std::vector<unsigned int> customer_ids{ 1 };
std::vector<unsigned int> item_ids{ 0, 1, 2, 3, 4 };
Tour tour(1, customer_ids, item_ids);
// Solution Creation
std::vector<Tour> tours{ tour };
Solution solution(tours);
// Test
Assert::AreEqual(true, ConstraintsRouting::checkDispatchedItems(solution, instance, false));
}
};
}