forked from CorinnaKrebs/SolutionValidator
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathAxleWeightTest.cpp
More file actions
100 lines (77 loc) · 2.94 KB
/
AxleWeightTest.cpp
File metadata and controls
100 lines (77 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
94
95
96
97
98
99
100
#include "pch.h"
#include "CppUnitTest.h"
#include "../Validator/ConstraintsLoading.h"
#include <string>
#include <vector>
using namespace Microsoft::VisualStudio::CppUnitTestFramework;
using namespace validator;
namespace LoadingConstraints {
TEST_CLASS(AxleWeightTest) {
unsigned int dim = 2;
unsigned int D = 90;
unsigned int max_FA = 50;
unsigned int max_RA = 82;
unsigned int WB = 48;
unsigned int lF = 4;
public:
TEST_METHOD(FrontAxleExceeding) {
unsigned int mass = 60;
ItemType type(1, dim, dim, dim, mass, false, 0);
Item item1(0, 1, 0, type);
// Instance Creation
Customer customer(1, 0, 0, 2, 0, 0, 0, 0, 0);
std::vector<Customer> customers{ customer };
std::vector<ItemType> itemtypes{ type };
Instance instance("", Vehicle(60, 25, 30, D, 0, WB, max_FA, max_RA, lF), itemtypes, customers, 0, 0);
instance.items.emplace_back(item1);
// Tour Creation
std::vector<unsigned int> customer_ids{ };
std::vector<unsigned int> item_ids{ };
Tour tour(1, customer_ids, item_ids);
// Positions
instance.items.at(item1.id).setPosition(Point(0, 0, 0));
// Tests
Assert::AreEqual(false, ConstraintsLoading::checkAxleWeights(instance.items.at(item1.id), tour, true, instance, true));
Assert::AreEqual(mass * 9.81, tour.sum_F);
Assert::AreEqual(mass * 9.81 * (lF + dim/2.0), tour.sum_T);
}
TEST_METHOD(RearAxleExceeding) {
unsigned int mass = 80;
ItemType type(1, dim, dim, dim, mass, false, 0);
Item item1(0, 1, 0, type);
// Instance Creation
Customer customer(1, 0, 0, 2, 0, 0, 0, 0, 0);
std::vector<Customer> customers{ customer };
std::vector<ItemType> itemtypes{ type };
Instance instance("", Vehicle(60, 25, 30, D, 0, WB, max_FA, max_RA, lF), itemtypes, customers, 0, 0);
instance.items.emplace_back(item1);
// Tour Creation
std::vector<unsigned int> customer_ids{ };
std::vector<unsigned int> item_ids{ };
Tour tour(1, customer_ids, item_ids);
// Position
instance.items.at(item1.id).setPosition(Point(55, 0, 0));
// Tests
Assert::AreEqual(false, ConstraintsLoading::checkAxleWeights(instance.items.at(item1.id), tour, true, instance, true));
}
TEST_METHOD(Feasible) {
unsigned int mass = 30;
ItemType type(1, dim, dim, dim, mass, false, 0);
Item item1(0, 1, 0, type);
// Instance Creation
Customer customer(1, 0, 0, 2, 0, 0, 0, 0, 0);
std::vector<Customer> customers{ customer };
std::vector<ItemType> itemtypes{ type };
Instance instance("", Vehicle(60, 25, 30, D, 0, WB, max_FA, max_RA, lF), itemtypes, customers, 0, 0);
instance.items.emplace_back(item1);
// Tour Creation
std::vector<unsigned int> customer_ids{ };
std::vector<unsigned int> item_ids{ };
Tour tour(1, customer_ids, item_ids);
// Positions
instance.items.at(item1.id).setPosition(Point(20, 0, 0));
// Tests
Assert::AreEqual(true, ConstraintsLoading::checkAxleWeights(instance.items.at(item1.id), tour, true, instance, true));
}
};
}