bool RObject::updateClasses (RData *new_data) { RK_TRACE (OBJECTS); RK_ASSERT (new_data->getDataLength () >= 1); // or can there be classless objects in R? RK_ASSERT (new_data->getDataType () == RData::StringVector); bool change = false; unsigned int new_len = new_data->getDataLength (); QString *new_classes = new_data->getStringVector (); new_data->detachData (); if (numClasses () != new_len) { change = true; } else { for (unsigned int cn=0; cn < numClasses (); ++cn) { if (classnames[cn] != new_classes[cn]) { change = true; break; } } } num_classes = new_len; delete [] classnames; classnames = new_classes; return change; }
bool RObject::inherits (const QString &class_name) { RK_TRACE (OBJECTS); for (unsigned int i=0; i < numClasses (); ++i) { if (getClassName (i) == class_name) { return true; } } return false; }
QString RObject::makeClassString (const QString &sep) { RK_TRACE (OBJECTS); QString ret; bool first = true; for (unsigned int i=0; i < numClasses (); ++i) { if (first) first = false; else ret.append (sep); ret.append (getClassName (i)); } return ret; }
MetronamicaOF2RandstadLargeCaseStudy3Obj(boost::filesystem::path & metro_exe, boost::filesystem::path & mck_exe, boost::filesystem::path & wine_exe, boost::filesystem::path & java_exe, boost::filesystem::path & geoproj_edit_jar, boost::filesystem::path & template_path, boost::filesystem::path & working_dir, boost::filesystem::path & save_dir, std::string &_wine_work_dir, std::string &_geoproj_name, boost::filesystem::path & _logfile_name, boost::filesystem::path & actual_map_path, boost::filesystem::path & original_map_path, boost::filesystem::path & masking_map_path, boost::filesystem::path & fks_coefficients_path, boost::filesystem::path & wine_regedit_path, int _id = 0, bool _is_logging = false, int _replicates = 10) : num_objectives(3), num_real_decision_vars(238), num_int_decision_vars(0), num_constraints(0), replicates(_replicates), geo_cmd(metro_exe), java_geoproj_edit(geoproj_edit_jar), mck_cmd(mck_exe), wine_cmd(wine_exe), java_cmd(java_exe), template_dir(template_path), working_dir(working_dir), save_dir(save_dir), wine_temp_dir(_wine_work_dir), geoproject_name(_geoproj_name), metro_logfile_name(_logfile_name), actual_map(actual_map_path), original_map(original_map_path), masking_map(masking_map_path), fks_coefficients(fks_coefficients_path), wine_regedit(wine_regedit_path), int_lowerbounds(0, std::numeric_limits<int>::min()), int_upperbounds(0, std::numeric_limits<int>::max()), prob_defs(new ProblemDefinitions(min_dv_values, max_dv_values, int_lowerbounds, int_upperbounds, minimise_or_maximise, num_constraints)), objectives_and_constrataints(std::piecewise_construct, std::make_tuple(num_objectives, std::numeric_limits<double>::max()), std::make_tuple(num_constraints)), evaluator_id(_id), is_logging(_is_logging), eval_count(0) { analysisNum = createAnalysis(); loadMapActual(analysisNum, actual_map.c_str()); loadOriginalMap(analysisNum, original_map.c_str()); loadMaskingMap(analysisNum, masking_map.c_str()); loadTransitionFuzzyWeights(analysisNum, fks_coefficients.c_str()); numClasses(analysisNum, 9); std::string temp_dir_template = "Metro_Cal_OF_worker" + std::to_string(evaluator_id) + "_%%%%-%%%%"; worker_dir = boost::filesystem::unique_path(working_dir / temp_dir_template); // create_directories(ph); copyDir(template_dir, worker_dir); namespace fs = boost::filesystem; std::string metro_cp_log_name = "calibration_log_%%%%-%%%%.xml"; boost::filesystem::path metro_cp_log_path = boost::filesystem::unique_path(worker_dir / metro_cp_log_name); fs::copy_file( metro_logfile_name, metro_cp_log_path ); cp_metro_log_name = metro_cp_log_path.filename().string(); // std::string filename = "logWorker" + std::to_string(evaluator_id) + "_WineRegEdit_" + boost::posix_time::to_simple_string(boost::posix_time::second_clock::local_time()) + ".log"; // boost::filesystem::path log_file_name = working_dir / filename; // std::ofstream logging_file; // if (is_logging) // { // logging_file.open(log_file_name.c_str(), std::ios_base::app); // if (!logging_file.is_open()) is_logging = false; // } // std::stringstream cmd; // cmd << wine_cmd << " regedit " << wine_regedit_path; // if (is_logging) cmd << " >> \"" << log_file_name.c_str() << "\" 2>&1"; // if (is_logging) logging_file << "Running: " << cmd.str() << "\n"; // system(cmd.str().c_str()); colour_mapper.push_back(std::make_tuple(255, 255, 160)); colour_mapper.push_back(std::make_tuple(255, 128, 0)); colour_mapper.push_back(std::make_tuple(255, 0, 0)); colour_mapper.push_back(std::make_tuple( 78, 0, 192)); colour_mapper.push_back(std::make_tuple(158, 12, 234)); colour_mapper.push_back(std::make_tuple(255, 87, 255)); colour_mapper.push_back(std::make_tuple( 0, 192, 0)); colour_mapper.push_back(std::make_tuple(192, 157, 0)); colour_mapper.push_back(std::make_tuple( 0, 0, 0)); colour_mapper.push_back(std::make_tuple( 0, 128, 255)); //Make sure the number of dv is correct BOOST_ASSERT(max_dv_values.size() == 520); }