int main(int argc, char const *argv[]) { std::string FILE="/homes/kgori/scratch/basic_pll/GGPS1.phy"; std::string PART="/homes/kgori/scratch/basic_pll/GGPS1.partitions.txt"; std::string TREE="/homes/kgori/scratch/basic_pll/GGPS1.tree"; auto inst = make_unique<pll>(FILE, PART, TREE, 1, 123); std::cout << inst->get_likelihood() << std::endl; std::cout << inst->get_partition_name(0) << std::endl; std::cout << inst->get_model_name(0) << std::endl; std::cout << inst->get_epsilon() << std::endl; std::cout << inst->get_alpha(0) << std::endl; std::cout << inst->get_number_of_partitions() << std::endl; std::cout << inst->get_tree() << std::endl; std::cout << inst->get_frac_change() << std::endl; inst->set_tree("((Ptro:0.00147084048849247711,Ppan:0.00106294370976534763):0.00444598321816729036,(Cjac:0.05157798212603657839,(Csab:0.00440006365327790666,(Mmul:0.00652936575529242547,Panu:0.00101047194512476272):0.00381049900890796569):0.01359968787254225639):0.01375788728353777995,Hsap:0.00674547067186638278):0.0;"); inst->set_epsilon(0.001); inst->set_alpha(2, 0, true); auto ef = inst->get_empirical_frequencies(); inst->optimise(true, true, true, true); inst->optimise_tree_search(true); std::cout << inst->get_likelihood() << std::endl; std::cout << inst->get_tree() << std::endl; return 0; }
bool MtxLP::isBottleNeck(stomap* obj, string rx, bool max, bool presolve){ double lb = getColLB(rx), ub = getColUB(rx); setColBnds(rx, LB, UB); optimise(obj, max, presolve); bool rv = !is_zero(getObjValue()); setColBnds(rx, lb, ub); return rv; }
bool Airspaces::synchronise_in_range(const Airspaces& master, const GeoPoint &location, const fixed range, const AirspacePredicate &condition) { bool changed = false; const AirspaceVector contents_master = master.scan_range(location, range, condition); AirspaceVector contents_self; contents_self.reserve(max(airspace_tree.size(), contents_master.size())); task_projection = master.task_projection; // ensure these are up to date for (auto t = airspace_tree.begin(); t != airspace_tree.end(); ++t) contents_self.push_back(*t); // find items to add for (auto v = contents_master.begin(); v != contents_master.end(); ++v) { const AbstractAirspace* other = v->get_airspace(); bool found = false; for (auto s = contents_self.begin(); s != contents_self.end(); ++s) { const AbstractAirspace* self = s->get_airspace(); if (self == other) { found = true; contents_self.erase(s); break; } } if (!found && other->IsActive()) { insert(v->get_airspace()); changed = true; } } // anything left in the self list are items that were not in the query, // so delete them --- including the clearances! for (auto v = contents_self.begin(); v != contents_self.end();) { bool found = false; for (auto t = airspace_tree.begin(); t != airspace_tree.end(); ) { if (t->get_airspace() == v->get_airspace()) { AirspaceTree::const_iterator new_t = t; ++new_t; airspace_tree.erase_exact(*t); t = new_t; found = true; } else { ++t; } } assert(found); v->clear_clearance(); v = contents_self.erase(v); changed = true; } if (changed) optimise(); return changed; }
bool Trace::optimise_if_old() { if (m_last_point.time > m_optimise_time + 60) { optimise(); return true; } return false; }
bool objlist_remove(ObjList **objlist, Obj *obj) { ObjList *node=objlist_find_node(*objlist, obj); if(node!=NULL) free_node(objlist, node); optimise(objlist); return (node!=NULL); }
optimise_result<T1, N> optimise( const T2<T1, N>& problem) { // TODO predict solver // TODO extend problem to track the optimal parameters const auto& results = optimise(problem, hooke_jeeves_algorithm<T1, N>()); // TODO add results return results; }
//---------- void SolveSet::solveNL() { if (this->dataSet.empty()) { throw(ofxRulr::Exception("Data set is empty!")); } this->model.initialiseParameters(); auto fitter = make_shared<ofxNonLinearFit::Fit<ofxNonLinearFit::Models::RigidBody>>(); double residual; bool success; auto startTime = chrono::system_clock::now(); if (this->parameters.nlSettings.trimOutliers == 0.0f) { //Use full data set. success = fitter->optimise(this->model, &this->dataSet, &residual); } else { //Use subset with top results. This will only work if the full set is calculated previously. auto firstIt = dataSet.begin(); auto lastIt = firstIt + (int)(this->dataSet.size() * (1.0f - this->parameters.nlSettings.trimOutliers)); ofxNonLinearFit::Models::RigidBody::DataSet subSet(firstIt, lastIt); success = fitter->optimise(this->model, &subSet, &residual); } auto endTime = chrono::system_clock::now(); sort(this->dataSet.begin(), this->dataSet.end(), [this](auto & a, auto & b) { return (this->model.getResidual(a) < this->model.getResidual(b)); }); this->result.success = success; this->result.totalTime = endTime - startTime; this->result.residual = residual; this->result.transform = this->model.getCachedTransform(); this->completed = true; }
bool objlist_reinsert_first(ObjList **objlist, Obj *obj) { ObjList *node; optimise(objlist); node=objlist_find_node(*objlist, obj); if(node==NULL) return objlist_insert_first(objlist, obj); UNLINK_ITEM(*objlist, node, next, prev); LINK_ITEM_FIRST(*objlist, node, next, prev); return TRUE; }
void Waypoints::add_takeoff_point(const GeoPoint& location, const fixed terrain_alt) { // remove old one first const Waypoint *old_takeoff_point = lookup_name(_T("(takeoff)")); if (old_takeoff_point != NULL) erase(*old_takeoff_point); const Waypoint *nearest_landable = get_nearest_landable(location, fixed(5000)); if (!nearest_landable) { // now add new and update database Waypoint new_waypoint = generate_takeoff_point(location, terrain_alt); append(new_waypoint); } optimise(); }
Obj *objlist_take_first(ObjList **objlist) { ObjList *node; Obj*obj; optimise(objlist); node=*objlist; if(node==NULL) return NULL; obj=node->watch.obj; assert(obj!=NULL); free_node(objlist, node); return obj; }
void MtxLP::fixSolution(stomap* targ, bool max, bool tmp, bool withzeroes, bool presolve, double scale){ optimise(targ, max, presolve); for (stomap::iterator i = targ->begin(); i != targ->end(); i++){ string name = i->first; if (ncol(name) != 0){ double coef = getColValue(name); if (withzeroes || !is_zero(coef)) fix(name, coef * scale, tmp); } else{ stomap* rsto = getRowSto(name); for (stomap::iterator j = rsto->begin(); j != rsto->end(); j++){ string name = j->first; double coef = getColValue(name); if (withzeroes || !is_zero(coef)) fix(name, coef * scale, tmp); } delete rsto; } } }
optimise_result<T1, N> optimise( const T2<T1, N>& problem, const T3<T1, N>& optimiser) { std::vector<std::array<T1, N>> initial_parameters; if (std::is_base_of<nelder_mead_method<T1, N>, T3<T1, N>>::value) { initial_parameters.resize(N + 1); } else if (std::is_base_of<particle_swarm_optimisation<T1, N>, T3<T1, N>>::value) { initial_parameters.resize(10 * N); } else { initial_parameters.resize(1); } for (auto& parameter : initial_parameters) { std::transform( problem.lower_bounds.cbegin(), problem.lower_bounds.cend(), problem.upper_bounds.cbegin(), parameter.begin(), [](const auto lower_bound, const auto upper_bound) { return lower_bound + std::uniform_real_distribution<T1>(0.0, 1.0)(random_number_generator()) * (upper_bound - lower_bound); }); } return optimise(problem, optimiser, initial_parameters); }
bool MtxLP::isCutSet(stomap* obj, strvec set, bool max, bool presolve){ block(&set, true); optimise(obj, max, presolve); cleanTmpRows(set.size()); return is_zero(getObjValue()); }
bool MtxLP::isEssential(stomap* obj, string col, bool max, bool presolve){ block(col, true); optimise(obj, max, presolve); cleanTmpRows(1); return is_zero(getObjValue()); }
void MtxLP::getOptSol(stomap* sol, stomap* targ, bool max, int kind, bool withzeroes, bool presolve){ optimise(targ, max, presolve); getSolution(sol, kind, withzeroes); }
void DifferentialEvolution::optimise( OptimisationProblem& optimisationProblem) { optimise(optimisationProblem, arma::randu<arma::mat>(optimisationProblem.numberOfDimensions_, populationSize_)); }
double MtxLP::getOptVal(stomap* targ, bool max, bool presolve){ optimise(targ, max, presolve); return getObjValue(); }
void SimulatedAnnealing::optimise( OptimisationProblem& optimisationProblem) { // Objects like `optimisationProblem` perform all validations by themselves. optimise(optimisationProblem, arma::randu<arma::vec>(optimisationProblem.numberOfDimensions_)); }