Louis BECQUEY

Removed k-pareto sets (reason: too slow)

......@@ -9,7 +9,7 @@ TARGET = biominserter
CC = clang++
# compiling flags here
CFLAGS = -Icppsrc/ -I/usr/local/include -I$(ICONCERT) -I$(ICPLEX) -I$(INUPACK) -I$(IEIGEN) -O3
CFLAGS = -Icppsrc/ -I/usr/local/include -I$(ICONCERT) -I$(ICPLEX) -I$(INUPACK) -I$(IEIGEN) -O3
CXXFLAGS = --std=c++17 -Wall -Wpedantic -Wextra -Wno-ignored-attributes -Wno-unused-variable
LINKER = clang++
......
This diff is collapsed. Click to expand it.
......@@ -14,17 +14,18 @@ class MOIP
{
public:
MOIP(void);
MOIP(const RNA& rna, const vector<Motif>& motifSites, uint nsets, float pthreshold, bool verbose);
MOIP(const RNA& rna, const vector<Motif>& motifSites, float pthreshold, bool verbose);
~MOIP(void);
SecondaryStructure solve_objective(int o, double min, double max, const vector<IloConstraint>& F);
SecondaryStructure solve_objective(int o, double min, double max, const IloConstraintArray& F);
SecondaryStructure solve_objective(int o);
uint get_n_solutions(void) const;
const SecondaryStructure& solution(uint i) const;
void search_between(double lambdaMin, double lambdaMax, const vector<IloConstraint>& F_);
void search_between(double lambdaMin, double lambdaMax, const IloConstraintArray& F_);
bool allowed_basepair(size_t u, size_t v) const;
void add_solution(const SecondaryStructure& s);
void remove_solution(uint i);
vector<IloConstraint> forbid_solutions_between(double min, double max);
IloConstraintArray forbid_solutions_between(double min, double max);
IloEnv& get_env(void);
static uint obj_to_solve_; // What objective do you prefer to solve in mono-objective portions of the algorithm ?
static double precision_; // decimals to keep in objective values, to avoid numerical issues. otherwise, solution with objective 5.0000000009 dominates solution with 5.0 =(
static double epsilon_;
......@@ -46,7 +47,7 @@ class MOIP
RNA rna_; // RNA object
vector<Motif> insertion_sites_; // Potential Motif insertion sites
vector<SecondaryStructure> pareto_; // Vector of results
uint n_sets_; // number of Pareto sets to return
// uint n_sets_; // number of Pareto sets to return
// Objectives related
float theta_; // theta parameter for the probability function
......@@ -69,6 +70,7 @@ inline IloNumExprArg& MOIP::y(size_t u, size_t v) { return basepair_d
inline IloNumExprArg& MOIP::C(size_t x, size_t i) { return insertion_dv_[get_Cpxi_index(x, i)]; }
inline SecondaryStructure MOIP::solve_objective(int o)
{
return solve_objective(o, 0, rna_.get_RNA_length(), vector<IloConstraint>());
return solve_objective(o, 0, rna_.get_RNA_length(), IloConstraintArray(env_));
}
inline IloEnv& MOIP::get_env(void) { return env_; }
#endif // MOIP_H_
\ No newline at end of file
......
......@@ -14,7 +14,7 @@ SecondaryStructure::SecondaryStructure() {}
SecondaryStructure::SecondaryStructure(const RNA& rna)
: objective_scores_(vector<double>(2)), n_(rna.get_RNA_length()), nBP_(0), k_(0), rna_(rna)
: objective_scores_(vector<double>(2)), n_(rna.get_RNA_length()), nBP_(0), rna_(rna)
{
is_empty_structure = false;
}
......
......@@ -49,8 +49,8 @@ class SecondaryStructure
void insert_motif(const Motif& m);
double get_objective_score(int i) const;
void set_objective_score(int i, double s);
void set_pareto_set(uint k);
uint get_pareto_set(void) const;
// void set_pareto_set(uint k);
// uint get_pareto_set(void) const;
uint get_n_motifs(void) const;
uint get_n_bp(void) const;
void print(void) const;
......@@ -63,7 +63,7 @@ class SecondaryStructure
vector<Motif> motif_info_; // information about known motives in this secondary structure and their positions
size_t n_; // length of the RNA
size_t nBP_; // number of basepairs
uint k_; // Secondary Structure belongs to the kth Pareto set
// uint k_; // Secondary Structure belongs to the kth Pareto set
RNA rna_; // RNA object which is folded
bool is_empty_structure; // Empty structure, returned when the solver does not find solutions anymore
IloConstraint forbid_this_; // Add it to a cplex model to forbid that solution
......@@ -90,7 +90,7 @@ inline double SecondaryStructure::get_objective_score(int i) const { return obje
inline void SecondaryStructure::set_objective_score(int i, double s) { objective_scores_[i - 1] = s; }
inline uint SecondaryStructure::get_n_motifs(void) const { return motif_info_.size(); }
inline uint SecondaryStructure::get_n_bp(void) const { return nBP_; }
inline uint SecondaryStructure::get_pareto_set(void) const { return k_; }
inline void SecondaryStructure::set_pareto_set(uint k) { k_ = k; }
// inline uint SecondaryStructure::get_pareto_set(void) const { return k_; }
// inline void SecondaryStructure::set_pareto_set(uint k) { k_ = k; }
#endif
......
......@@ -116,20 +116,18 @@ int main(int argc, char* argv[])
/* FIND K-PARETO SETS */
MOIP myMOIP = MOIP(myRNA, posInsertionSites, 1, theta_p_threshold, verbose);
MOIP myMOIP = MOIP(myRNA, posInsertionSites, theta_p_threshold, verbose);
double min, max;
IloConstraintArray F(myMOIP.get_env());
try {
bestSSO1 = myMOIP.solve_objective(1, -__DBL_MAX__, __DBL_MAX__, vector<IloConstraint>());
bestSSO2 = myMOIP.solve_objective(2, -__DBL_MAX__, __DBL_MAX__, vector<IloConstraint>());
bestSSO1.set_pareto_set(1);
bestSSO2.set_pareto_set(1);
bestSSO1 = myMOIP.solve_objective(1, -__DBL_MAX__, __DBL_MAX__, F);
bestSSO2 = myMOIP.solve_objective(2, -__DBL_MAX__, __DBL_MAX__, F);
if (verbose) {
cout << endl << "Best solution according to objective 1 :" << bestSSO1.to_string() << endl;
cout << "Best solution according to objective 2 :" << bestSSO2.to_string() << endl;
}
double min, max;
vector<IloConstraint> F;
// extend the Pareto set on top
if (MOIP::obj_to_solve_ == 1) {
myMOIP.add_solution(bestSSO1);
......@@ -144,8 +142,9 @@ int main(int argc, char* argv[])
}
if (verbose)
cout << std::setprecision(8) << "\nSolving objective function " << MOIP::obj_to_solve_ << ", on top of "
<< min << ": Obj" << 3 - MOIP::obj_to_solve_ << " being in [" << min << ", " << max << "]..." << endl;
cout << std::setprecision(-log10(MOIP::precision_) + 4) << "\nSolving objective function "
<< MOIP::obj_to_solve_ << ", on top of " << min << ": Obj" << 3 - MOIP::obj_to_solve_ << " being in ["
<< min << ", " << max << "]..." << endl;
myMOIP.search_between(min, max, F); // F is empty
......@@ -162,35 +161,33 @@ int main(int argc, char* argv[])
F.clear();
F = myMOIP.forbid_solutions_between(min, max);
if (verbose)
cout << std::setprecision(8) << "\nSolving objective function " << MOIP::obj_to_solve_ << ", below (or eq. to) "
<< max << ": Obj" << 3 - MOIP::obj_to_solve_ << " being in [" << min << ", " << max << "]..." << endl
<< "\t>forbidding " << F.size() << " solutions found in [" << std::setprecision(10)
cout << std::setprecision(-log10(MOIP::precision_) + 4) << "\nSolving objective function "
<< MOIP::obj_to_solve_ << ", below (or eq. to) " << max << ": Obj" << 3 - MOIP::obj_to_solve_
<< " being in [" << min << ", " << max << "]..." << endl
<< "\t>forbidding " << F.getSize() << " solutions found in [" << std::setprecision(10)
<< min - MOIP::precision_ << ", " << max + MOIP::precision_ << ']' << endl;
myMOIP.search_between(min, max, F);
} catch (IloAlgorithm::NotExtractedException& e) {
cerr << e << endl;
exit(EXIT_FAILURE);
} catch (IloCplex::Exception& e) {
cerr << e << endl;
cerr << "Cplex Exception: " << e.getMessage() << endl;
exit(EXIT_FAILURE);
}
/* REMOVE SOLUTIONS WITH TOO HIGH LABEL */
vector<size_t> to_remove;
if (verbose) cout << endl;
for (uint i = 0; i < myMOIP.get_n_solutions(); i++)
if (myMOIP.solution(i).get_pareto_set() > 1) { // Some solution is fromm a Pareto set of too high order
if (verbose)
cout << "Removing structure from Pareto set " << myMOIP.solution(i).get_pareto_set() << " : "
<< myMOIP.solution(i).to_string() << endl;
to_remove.push_back(i);
}
if (to_remove.size()) {
for (size_t i = to_remove.size() - 1; i != 0; i--) myMOIP.remove_solution(to_remove[i]);
myMOIP.remove_solution(to_remove[0]);
}
// vector<size_t> to_remove;
// if (verbose) cout << endl;
// for (uint i = 0; i < myMOIP.get_n_solutions(); i++)
// if (myMOIP.solution(i).get_pareto_set() > 1) { // Some solution is fromm a Pareto set of too high order
// if (verbose)
// cout << "Removing structure from Pareto set " << myMOIP.solution(i).get_pareto_set() << " : "
// << myMOIP.solution(i).to_string() << endl;
// to_remove.push_back(i);
// }
// if (to_remove.size()) {
// for (size_t i = to_remove.size() - 1; i != 0; i--) myMOIP.remove_solution(to_remove[i]);
// myMOIP.remove_solution(to_remove[0]);
// }
/* DISPLAY RESULTS */
......