Showing
7 changed files
with
113 additions
and
54 deletions
... | @@ -9,7 +9,7 @@ TARGET = biominserter | ... | @@ -9,7 +9,7 @@ TARGET = biominserter |
9 | 9 | ||
10 | CC = clang++ | 10 | CC = clang++ |
11 | # compiling flags here | 11 | # compiling flags here |
12 | -CFLAGS = -Icppsrc/ -I/usr/local/include -I$(ICONCERT) -I$(ICPLEX) -I$(INUPACK) -I$(IEIGEN) -g | 12 | +CFLAGS = -Icppsrc/ -I/usr/local/include -I$(ICONCERT) -I$(ICPLEX) -I$(INUPACK) -I$(IEIGEN) -O3 |
13 | CXXFLAGS = --std=c++17 -Wall -Wpedantic -Wextra -Wno-ignored-attributes -Wno-unused-variable | 13 | CXXFLAGS = --std=c++17 -Wall -Wpedantic -Wextra -Wno-ignored-attributes -Wno-unused-variable |
14 | 14 | ||
15 | LINKER = clang++ | 15 | LINKER = clang++ | ... | ... |
This diff is collapsed. Click to expand it.
... | @@ -14,21 +14,28 @@ class MOIP | ... | @@ -14,21 +14,28 @@ class MOIP |
14 | { | 14 | { |
15 | public: | 15 | public: |
16 | MOIP(void); | 16 | MOIP(void); |
17 | - MOIP(const RNA& rna, const vector<Motif>& motifSites, float pthreshold, bool verbose); | 17 | + MOIP(const RNA& rna, const vector<Motif>& motifSites, uint nsets, float pthreshold, bool verbose); |
18 | ~MOIP(void); | 18 | ~MOIP(void); |
19 | SecondaryStructure solve_objective(int o, double min, double max); | 19 | SecondaryStructure solve_objective(int o, double min, double max); |
20 | SecondaryStructure solve_objective(int o); | 20 | SecondaryStructure solve_objective(int o); |
21 | uint get_n_solutions(void) const; | 21 | uint get_n_solutions(void) const; |
22 | const SecondaryStructure& solution(uint i) const; | 22 | const SecondaryStructure& solution(uint i) const; |
23 | - void extend_pareto(double lambdaMin, double lambdaMax); | 23 | + void search_between(double lambdaMin, double lambdaMax); |
24 | bool allowed_basepair(size_t u, size_t v) const; | 24 | bool allowed_basepair(size_t u, size_t v) const; |
25 | void add_solution(const SecondaryStructure& s); | 25 | void add_solution(const SecondaryStructure& s); |
26 | + void remove_solution(uint i); | ||
27 | + static uint obj_to_solve_; // What objective do you prefer to solve in mono-objective portions of the algorithm ? | ||
28 | + static double precision_; // decimals to keep in objective values, to avoid numerical issues. otherwise, solution with objective 5.0000000009 dominates solution with 5.0 =( | ||
29 | + static double epsilon_; | ||
26 | 30 | ||
27 | private: | 31 | private: |
28 | - bool is_undominated_yet(const SecondaryStructure& s); | 32 | + bool is_undominated_yet(const SecondaryStructure& s); |
29 | - void define_problem_constraints(void); | 33 | + void define_problem_constraints(void); |
30 | - size_t get_yuv_index(size_t u, size_t v) const; | 34 | + size_t get_yuv_index(size_t u, size_t v) const; |
31 | - size_t get_Cpxi_index(size_t x_i, size_t i_on_j) const; | 35 | + size_t get_Cpxi_index(size_t x_i, size_t i_on_j) const; |
36 | + bool exists_vertical_outdated_labels(const SecondaryStructure& s) const; | ||
37 | + bool exists_horizontal_outdated_labels(const SecondaryStructure& s) const; | ||
38 | + | ||
32 | IloNumExprArg& y(size_t u, size_t v); // Direct reference to y^u_v in basepair_dv_ | 39 | IloNumExprArg& y(size_t u, size_t v); // Direct reference to y^u_v in basepair_dv_ |
33 | IloNumExprArg& C(size_t x, size_t i); // Direct reference to C_p^xi in insertion_dv_ | 40 | IloNumExprArg& C(size_t x, size_t i); // Direct reference to C_p^xi in insertion_dv_ |
34 | 41 | ||
... | @@ -38,6 +45,7 @@ class MOIP | ... | @@ -38,6 +45,7 @@ class MOIP |
38 | RNA rna_; // RNA object | 45 | RNA rna_; // RNA object |
39 | vector<Motif> insertion_sites_; // Potential Motif insertion sites | 46 | vector<Motif> insertion_sites_; // Potential Motif insertion sites |
40 | vector<SecondaryStructure> pareto_; // Vector of results | 47 | vector<SecondaryStructure> pareto_; // Vector of results |
48 | + uint n_sets_; // number of Pareto sets to return | ||
41 | 49 | ||
42 | // Objectives related | 50 | // Objectives related |
43 | float theta_; // theta parameter for the probability function | 51 | float theta_; // theta parameter for the probability function | ... | ... |
1 | #include "SecondaryStructure.h" | 1 | #include "SecondaryStructure.h" |
2 | +#include "MOIP.h" | ||
2 | #include <algorithm> | 3 | #include <algorithm> |
3 | #include <boost/format.hpp> | 4 | #include <boost/format.hpp> |
4 | 5 | ||
... | @@ -13,7 +14,7 @@ SecondaryStructure::SecondaryStructure() {} | ... | @@ -13,7 +14,7 @@ SecondaryStructure::SecondaryStructure() {} |
13 | 14 | ||
14 | 15 | ||
15 | SecondaryStructure::SecondaryStructure(const RNA& rna) | 16 | SecondaryStructure::SecondaryStructure(const RNA& rna) |
16 | -: objective_scores_(vector<double>(2)), n_(rna.get_RNA_length()), nBP_(0), rna_(rna) | 17 | +: objective_scores_(vector<double>(2)), n_(rna.get_RNA_length()), nBP_(0), k_(0), rna_(rna) |
17 | { | 18 | { |
18 | is_empty_structure = false; | 19 | is_empty_structure = false; |
19 | } | 20 | } |
... | @@ -21,6 +22,7 @@ SecondaryStructure::SecondaryStructure(const RNA& rna) | ... | @@ -21,6 +22,7 @@ SecondaryStructure::SecondaryStructure(const RNA& rna) |
21 | SecondaryStructure::SecondaryStructure(bool empty) : rna_(RNA()) { is_empty_structure = empty; } | 22 | SecondaryStructure::SecondaryStructure(bool empty) : rna_(RNA()) { is_empty_structure = empty; } |
22 | 23 | ||
23 | 24 | ||
25 | + | ||
24 | string SecondaryStructure::to_DBN(void) const | 26 | string SecondaryStructure::to_DBN(void) const |
25 | { | 27 | { |
26 | 28 | ||
... | @@ -175,16 +177,16 @@ bool operator>(const SecondaryStructure& s1, const SecondaryStructure& s2) | ... | @@ -175,16 +177,16 @@ bool operator>(const SecondaryStructure& s1, const SecondaryStructure& s2) |
175 | 177 | ||
176 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; | 178 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; |
177 | 179 | ||
178 | - if (s11 > s21) { | 180 | + if (s11 - s21 > MOIP::precision_) { |
179 | strict1 = true; | 181 | strict1 = true; |
180 | obj1 = true; | 182 | obj1 = true; |
181 | - } else if (s11 == s21) { | 183 | + } else if (abs(s11 - s21) < MOIP::precision_) { |
182 | obj1 = true; | 184 | obj1 = true; |
183 | } | 185 | } |
184 | - if (s12 > s22) { | 186 | + if (s12 - s22 > MOIP::precision_) { |
185 | strict2 = true; | 187 | strict2 = true; |
186 | obj2 = true; | 188 | obj2 = true; |
187 | - } else if (s12 == s22) { | 189 | + } else if (abs(s12 - s22) < MOIP::precision_) { |
188 | obj2 = true; | 190 | obj2 = true; |
189 | } | 191 | } |
190 | 192 | ||
... | @@ -204,16 +206,16 @@ bool operator<(const SecondaryStructure& s1, const SecondaryStructure& s2) | ... | @@ -204,16 +206,16 @@ bool operator<(const SecondaryStructure& s1, const SecondaryStructure& s2) |
204 | 206 | ||
205 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; | 207 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; |
206 | 208 | ||
207 | - if (s11 < s21) { | 209 | + if (MOIP::precision_ < s21 - s11) { |
208 | strict1 = true; | 210 | strict1 = true; |
209 | obj1 = true; | 211 | obj1 = true; |
210 | - } else if (s11 == s21) { | 212 | + } else if (abs(s11-s21) < MOIP::precision_) { |
211 | obj1 = true; | 213 | obj1 = true; |
212 | } | 214 | } |
213 | - if (s12 < s22) { | 215 | + if (MOIP::precision_ < s22 - s12) { |
214 | strict2 = true; | 216 | strict2 = true; |
215 | obj2 = true; | 217 | obj2 = true; |
216 | - } else if (s12 == s22) { | 218 | + } else if (abs(s12-s22) < MOIP::precision_) { |
217 | obj2 = true; | 219 | obj2 = true; |
218 | } | 220 | } |
219 | 221 | ||
... | @@ -232,20 +234,20 @@ bool operator>=(const SecondaryStructure& s1, const SecondaryStructure& s2) | ... | @@ -232,20 +234,20 @@ bool operator>=(const SecondaryStructure& s1, const SecondaryStructure& s2) |
232 | 234 | ||
233 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; | 235 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; |
234 | 236 | ||
235 | - if (s11 > s21) { | 237 | + if (s11 - s21 > MOIP::precision_) { |
236 | strict1 = true; | 238 | strict1 = true; |
237 | obj1 = true; | 239 | obj1 = true; |
238 | - } else if (s11 == s21) { | 240 | + } else if (abs(s11-s21) < MOIP::precision_) { |
239 | obj1 = true; | 241 | obj1 = true; |
240 | } | 242 | } |
241 | - if (s12 > s22) { | 243 | + if (s12 - s22 > MOIP::precision_) { |
242 | strict2 = true; | 244 | strict2 = true; |
243 | obj2 = true; | 245 | obj2 = true; |
244 | - } else if (s12 == s22) { | 246 | + } else if (abs(s12-s22) < MOIP::precision_) { |
245 | obj2 = true; | 247 | obj2 = true; |
246 | } | 248 | } |
247 | 249 | ||
248 | - if ((obj1 && obj2 && (strict1 || strict2)) || ((s11 == s21 && s12 == s22))) { | 250 | + if ((obj1 && obj2 && (strict1 || strict2)) || ((abs(s11-s21) < MOIP::precision_ && abs(s12-s22) < MOIP::precision_))) { |
249 | return true; | 251 | return true; |
250 | } | 252 | } |
251 | 253 | ||
... | @@ -261,20 +263,20 @@ bool operator<=(const SecondaryStructure& s1, const SecondaryStructure& s2) | ... | @@ -261,20 +263,20 @@ bool operator<=(const SecondaryStructure& s1, const SecondaryStructure& s2) |
261 | 263 | ||
262 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; | 264 | bool obj1 = false, obj2 = false, strict1 = false, strict2 = false; |
263 | 265 | ||
264 | - if (s11 < s21) { | 266 | + if (MOIP::precision_ < s21 - s11) { |
265 | strict1 = true; | 267 | strict1 = true; |
266 | obj1 = true; | 268 | obj1 = true; |
267 | - } else if (s11 == s21) { | 269 | + } else if (abs(s11-s21) < MOIP::precision_) { |
268 | obj1 = true; | 270 | obj1 = true; |
269 | } | 271 | } |
270 | - if (s12 < s22) { | 272 | + if (MOIP::precision_ < s22 - s12) { |
271 | strict2 = true; | 273 | strict2 = true; |
272 | obj2 = true; | 274 | obj2 = true; |
273 | - } else if (s12 == s22) { | 275 | + } else if (abs(s12-s22) < MOIP::precision_) { |
274 | obj2 = true; | 276 | obj2 = true; |
275 | } | 277 | } |
276 | 278 | ||
277 | - if ((obj1 && obj2 && (strict1 || strict2)) || ((s11 == s21 && s12 == s22))) { | 279 | + if ((obj1 && obj2 && (strict1 || strict2)) || ((abs(s11-s21) < MOIP::precision_ && abs(s12-s22) < MOIP::precision_))) { |
278 | return true; | 280 | return true; |
279 | } | 281 | } |
280 | return false; | 282 | return false; |
... | @@ -289,6 +291,8 @@ bool operator==(const Component& c1, const Component& c2) | ... | @@ -289,6 +291,8 @@ bool operator==(const Component& c1, const Component& c2) |
289 | 291 | ||
290 | bool operator!=(const Component& c1, const Component& c2) { return not(c1 == c2); } | 292 | bool operator!=(const Component& c1, const Component& c2) { return not(c1 == c2); } |
291 | 293 | ||
294 | + | ||
295 | + | ||
292 | bool operator==(const Motif& m1, const Motif& m2) | 296 | bool operator==(const Motif& m1, const Motif& m2) |
293 | { | 297 | { |
294 | if (m1.atlas_id != m2.atlas_id) return false; | 298 | if (m1.atlas_id != m2.atlas_id) return false; |
... | @@ -301,6 +305,8 @@ bool operator==(const Motif& m1, const Motif& m2) | ... | @@ -301,6 +305,8 @@ bool operator==(const Motif& m1, const Motif& m2) |
301 | 305 | ||
302 | bool operator!=(const Motif& m1, const Motif& m2) { return not(m1 == m2); } | 306 | bool operator!=(const Motif& m1, const Motif& m2) { return not(m1 == m2); } |
303 | 307 | ||
308 | + | ||
309 | + | ||
304 | bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2) | 310 | bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2) |
305 | { | 311 | { |
306 | // Checks wether the secondary structures are exactly the same, including the inserted motifs. | 312 | // Checks wether the secondary structures are exactly the same, including the inserted motifs. |
... | @@ -317,4 +323,11 @@ bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2) | ... | @@ -317,4 +323,11 @@ bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2) |
317 | for (uint i = 0; i < s1.get_n_motifs(); i++) | 323 | for (uint i = 0; i < s1.get_n_motifs(); i++) |
318 | if (s1.motif_info_[i] != s2.motif_info_[i]) return false; | 324 | if (s1.motif_info_[i] != s2.motif_info_[i]) return false; |
319 | return true; | 325 | return true; |
326 | +} | ||
327 | + | ||
328 | +bool operator!=(const SecondaryStructure& s1, const SecondaryStructure& s2) | ||
329 | +{ | ||
330 | + // Checks wether the secondary structures are different, including the inserted motifs. | ||
331 | + | ||
332 | + return not(s1 == s2); | ||
320 | } | 333 | } |
... | \ No newline at end of file | ... | \ No newline at end of file | ... | ... |
1 | #ifndef __INC_IP_SOL__ | 1 | #ifndef __INC_IP_SOL__ |
2 | #define __INC_IP_SOL__ | 2 | #define __INC_IP_SOL__ |
3 | 3 | ||
4 | +#define IL_STD | ||
5 | + | ||
4 | #include "rna.h" | 6 | #include "rna.h" |
7 | +#include <ilconcert/ilomodel.h> | ||
8 | +#include <ilcplex/ilocplex.h> | ||
5 | #include <iostream> | 9 | #include <iostream> |
6 | #include <string> | 10 | #include <string> |
7 | #include <vector> | 11 | #include <vector> |
... | @@ -45,6 +49,8 @@ class SecondaryStructure | ... | @@ -45,6 +49,8 @@ class SecondaryStructure |
45 | void insert_motif(const Motif& m); | 49 | void insert_motif(const Motif& m); |
46 | double get_objective_score(int i) const; | 50 | double get_objective_score(int i) const; |
47 | void set_objective_score(int i, double s); | 51 | void set_objective_score(int i, double s); |
52 | + void set_pareto_set(uint k); | ||
53 | + uint get_pareto_set(void) const; | ||
48 | uint get_n_motifs(void) const; | 54 | uint get_n_motifs(void) const; |
49 | uint get_n_bp(void) const; | 55 | uint get_n_bp(void) const; |
50 | void print(void) const; | 56 | void print(void) const; |
... | @@ -56,9 +62,11 @@ class SecondaryStructure | ... | @@ -56,9 +62,11 @@ class SecondaryStructure |
56 | vector<pair<uint, uint>> basepairs_; // values of the decision variable of the integer program | 62 | vector<pair<uint, uint>> basepairs_; // values of the decision variable of the integer program |
57 | vector<Motif> motif_info_; // information about known motives in this secondary structure and their positions | 63 | vector<Motif> motif_info_; // information about known motives in this secondary structure and their positions |
58 | size_t n_; // length of the RNA | 64 | size_t n_; // length of the RNA |
59 | - size_t nBP_; | 65 | + size_t nBP_; // number of basepairs |
60 | - RNA rna_; // RNA object which is folded | 66 | + uint k_; // Secondary Structure belongs to the kth Pareto set |
67 | + RNA rna_; // RNA object which is folded | ||
61 | bool is_empty_structure; // Empty structure, returned when the solver does not find solutions anymore | 68 | bool is_empty_structure; // Empty structure, returned when the solver does not find solutions anymore |
69 | + IloConstraint forbid_this_; // Add it to a cplex model to forbid that solution | ||
62 | }; | 70 | }; |
63 | 71 | ||
64 | // return if this SecondaryStructure s1 dominates s2 | 72 | // return if this SecondaryStructure s1 dominates s2 |
... | @@ -67,8 +75,9 @@ bool operator>=(const SecondaryStructure& s1, const SecondaryStructure& s2); | ... | @@ -67,8 +75,9 @@ bool operator>=(const SecondaryStructure& s1, const SecondaryStructure& s2); |
67 | // return if this SecondaryStructure s2 dominates s1 | 75 | // return if this SecondaryStructure s2 dominates s1 |
68 | bool operator<(const SecondaryStructure& s1, const SecondaryStructure& s2); | 76 | bool operator<(const SecondaryStructure& s1, const SecondaryStructure& s2); |
69 | bool operator<=(const SecondaryStructure& s1, const SecondaryStructure& s2); | 77 | bool operator<=(const SecondaryStructure& s1, const SecondaryStructure& s2); |
70 | -// return wether SecondaryStructures are identical | 78 | +// return wether SecondaryStructures are identical or not |
71 | bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2); | 79 | bool operator==(const SecondaryStructure& s1, const SecondaryStructure& s2); |
80 | +bool operator!=(const SecondaryStructure& s1, const SecondaryStructure& s2); | ||
72 | // utilities to compare secondary structures: | 81 | // utilities to compare secondary structures: |
73 | bool operator==(const Motif& m1, const Motif& m2); | 82 | bool operator==(const Motif& m1, const Motif& m2); |
74 | bool operator!=(const Motif& m1, const Motif& m2); | 83 | bool operator!=(const Motif& m1, const Motif& m2); |
... | @@ -81,5 +90,7 @@ inline double SecondaryStructure::get_objective_score(int i) const { return obje | ... | @@ -81,5 +90,7 @@ inline double SecondaryStructure::get_objective_score(int i) const { return obje |
81 | inline void SecondaryStructure::set_objective_score(int i, double s) { objective_scores_[i - 1] = s; } | 90 | inline void SecondaryStructure::set_objective_score(int i, double s) { objective_scores_[i - 1] = s; } |
82 | inline uint SecondaryStructure::get_n_motifs(void) const { return motif_info_.size(); } | 91 | inline uint SecondaryStructure::get_n_motifs(void) const { return motif_info_.size(); } |
83 | inline uint SecondaryStructure::get_n_bp(void) const { return nBP_; } | 92 | inline uint SecondaryStructure::get_n_bp(void) const { return nBP_; } |
93 | +inline uint SecondaryStructure::get_pareto_set(void) const { return k_; } | ||
94 | +inline void SecondaryStructure::set_pareto_set(uint k) { k_ = k; } | ||
84 | 95 | ||
85 | #endif | 96 | #endif | ... | ... |
... | @@ -66,30 +66,28 @@ int main(int argc, char* argv[]) | ... | @@ -66,30 +66,28 @@ int main(int argc, char* argv[]) |
66 | { | 66 | { |
67 | /* ARGUMENT CHECKING */ | 67 | /* ARGUMENT CHECKING */ |
68 | 68 | ||
69 | - if (argc != 5) { | 69 | + if (argc != 6) { |
70 | cerr << argc << " arguments specified !" << endl; | 70 | cerr << argc << " arguments specified !" << endl; |
71 | cerr << "Please specify the following input files:" << endl; | 71 | cerr << "Please specify the following input files:" << endl; |
72 | - cerr << "biominserter sequence.fasta insertion.sites.csv prob_threshold verbose" << endl; | 72 | + cerr << "biominserter sequence.fasta insertion.sites.csv prob_threshold verbose obj" << endl; |
73 | return EXIT_FAILURE; | 73 | return EXIT_FAILURE; |
74 | } | 74 | } |
75 | 75 | ||
76 | /* VARIABLE DECLARATIONS */ | 76 | /* VARIABLE DECLARATIONS */ |
77 | 77 | ||
78 | - const char* inputName = argv[1]; | 78 | + const char* inputName = argv[1]; |
79 | - const char* csvname = argv[2]; | 79 | + const char* csvname = argv[2]; |
80 | - bool verbose = (atoi(argv[4]) != 0); | 80 | + bool verbose = (atoi(argv[4]) != 0); |
81 | - string fastaname = string(inputName); | 81 | + string basename = remove_ext(inputName, '.', '/'); |
82 | - string basename = remove_ext(inputName, '.', '/'); | 82 | + float theta_p_threshold = atof(argv[3]); |
83 | - float theta_p_threshold = atof(argv[3]); | 83 | + list<Fasta> f; |
84 | - list<Fasta> f; | 84 | + string line; |
85 | - list<Fasta>::iterator fa = f.begin(); | 85 | + ifstream motifs; |
86 | - string line; | 86 | + vector<Motif> posInsertionSites; |
87 | - ifstream motifs; | 87 | + ofstream outfile; |
88 | - vector<Motif> posInsertionSites; | 88 | + SecondaryStructure bestSSO1, bestSSO2; |
89 | - ofstream outfile; | 89 | + RNA myRNA; |
90 | - SecondaryStructure bestSSO1, bestSSO2; | 90 | + MOIP::obj_to_solve_ = atoi(argv[5]); |
91 | - RNA myRNA; | ||
92 | - MOIP myMOIP; | ||
93 | 91 | ||
94 | /* FILE PARSING */ | 92 | /* FILE PARSING */ |
95 | 93 | ||
... | @@ -100,6 +98,7 @@ int main(int argc, char* argv[]) | ... | @@ -100,6 +98,7 @@ int main(int argc, char* argv[]) |
100 | return EXIT_FAILURE; | 98 | return EXIT_FAILURE; |
101 | } | 99 | } |
102 | Fasta::load(f, inputName); | 100 | Fasta::load(f, inputName); |
101 | + list<Fasta>::iterator fa = f.begin(); | ||
103 | if (verbose) cout << "loading " << fa->name() << "..." << endl; | 102 | if (verbose) cout << "loading " << fa->name() << "..." << endl; |
104 | myRNA = RNA(fa->name(), fa->seq(), verbose); | 103 | myRNA = RNA(fa->name(), fa->seq(), verbose); |
105 | if (verbose) cout << "\t>" << inputName << " successfuly loaded (" << myRNA.get_RNA_length() << " nt)" << endl; | 104 | if (verbose) cout << "\t>" << inputName << " successfuly loaded (" << myRNA.get_RNA_length() << " nt)" << endl; |
... | @@ -117,19 +116,31 @@ int main(int argc, char* argv[]) | ... | @@ -117,19 +116,31 @@ int main(int argc, char* argv[]) |
117 | 116 | ||
118 | /* FIND K-PARETO SETS */ | 117 | /* FIND K-PARETO SETS */ |
119 | 118 | ||
120 | - myMOIP = MOIP(myRNA, posInsertionSites, theta_p_threshold, verbose); | 119 | + MOIP myMOIP = MOIP(myRNA, posInsertionSites, 1, theta_p_threshold, verbose); |
121 | try { | 120 | try { |
122 | bestSSO1 = myMOIP.solve_objective(1, -__DBL_MAX__, __DBL_MAX__); | 121 | bestSSO1 = myMOIP.solve_objective(1, -__DBL_MAX__, __DBL_MAX__); |
123 | bestSSO2 = myMOIP.solve_objective(2, -__DBL_MAX__, __DBL_MAX__); | 122 | bestSSO2 = myMOIP.solve_objective(2, -__DBL_MAX__, __DBL_MAX__); |
124 | - if (verbose) { | 123 | + bestSSO1.set_pareto_set(1); |
125 | - cout << "Best solution according to objective 1 :" << bestSSO1.to_string(); | 124 | + bestSSO2.set_pareto_set(1); |
126 | - cout << "Best solution according to objective 2 :" << bestSSO2.to_string(); | ||
127 | - } | ||
128 | - // extend to the whole pareto set | ||
129 | myMOIP.add_solution(bestSSO1); | 125 | myMOIP.add_solution(bestSSO1); |
130 | myMOIP.add_solution(bestSSO2); | 126 | myMOIP.add_solution(bestSSO2); |
131 | - myMOIP.extend_pareto(bestSSO2.get_objective_score(1), bestSSO1.get_objective_score(1)); | 127 | + if (verbose) { |
128 | + cout << endl << "Best solution according to objective 1 :" << bestSSO1.to_string() << endl; | ||
129 | + cout << "Best solution according to objective 2 :" << bestSSO2.to_string() << endl; | ||
130 | + } | ||
132 | 131 | ||
132 | + // extend to the whole pareto set | ||
133 | + if (MOIP::obj_to_solve_ == 1) { | ||
134 | + if (verbose) cout << endl << "Solving obj1 on top of best solution 1." << endl; | ||
135 | + myMOIP.search_between(bestSSO1.get_objective_score(2) + MOIP::epsilon_, bestSSO2.get_objective_score(2)); | ||
136 | + if (verbose) cout << endl << "Solving obj1 below best solution 1." << endl; | ||
137 | + myMOIP.search_between(-__DBL_MAX__, bestSSO1.get_objective_score(2)); | ||
138 | + } else { | ||
139 | + if (verbose) cout << endl << "Solving obj2 on top of best solution 2." << endl; | ||
140 | + myMOIP.search_between(bestSSO2.get_objective_score(1) + MOIP::epsilon_, bestSSO1.get_objective_score(1)); | ||
141 | + if (verbose) cout << endl << "Solving obj2 below best solution 2." << endl; | ||
142 | + myMOIP.search_between(-__DBL_MAX__, bestSSO2.get_objective_score(1)); | ||
143 | + } | ||
133 | } catch (IloAlgorithm::NotExtractedException& e) { | 144 | } catch (IloAlgorithm::NotExtractedException& e) { |
134 | cerr << e << endl; | 145 | cerr << e << endl; |
135 | exit(EXIT_FAILURE); | 146 | exit(EXIT_FAILURE); |
... | @@ -138,6 +149,22 @@ int main(int argc, char* argv[]) | ... | @@ -138,6 +149,22 @@ int main(int argc, char* argv[]) |
138 | exit(EXIT_FAILURE); | 149 | exit(EXIT_FAILURE); |
139 | } | 150 | } |
140 | 151 | ||
152 | + /* REMOVE SOLUTIONS WITH TOO HIGH LABEL */ | ||
153 | + | ||
154 | + vector<size_t> to_remove; | ||
155 | + if (verbose) cout << endl; | ||
156 | + for (uint i = 0; i < myMOIP.get_n_solutions(); i++) | ||
157 | + if (myMOIP.solution(i).get_pareto_set() > 1) { // Some solution is fromm a Pareto set of too high order | ||
158 | + if (verbose) | ||
159 | + cout << "Removing structure from Pareto set " << myMOIP.solution(i).get_pareto_set() << " : " | ||
160 | + << myMOIP.solution(i).to_string() << endl; | ||
161 | + to_remove.push_back(i); | ||
162 | + } | ||
163 | + if (to_remove.size()) { | ||
164 | + for (size_t i = to_remove.size() - 1; i != 0; i--) myMOIP.remove_solution(to_remove[i]); | ||
165 | + myMOIP.remove_solution(to_remove[0]); | ||
166 | + } | ||
167 | + | ||
141 | /* DISPLAY RESULTS */ | 168 | /* DISPLAY RESULTS */ |
142 | 169 | ||
143 | // print the pareto set | 170 | // print the pareto set | ... | ... |
... | @@ -111,7 +111,7 @@ RNA::RNA(string name, string seq, bool verbose) | ... | @@ -111,7 +111,7 @@ RNA::RNA(string name, string seq, bool verbose) |
111 | for (i = 0; i < length; i++) { | 111 | for (i = 0; i < length; i++) { |
112 | p_unpaired[i] = pairPr[(length + 1) * i + j]; | 112 | p_unpaired[i] = pairPr[(length + 1) * i + j]; |
113 | double sum = 0.0; | 113 | double sum = 0.0; |
114 | - for (j = 0; j < length; j++) sum += pij_(i, j); | 114 | + for (j = 0; j < length; j++) sum += i < j ? pij_(i, j) : pij_(j, i); |
115 | printf("\t\t%d\tunpaired: %.4e\tpaired(pK+noPK): %.4e\tTotal: %f\n", i + 1, p_unpaired[i], sum, p_unpaired[i] + sum); | 115 | printf("\t\t%d\tunpaired: %.4e\tpaired(pK+noPK): %.4e\tTotal: %f\n", i + 1, p_unpaired[i], sum, p_unpaired[i] + sum); |
116 | } | 116 | } |
117 | cout << "\t\t>pairing probabilities defined" << endl; | 117 | cout << "\t\t>pairing probabilities defined" << endl; | ... | ... |
-
Please register or login to post a comment