Louis BECQUEY

Different criteria as a command line option

......@@ -17,8 +17,9 @@ using std::endl;
using std::make_pair;
using std::vector;
uint MOIP::obj_to_solve_ = 1;
double MOIP::precision_ = 1e-5;
uint MOIP::obj_function_nbr_ = 1;
uint MOIP::obj_to_solve_ = 1;
double MOIP::precision_ = 1e-5;
unsigned getNumConstraints(IloModel& m)
{
......@@ -127,21 +128,41 @@ MOIP::MOIP(const RNA& rna, const vector<Motif>& insertionSites, float theta, boo
model_ = IloModel(env_);
define_problem_constraints();
if (verbose_) cout << "A total of " << getNumConstraints(model_) << " constraints are used." << endl;
if (getNumConstraints(model_) > 1500) {
cerr << "\033[31m Quitting because too hard for me (too many constraints). Srry. \033[0m" << endl;
exit(1);
}
// Define the motif objective function:
obj1 = IloExpr(env_);
for (uint i = 0; i < insertion_sites_.size(); i++) {
// objective f_1A
// IloNum n_compo_squared = IloNum(insertion_sites_[i].comp.size() * insertion_sites_[i].comp.size());
// obj1 += n_compo_squared * insertion_dv_[index_of_first_components[i]];
// Weighted by the JAR3D score:
// obj1 += IloNum(insertion_sites_[i].score) * insertion_dv_[index_of_first_components[i]];
// RNA MoIP style
IloNum sum_k = 0;
for (const Component& c : insertion_sites_[i].comp) sum_k += c.k;
obj1 += IloNum(sum_k * sum_k) * insertion_dv_[index_of_first_components[i]];
switch (obj_function_nbr_) {
case 1:
// RNA MoIP style
for (const Component& c : insertion_sites_[i].comp) sum_k += c.k;
obj1 += IloNum(sum_k * sum_k) * insertion_dv_[index_of_first_components[i]];
break;
case 2:
// Weighted by the JAR3D score only:
obj1 += IloNum(insertion_sites_[i].score_) * insertion_dv_[index_of_first_components[i]];
break;
case 3:
// everything
for (const Component& c : insertion_sites_[i].comp) sum_k += c.k;
obj1 += IloNum(insertion_sites_[i].comp.size() * insertion_sites_[i].score_ / log2(sum_k)) *
insertion_dv_[index_of_first_components[i]];
break;
case 4:
// everything but Jar3D score
for (const Component& c : insertion_sites_[i].comp) sum_k += c.k;
obj1 += IloNum(insertion_sites_[i].comp.size() / log2(sum_k)) * insertion_dv_[index_of_first_components[i]];
break;
}
}
// Define the expected accuracy objective function:
......@@ -470,7 +491,6 @@ bool MOIP::exists_vertical_outdated_labels(const SecondaryStructure& s) const
return result;
}
bool MOIP::exists_horizontal_outdated_labels(const SecondaryStructure& s) const
{
bool result = false;
......@@ -490,6 +510,10 @@ void MOIP::add_solution(const SecondaryStructure& s)
{
if (verbose_) cout << "\t>adding structure to Pareto set :\t" << s.to_string() << endl;
pareto_.push_back(s);
if (pareto_.size() > 300) {
cerr << "\033[31m Quitting because combinatorial issues. \033[0m";
exit(1);
}
}
size_t MOIP::get_yuv_index(size_t u, size_t v) const
......
......@@ -26,6 +26,7 @@ class MOIP
void remove_solution(uint i);
void forbid_solutions_between(double min, double max);
IloEnv& get_env(void);
static uint obj_function_nbr_; // On what criteria do you want to insert motifs ?
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 =(
......
......@@ -57,6 +57,7 @@ int main(int argc, char* argv[])
string inputName, outputName, motifs_path_name, basename;
bool verbose = false;
float theta_p_threshold;
int obj_function_nbr = 3;
list<Fasta> f;
vector<Motif> posInsertionSites;
ofstream outfile;
......@@ -79,7 +80,12 @@ int main(int argc, char* argv[])
"Objective to solve in the mono-objective portions of the algorithm")("output,o", po::value<string>(&outputName), "A file to summarize the computation results")(
"theta,t",
po::value<float>(&theta_p_threshold)->default_value(0.001),
"Pairing probability threshold to consider or not the possibility of pairing")("verbose,v", "Print what is happening to stdout");
"Pairing probability threshold to consider or not the possibility of pairing")(
"type",
po::value<int>(&obj_function_nbr),
"If -f is provided, what objective function to use to include motifs: square of motif size in nucleotides like "
"RNA-MoIP (1), jar3d score (2), motif size + jar3d score + number of components (3), motif size + number of "
"components (4)")("verbose,v", "Print what is happening to stdout");
po::variables_map vm;
po::store(po::parse_command_line(argc, argv, desc), vm);
basename = remove_ext(inputName.c_str(), '.', '/');
......@@ -103,23 +109,33 @@ int main(int argc, char* argv[])
}
if (vm.count("verbose")) verbose = true;
if (!vm.count("jar3dcsv") and !vm.count("descfolder")) {
cerr << "You must provide at least --jar3dcsv or --descfolder. See --help for more information." << endl;
cerr << "\033[31mYou must provide at least --jar3dcsv or --descfolder.\033[0m See --help for more "
"information."
<< endl;
return EXIT_FAILURE;
}
if (vm.count("-d") and (obj_function_nbr == 1 or obj_function_nbr == 3)) {
cerr << "\033[31mYou must provide at -f to use --type 1 or --type 3.\033[0m See --help for more "
"information."
<< endl;
return EXIT_FAILURE;
}
po::notify(vm); // throws on error, so do after help in case there are any problems
} catch (po::error& e) {
cerr << "ERROR: " << e.what() << endl;
cerr << "ERROR: \033[31m" << e.what() << "\033[0m" << endl;
cerr << desc << endl;
return EXIT_FAILURE;
}
MOIP::obj_function_nbr_ = obj_function_nbr;
/* FILE PARSING */
// load fasta file
if (verbose) cout << "Reading input files..." << endl;
if (access(inputName.c_str(), F_OK) == -1) {
cerr << inputName << " not found" << endl;
cerr << "\033[31m" << inputName << " not found\033[0m" << endl;
return EXIT_FAILURE;
}
Fasta::load(f, inputName.c_str());
......@@ -130,7 +146,7 @@ int main(int argc, char* argv[])
// load CSV file
if (access(motifs_path_name.c_str(), F_OK) == -1) {
cerr << motifs_path_name << " not found" << endl;
cerr << "\033[31m" << motifs_path_name << " not found\033[0m" << endl;
return EXIT_FAILURE;
}
if (vm.count("jar3dcsv"))
......@@ -190,7 +206,7 @@ int main(int argc, char* argv[])
myMOIP.search_between(min, max);
} catch (IloCplex::Exception& e) {
cerr << "Cplex Exception: " << e.getMessage() << endl;
cerr << "\033[31mCplex Exception: " << e.getMessage() << "\033[0m" << endl;
exit(EXIT_FAILURE);
}
......
This diff is collapsed. Click to expand it.