boipsolution.cpp
2.55 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
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
#include <iostream>
#include <vector>
#include <utility>
#include <string>
#include <boost/format.hpp>
#include "boipsolution.h"
BoipSolution::BoipSolution()
{
l_ = 1;
}
BoipSolution::BoipSolution (float obj1, float obj2, std::vector< double > v) : obj1_(obj1), obj2_(obj2), v_(v)
{
l_ = 1;
}
BoipSolution::BoipSolution (const BoipSolution & sol) : obj1_(sol.get_obj1_()), obj2_(sol.get_obj2_()), v_(sol.get_v_()), l_(sol.get_l_())
{
l_ = 1;
}
BoipSolution::~BoipSolution()
{
}
float BoipSolution::get_obj1_() const
{
return obj1_;
}
float BoipSolution::get_obj2_() const
{
return obj2_;
}
std::vector< double > BoipSolution::get_v_() const
{
return v_;
}
int BoipSolution::get_l_() const
{
return l_;
}
void BoipSolution::set_obj1_(float obj1)
{
obj1_ = obj1;
}
void BoipSolution::set_obj2_(float obj2)
{
obj2_ = obj2;
}
void BoipSolution::set_v_(std::vector < double > v)
{
v_ = v;
}
void BoipSolution::set_l_(int l)
{
l_=l;
}
int BoipSolution::dominate( BoipSolution s){ //return 1 if this BoipSolution dominates s
float s1 = s.get_obj1_();
float s2 = s.get_obj2_();
int dom = 0, obj1 = 0, obj2 = 0, strict1 = 0, strict2 = 0;
if (s1 > obj1_){
strict1 = 1;
obj1 = 1;
}
else if ( std::abs(s1 - obj1_) < PRECISION ){
obj1 = 1;
}
if (s2 > obj2_){
strict2 = 1;
obj2 = 1;
}
else if ( std::abs(s2 - obj2_) < PRECISION ){
obj2 = 1;
}
if ( obj1 == 1 && obj2 == 1 && ( strict1 == 1 || strict2 == 1 ) ){
dom = 1;
}
return dom;
}
// BoipChrSolution
BoipChrSolution::BoipChrSolution()
{
l_ = 1;
}
BoipChrSolution::BoipChrSolution (float obj1, float obj2, std::vector< double > v,
std::vector< std::vector < double > > varVC, std::vector < double > varColorUsed) :
BoipSolution(obj1, obj2, v), varVC_(varVC), varColorUsed_(varColorUsed)
{
l_ = 1;
}
BoipChrSolution::BoipChrSolution (const BoipChrSolution & sol) :
BoipSolution(sol.obj1_, sol.obj2_, sol.v_),
varVC_(sol.varVC_), varColorUsed_(sol.varColorUsed_)
{
l_ = sol.l_;
}
BoipChrSolution::~BoipChrSolution()
{
}
std::vector< std::vector < double > > BoipChrSolution::get_varVC_() const
{
return varVC_;
}
std::vector< double > BoipChrSolution::get_varColorUsed_() const
{
return varColorUsed_;
}
void BoipChrSolution::set_varVC_(std::vector < std::vector < double > > varVC)
{
varVC_ = varVC;
}
void BoipChrSolution::set_varColorUsed_(std::vector < double > varColorUsed)
{
varColorUsed_ = varColorUsed;
}