forked from CorinnaKrebs/SolutionValidator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathCapacitiesTest.cpp
More file actions
101 lines (78 loc) · 2.92 KB
/
CapacitiesTest.cpp
File metadata and controls
101 lines (78 loc) · 2.92 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
94
95
96
97
98
99
100
101
#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(CapacitiesTest) {
public:
TEST_METHOD(LoadVolumeCheck) {
unsigned int max_vol = 250;
unsigned int c1_vol = 100;
unsigned int c2_vol = 200;
Customer depot(0, 0, 0, 0, 0, 0, 0, 0, 0);
Customer customer1(1, 0, 0, 0, 0, 0, 0, 0, c1_vol);
Customer customer2(2, 0, 0, 0, 0, 0, 0, 0, c2_vol);
// Instance Creation
std::vector<Customer> customers{ depot, customer1, customer2};
std::vector<ItemType> itemtypes{ };
Instance instance("", Vehicle(0, 0, 0, 0, max_vol, 0, 0, 0, 0), itemtypes, customers, 0, 0);
// Tour Creation
std::vector<unsigned int> customer_ids1{ 1, 2 };
std::vector<unsigned int> item_ids{};
Tour tour1(1, customer_ids1, item_ids);
// Solution Creation
std::vector<Tour> tours{ tour1 };
Solution solution(tours);
// Test
Assert::AreEqual(false, ConstraintsRouting::checkCapacities(solution, true, instance, false));
}
TEST_METHOD(LoadMassCheck) {
unsigned int D = 30;
unsigned int c1_mass = 20;
unsigned int c2_mass = 20;
Customer depot(0, 0, 0, 0, 0, 0, 0, 0, 0);
Customer customer1(1, 0, 0, 0, 0, 0, 0, c1_mass, 0);
Customer customer2(2, 0, 0, 0, 0, 0, 0, c2_mass, 0);
// Instance Creation
std::vector<Customer> customers{ depot, customer1, customer2 };
std::vector<ItemType> itemtypes{ };
Instance instance("", Vehicle(0, 0, 0, D, 0, 0, 0, 0, 0), itemtypes, customers, 0, 0);
// Tour Creation
std::vector<unsigned int> customer_ids1{ 1, 2 };
std::vector<unsigned int> item_ids{};
Tour tour1(1, customer_ids1, item_ids);
// Solution Creation
std::vector<Tour> tours{ tour1 };
Solution solution(tours);
// Test
Assert::AreEqual(false, ConstraintsRouting::checkCapacities(solution, true, instance, false));
}
TEST_METHOD(Feasible) {
unsigned int D = 50;
unsigned int c1_mass = 20;
unsigned int c2_mass = 20;
unsigned int max_vol = 500;
unsigned int c1_vol = 100;
unsigned int c2_vol = 200;
Customer depot(0, 0, 0, 0, 0, 0, 0, 0, 0);
Customer customer1(1, 0, 0, 0, 0, 0, 0, c1_mass, c1_vol);
Customer customer2(2, 0, 0, 0, 0, 0, 0, c2_mass, c2_vol);
// Instance Creation
std::vector<Customer> customers{ depot, customer1, customer2 };
std::vector<ItemType> itemtypes{ };
Instance instance("", Vehicle(0, 0, 0, D, max_vol, 0, 0, 0, 0), itemtypes, customers, 0, 0);
// Tour Creation
std::vector<unsigned int> customer_ids1{ 1, 2 };
std::vector<unsigned int> item_ids{};
Tour tour1(1, customer_ids1, item_ids);
// Solution Creation
std::vector<Tour> tours{ tour1 };
Solution solution(tours);
// Test
Assert::AreEqual(true, ConstraintsRouting::checkCapacities(solution, true, instance, false));
}
};
}