/* Main - create the threads and start the processing */ int main(int argc, char *argv[]) { /* Check for argument count */ if (argc != 2) { std::cerr << "Invalid number of arguments." << std::endl; return -1; } /* Read the path to the data */ std::string path(argv[1]); /* Read the list of directories to process */ std::string image_list_filename = path + "image_list.dat"; std::vector<std::string> input_images; FILE *file = fopen(image_list_filename.c_str(), "r"); if (!file) { std::cerr << "Could not open 'image_list.dat' inside '" << path << "'." << std::endl; return -1; } char line[128]; while (fgets(line, sizeof(line), file) != NULL) { line[strlen(line)-1] = 0; std::string temp_str(line); input_images.push_back(temp_str); } fclose(file); /* Create and prepare the file for metrics */ std::string metrics_file = path + "computed_metrics.csv"; std::ofstream data_stream; data_stream.open(metrics_file, std::ios::out); if (!data_stream.is_open()) { std::cerr << "Could not create the metrics file." << std::endl; return -1; } data_stream << std::endl; data_stream.close(); /* Process each image */ for (unsigned int index = 0; index < input_images.size(); index++) { std::cout << "Processing " << input_images[index] << std::endl; if (!processDir(path, input_images[index], metrics_file)) { std::cout << "ERROR !!!" << std::endl; return -1; } } return 0; }
//static void LLFloaterTeleportHistory::loadFile(const std::string &file_name) { LLFloaterTeleportHistory *pFloaterHistory = LLFloaterTeleportHistory::findInstance(); if(!pFloaterHistory) return; LLScrollListCtrl* pScrollList = pFloaterHistory->mPlacesList; if(!pScrollList) return; std::string temp_str(gDirUtilp->getLindenUserDir() + gDirUtilp->getDirDelimiter() + file_name); llifstream file(temp_str); if (file.is_open()) { LL_INFOS() << "Loading "<< file_name << " file at " << temp_str << LL_ENDL; LLSD data; LLSDSerialize::fromXML(data, file); if (data.isUndefined()) { LL_INFOS() << "file missing, ill-formed, " "or simply undefined; not reading the" " file" << LL_ENDL; } else { const S32 max_entries = gSavedSettings.getS32("TeleportHistoryMaxEntries"); const S32 num_entries = llmin(max_entries,(const S32)data.size()); pScrollList->clear(); for(S32 i = 0; i < num_entries; i++) //Lower entry = newer { pScrollList->addElement(data[i], ADD_BOTTOM); } pScrollList->deselectAllItems(TRUE); pFloaterHistory->mID = pScrollList->getItemCount(); pFloaterHistory->setButtonsEnabled(FALSE); } } }
int main(int argc, char *argv[]) { if(argc < 5){ std::cout << " Invalid number of arguments to " << argv[0] << std::endl; std::cout << " SYNTAX: " << argv[0] << " [module] [channel] [parameter] [value]\n\n"; return 1; } int mod = atoi(argv[1]); int ch = atoi(argv[2]); double value = std::strtod(argv[4], NULL); PixieInterface pif("pixie.cfg"); pif.GetSlots(); pif.Init(); pif.Boot(PixieInterface::DownloadParameters | PixieInterface::ProgramFPGA | PixieInterface::SetDAC, true); std::string temp_str(argv[3]); ParameterChannelWriter writer; if(forChannel(&pif, mod, ch, writer, make_pair(temp_str, value))){ pif.SaveDSPParameters(); } return 0; }
void printRuleData(RuleStruct* _rule, std::vector<std::string> *massive_of_tokens){ if(_rule->_variable.size() == 0){ //printf("%s;\n ", _rule->_rule_uniq_name.c_str()); global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); global_string_with_graph.append(";\n"); } //bool should_print_lable = false; //if (_rule->_variable.size() >1){ // should_print_lable = true; //} /* for (auto i = _rule->_variable.begin(); i!= _rule->_variable.end(); ++i){ if ((*i)!=NULL) { //printf("%s -> ", _rule->_rule_uniq_name.c_str()); global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); global_string_with_graph.append(" -> "); printVariableData((*i)); } } */ global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); global_string_with_graph.append(";\n"); global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); global_string_with_graph.append("[label=\""); //global_string_with_graph.append("{"); global_string_with_graph.append(_rule->_name.c_str()); global_string_with_graph.append("|"); global_string_with_graph.append("{"); int temp_count_i = _rule->_variable.size(); for (int i=0; i< temp_count_i; i++){ global_string_with_graph.append("<"); global_string_with_graph.append("var_"); global_string_with_graph.append(returnIntToString(i)); global_string_with_graph.append(">"); std::string temp_str(_rule->_variable[i]->_name); if (temp_str.find("'") != std::string::npos){ temp_str = temp_str.substr(temp_str.find("'")+1); temp_str = temp_str.substr(0,temp_str.find("'")); global_string_with_graph.append("\\"); } global_string_with_graph.append(temp_str); if (i < temp_count_i-1){ global_string_with_graph.append("|"); } } global_string_with_graph.append("} \" style=filled gradientangle=90 fillcolor=\"cornsilk;0.5:aquamarine\"];\n"); /* global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); global_string_with_graph.append(";\n"); global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); global_string_with_graph.append("[label=<<table><tr><td bgcolor=\"#7FFFD4\" colspan=\""); int temp_count_i = _rule->_variable.size(); // не нужна проверка - дот их игнорирует global_string_with_graph.append(returnIntToString(temp_count_i)); global_string_with_graph.append("\">"); global_string_with_graph.append(_rule->_name.c_str()); global_string_with_graph.append("</td></tr>"); global_string_with_graph.append("<tr>"); for (int i = 0; i < temp_count_i; ++i) { global_string_with_graph.append("<td bgcolor=\""); if (isItToken(_rule->_variable[i],massive_of_tokens)){ global_string_with_graph.append("#7EC0EE"); } else { global_string_with_graph.append("#FFF68F"); } global_string_with_graph.append("\">"); std::string temp_str(_rule->_variable[i]->_name); if (temp_str.find("'") != std::string::npos){ temp_str = temp_str.substr(temp_str.find("'")+1); temp_str = temp_str.substr(0,temp_str.find("'")); //global_string_with_graph.append("\\"); if (temp_str.compare("<") == 0){ temp_str.assign("<"); } if (temp_str.compare(">") == 0){ temp_str.assign(">"); } if (temp_str.compare("{") == 0 || temp_str.compare("}") == 0 ){ global_string_with_graph.append("\\"); } } global_string_with_graph.append(temp_str); global_string_with_graph.append("</td>"); } if (temp_count_i == 0) { global_string_with_graph.append("<td bgcolor=\"#7FFFD4\"> </td>"); } global_string_with_graph.append("</tr></table>>]\n"); */ /* for (int i=0; i< _rule->_variable.size(); i++){ if (_rule->_variable[i] != NULL){ //global_string_with_graph.append(_rule->_rule_uniq_name.c_str()); //global_string_with_graph.append(";\n"); //global_string_with_graph.append(); printVariableData(_rule->_variable[i],_rule,i, massive_of_tokens); } } */ };
/* Main - create the threads and start the processing */ int main(int argc, char *argv[]) { /* Check for argument count */ if (argc != 2) { std::cerr << "Invalid number of arguments." << std::endl; return -1; } /* Read the path to the data */ std::string path(argv[1]); /* Read the list of directories to process */ std::string image_list_filename = path + "image_list.dat"; std::vector<std::string> input_images; FILE *file = fopen(image_list_filename.c_str(), "r"); if (!file) { std::cerr << "Could not open 'image_list.dat' inside '" << path << "'." << std::endl; return -1; } char line[128]; while (fgets(line, sizeof(line), file) != NULL) { line[strlen(line)-1] = 0; std::string temp_str(line); if (temp_str.find("dapi") == std::string::npos) continue; input_images.push_back(temp_str); } fclose(file); /* Create the scatterplot Control and SZ file */ // Create the plots directory std::string plots_directory = path + PLOTS_DIR_NAME; struct stat st = {0}; if (stat(plots_directory.c_str(), &st) == -1) { mkdir(plots_directory.c_str(), 0700); } std::ofstream scatterplot_stream; // Control std::string scatter_control_file = plots_directory + SCATTERPLOT_CONTROL; scatterplot_stream.open(scatter_control_file, std::ios::out); if (!scatterplot_stream.is_open()) { std::cerr << "Could not create the scatter plot Control file." << std::endl; return -1; } scatterplot_stream.close(); // SZ std::string scatter_sz_file = plots_directory + SCATTERPLOT_SZ; scatterplot_stream.open(scatter_sz_file, std::ios::out); if (!scatterplot_stream.is_open()) { std::cerr << "Could not create the scatter plot SZ file." << std::endl; return -1; } scatterplot_stream.close(); /* Create and prepare the file for metrics */ std::string metrics_file_name = path.substr(path.find_first_of("/")+1); std::size_t found = metrics_file_name.find_first_of("/"); assert(found != std::string::npos); metrics_file_name[found] = '_'; found = metrics_file_name.find_first_of(" "); while (found != std::string::npos) { metrics_file_name[found] = '_'; found = metrics_file_name.find_first_of(" ", found+1); } std::string metrics_file = path + "metrics_" + metrics_file_name + ".csv"; std::ofstream data_stream; data_stream.open(metrics_file, std::ios::out); if (!data_stream.is_open()) { std::cerr << "Could not create the metrics file." << std::endl; return -1; } data_stream << "Merged Image,"; data_stream << "DAPI-GFP Cell Count,"; data_stream << "DAPI-GFP Soma Diameter (mean),"; data_stream << "DAPI-GFP Soma Diameter (std. dev.),"; data_stream << "DAPI-GFP Soma Aspect Ratio (mean),"; data_stream << "DAPI-GFP Soma Aspect Ratio (std. dev.),"; data_stream << "DAPI-GFP Soma Error Ratio (mean),"; data_stream << "DAPI-GFP Soma Error Ratio (std. dev.),"; data_stream << "DAPI-RFP Cell Count,"; data_stream << "DAPI-RFP Soma Diameter (mean),"; data_stream << "DAPI-RFP Soma Diameter (std. dev.),"; data_stream << "DAPI-RFP Soma Aspect Ratio (mean),"; data_stream << "DAPI-RFP Soma Aspect Ratio (std. dev.),"; data_stream << "DAPI-RFP Soma Error Ratio (mean),"; data_stream << "DAPI-RFP Soma Error Ratio (std. dev.),"; // GFP (low, medium and high) bins data_stream << "GFP_Low_Contour_Count,"; for (unsigned int i = 0; i < NUM_AREA_BINS-1; i++) { data_stream << i*BIN_AREA << " <= GFP_Low_Contour_Area < " << (i+1)*BIN_AREA << ","; } data_stream << "GFP_Low_Contour_Area >= " << (NUM_AREA_BINS-1)*BIN_AREA << ","; data_stream << "GFP_Medium_Contour_Count,"; for (unsigned int i = 0; i < NUM_AREA_BINS-1; i++) { data_stream << i*BIN_AREA << " <= GFP_Medium_Contour_Area < " << (i+1)*BIN_AREA << ","; } data_stream << "GFP_Medium_Contour_Area >= " << (NUM_AREA_BINS-1)*BIN_AREA << ","; data_stream << "GFP_High_Contour_Count,"; for (unsigned int i = 0; i < NUM_AREA_BINS-1; i++) { data_stream << i*BIN_AREA << " <= GFP_High_Contour_Area < " << (i+1)*BIN_AREA << ","; } data_stream << "GFP_High_Contour_Area >= " << (NUM_AREA_BINS-1)*BIN_AREA << ","; data_stream << std::endl; data_stream.close(); /* Process each image */ for (unsigned int index = 0; index < input_images.size(); index++) { std::cout << "Processing " << input_images[index] << std::endl; if (!processDir(path, input_images[index], metrics_file)) { std::cout << "ERROR !!!" << std::endl; return -1; } } /* Generate the scatter plot */ std::cout << "Calculating the scatter plot statistics." << std::endl; scatterPlotStat(plots_directory); return 0; }
void * weechat_js_exec (struct t_plugin_script *script, int ret_type, const char *function, const char *format, void **argv) { struct t_plugin_script *old_js_current_script; WeechatJsV8 *js_v8; void *ret_value; v8::Handle<v8::Value> argv2[16], ret_js; int i, argc, *ret_int; ret_value = NULL; old_js_current_script = js_current_script; js_current_script = script; js_v8 = (WeechatJsV8 *)(script->interpreter); if (!js_v8->functionExists(function)) { weechat_printf (NULL, weechat_gettext ("%s%s: unable to run function \"%s\""), weechat_prefix ("error"), JS_PLUGIN_NAME, function); goto end; } argc = 0; if (format && format[0]) { argc = strlen (format); for (i = 0; i < argc; i++) { switch (format[i]) { case 's': /* string */ argv2[i] = v8::String::New((const char *)argv[i]); break; case 'i': /* integer */ argv2[i] = v8::Integer::New(*((int *)argv[i])); break; case 'h': /* hash */ argv2[i] = weechat_js_hashtable_to_object ( (struct t_hashtable *)argv[i]); break; } } } ret_js = js_v8->execFunction(function, argc, (argc > 0) ? argv2 : NULL); if (!ret_js.IsEmpty()) { if ((ret_type == WEECHAT_SCRIPT_EXEC_STRING) && (ret_js->IsString())) { v8::String::Utf8Value temp_str(ret_js); ret_value = (*temp_str) ? strdup(*temp_str) : NULL; } else if ((ret_type == WEECHAT_SCRIPT_EXEC_INT) && (ret_js->IsInt32())) { ret_int = (int *)malloc (sizeof (*ret_int)); if (ret_int) *ret_int = (int)(ret_js->IntegerValue()); ret_value = ret_int; } else if ((ret_type == WEECHAT_SCRIPT_EXEC_HASHTABLE) && (ret_js->IsObject())) { ret_value = (struct t_hashtable *)weechat_js_object_to_hashtable ( ret_js->ToObject(), WEECHAT_SCRIPT_HASHTABLE_DEFAULT_SIZE, WEECHAT_HASHTABLE_STRING, WEECHAT_HASHTABLE_STRING); } else { if (ret_type != WEECHAT_SCRIPT_EXEC_IGNORE) { weechat_printf (NULL, weechat_gettext ("%s%s: function \"%s\" must " "return a valid value"), weechat_prefix ("error"), JS_PLUGIN_NAME, function); } } } if ((ret_type != WEECHAT_SCRIPT_EXEC_IGNORE) && !ret_value) { weechat_printf (NULL, weechat_gettext ("%s%s: error in function \"%s\""), weechat_prefix ("error"), JS_PLUGIN_NAME, function); } end: js_current_script = old_js_current_script; return ret_value; }
// performs the rl update at a state void rl_perform_update( agent *my_agent, double op_value, bool op_rl, Symbol *goal, bool update_efr ) { bool using_gaps = ( my_agent->rl_params->temporal_extension->get_value() == soar_module::on ); if ( !using_gaps || op_rl ) { rl_data *data = goal->id.rl_info; if ( !data->prev_op_rl_rules->empty() ) { rl_et_map::iterator iter; double alpha = my_agent->rl_params->learning_rate->get_value(); double lambda = my_agent->rl_params->et_decay_rate->get_value(); double gamma = my_agent->rl_params->discount_rate->get_value(); double tolerance = my_agent->rl_params->et_tolerance->get_value(); double theta = my_agent->rl_params->meta_learning_rate->get_value(); // if temporal_discount is off, don't discount for gaps unsigned int effective_age = data->hrl_age + 1; if (my_agent->rl_params->temporal_discount->get_value() == soar_module::on) { effective_age += data->gap_age; } double discount = pow( gamma, static_cast< double >( effective_age ) ); // notify of gap closure if ( data->gap_age && using_gaps && my_agent->sysparams[ TRACE_RL_SYSPARAM ] ) { char buf[256]; SNPRINTF( buf, 254, "gap ended (%c%llu)", goal->id.name_letter, static_cast<long long unsigned>(goal->id.name_number) ); print( my_agent, buf ); xml_generate_warning( my_agent, buf ); } // Iterate through eligibility_traces, decay traces. If less than TOLERANCE, remove from map. if ( lambda == 0 ) { if ( !data->eligibility_traces->empty() ) { data->eligibility_traces->clear(); } } else { for ( iter = data->eligibility_traces->begin(); iter != data->eligibility_traces->end(); ) { iter->second *= lambda; iter->second *= discount; if ( iter->second < tolerance ) { data->eligibility_traces->erase( iter++ ); } else { ++iter; } } } // Update trace for just fired prods double sum_old_ecr = 0.0; double sum_old_efr = 0.0; if ( !data->prev_op_rl_rules->empty() ) { double trace_increment = ( 1.0 / static_cast<double>( data->prev_op_rl_rules->size() ) ); rl_rule_list::iterator p; for ( p=data->prev_op_rl_rules->begin(); p!=data->prev_op_rl_rules->end(); p++ ) { sum_old_ecr += (*p)->rl_ecr; sum_old_efr += (*p)->rl_efr; iter = data->eligibility_traces->find( (*p) ); if ( iter != data->eligibility_traces->end() ) { iter->second += trace_increment; } else { (*data->eligibility_traces)[ (*p) ] = trace_increment; } } } // For each prod with a trace, perform update { double old_ecr, old_efr; double delta_ecr, delta_efr; double new_combined, new_ecr, new_efr; double delta_t = (data->reward + discount * op_value) - (sum_old_ecr + sum_old_efr); for ( iter = data->eligibility_traces->begin(); iter != data->eligibility_traces->end(); iter++ ) { production *prod = iter->first; // get old vals old_ecr = prod->rl_ecr; old_efr = prod->rl_efr; // Adjust alpha based on decay policy // Miller 11/14/2011 double adjusted_alpha; switch (my_agent->rl_params->decay_mode->get_value()) { case rl_param_container::exponential_decay: adjusted_alpha = 1.0 / (prod->rl_update_count + 1.0); break; case rl_param_container::logarithmic_decay: adjusted_alpha = 1.0 / (log(prod->rl_update_count + 1.0) + 1.0); break; case rl_param_container::delta_bar_delta_decay: { // Note that in this case, x_i = 1.0 for all productions that are being updated. // Those values have been included here for consistency with the algorithm as described in the delta bar delta paper. prod->rl_delta_bar_delta_beta = prod->rl_delta_bar_delta_beta + theta * delta_t * 1.0 * prod->rl_delta_bar_delta_h; adjusted_alpha = exp(prod->rl_delta_bar_delta_beta); double decay_term = 1.0 - adjusted_alpha * 1.0 * 1.0; if (decay_term < 0.0) decay_term = 0.0; prod->rl_delta_bar_delta_h = prod->rl_delta_bar_delta_h * decay_term + adjusted_alpha * delta_t * 1.0; break; } case rl_param_container::normal_decay: default: adjusted_alpha = alpha; break; } // calculate updates delta_ecr = ( adjusted_alpha * iter->second * ( data->reward - sum_old_ecr ) ); if ( update_efr ) { delta_efr = ( adjusted_alpha * iter->second * ( ( discount * op_value ) - sum_old_efr ) ); } else { delta_efr = 0.0; } // calculate new vals new_ecr = ( old_ecr + delta_ecr ); new_efr = ( old_efr + delta_efr ); new_combined = ( new_ecr + new_efr ); // print as necessary if ( my_agent->sysparams[ TRACE_RL_SYSPARAM ] ) { std::ostringstream ss; ss << "RL update " << prod->name->sc.name << " " << old_ecr << " " << old_efr << " " << old_ecr + old_efr << " -> " << new_ecr << " " << new_efr << " " << new_combined ; std::string temp_str( ss.str() ); print( my_agent, "%s\n", temp_str.c_str() ); xml_generate_message( my_agent, temp_str.c_str() ); // Log update to file if the log file has been set std::string log_path = my_agent->rl_params->update_log_path->get_value(); if (!log_path.empty()) { std::ofstream file(log_path.c_str(), std::ios_base::app); file << ss.str() << std::endl; file.close(); } } // Change value of rule symbol_remove_ref( my_agent, rhs_value_to_symbol( prod->action_list->referent ) ); prod->action_list->referent = symbol_to_rhs_value( make_float_constant( my_agent, new_combined ) ); prod->rl_update_count += 1; prod->rl_ecr = new_ecr; prod->rl_efr = new_efr; // change documentation if ( my_agent->rl_params->meta->get_value() == soar_module::on ) { if ( prod->documentation ) { free_memory_block_for_string( my_agent, prod->documentation ); } std::stringstream doc_ss; const std::vector<std::pair<std::string, param_accessor<double> *> > &documentation_params = my_agent->rl_params->get_documentation_params(); for (std::vector<std::pair<std::string, param_accessor<double> *> >::const_iterator doc_params_it = documentation_params.begin(); doc_params_it != documentation_params.end(); ++doc_params_it) { doc_ss << doc_params_it->first << "=" << doc_params_it->second->get_param(prod) << ";"; } prod->documentation = make_memory_block_for_string(my_agent, doc_ss.str().c_str()); /* std::string rlupdates( "rlupdates=" ); std::string val; to_string( static_cast< uint64_t >( prod->rl_update_count ), val ); rlupdates.append( val ); prod->documentation = make_memory_block_for_string( my_agent, rlupdates.c_str() ); */ } // Change value of preferences generated by current instantiations of this rule if ( prod->instantiations ) { for ( instantiation *inst = prod->instantiations; inst; inst = inst->next ) { for ( preference *pref = inst->preferences_generated; pref; pref = pref->inst_next ) { symbol_remove_ref( my_agent, pref->referent ); pref->referent = make_float_constant( my_agent, new_combined ); } } } } } } data->gap_age = 0; data->hrl_age = 0; data->reward = 0.0; } }
void ConfigData::get_config_data() { int min, max; const char *thermSec = SescConf->getCharPtr("","thermal"); std::string name_str; //GET BASIC PROPERTIES const char *modelconfigSec = SescConf->getCharPtr(thermSec,"model"); init_temp_ = SescConf->getDouble(modelconfigSec,"initialTemp"); ambient_temp_ = SescConf->getDouble(modelconfigSec,"ambientTemp"); { // Adjust default_time_increment_ so that it is a multiple of the sampling frequency int cyclesPerSample = SescConf->getInt(modelconfigSec,"CyclesPerSample"); MATRIX_DATA frequency = SescConf->getDouble("technology","Frequency"); MATRIX_DATA seconds_per_step = cyclesPerSample/frequency; int nsamples = SescConf->getInt(modelconfigSec,"PowerSamplesPerThermSample"); default_time_increment_ = seconds_per_step*nsamples; } //GET GRAPHICS PROPERTIES const char *graphicsconfigSec = SescConf->getCharPtr(thermSec,"graphics"); enable_graphics_ = SescConf->getBool(graphicsconfigSec,"enableGraphics"); resolution_x_=SescConf->getInt(graphicsconfigSec, "resolution_x"); resolution_y_=SescConf->getInt(graphicsconfigSec, "resolution_y"); enable_perspective_view_=SescConf->getBool(graphicsconfigSec, "perspective_view"); graphics_floorplan_layer_ = SescConf->getInt(graphicsconfigSec, "graphics_floorplan_layer"); min = SescConf->getRecordMin(graphicsconfigSec,"graphics_file_type") ; max = SescConf->getRecordMax(graphicsconfigSec,"graphics_file_type") ; for (int id=min;id<=max;id++) { std::string temp_str(SescConf->getCharPtr(graphicsconfigSec,"graphics_file_type",id)); ThermGraphics_FileType* file_type = new ThermGraphics_FileType(temp_str); graphics_file_types_.push_back(file_type); } //GET COOLING PROPERTIES const char *coolingconfigSec = SescConf->getCharPtr(thermSec,"cooling"); fan_used_ = SescConf->getInt(coolingconfigSec, "Fan_Used"); fan_velocity_ = SescConf->getDouble(coolingconfigSec,"Fan_Velocity"); fan_distance_ = SescConf->getDouble(coolingconfigSec, "Fan_Distance"); air_pressure_ = SescConf->getDouble(coolingconfigSec, "Air_Pressure"); coolant_density_=SescConf->getDouble(coolingconfigSec,"Coolant_density"); coolant_viscosity_=SescConf->getDouble(coolingconfigSec,"Coolant_viscosity"); coolant_thermal_conductivity_=SescConf->getDouble(coolingconfigSec,"Coolant_thermal_conductivity"); coolant_specific_heat_=SescConf->getDouble(coolingconfigSec,"Coolant_specific_heat"); coolant_prandtl_number_=SescConf->getDouble(coolingconfigSec,"Coolant_prandtl_number"); coolant_flow_rate_=SescConf->getDouble(coolingconfigSec,"Coolant_flow_rate"); coolant_angle_=SescConf->getDouble(coolingconfigSec,"Coolant_angle"); coolant_nozzle_diameter_=SescConf->getDouble(coolingconfigSec,"Coolant_nozzle_diameter"); coolant_coverage_percent_=SescConf->getDouble(coolingconfigSec,"Coolant_coverage_percent"); //GET THE CHIP PARAMETERS const char *chipconfigSec = SescConf->getCharPtr(thermSec,"chip"); transistor_count_ =SescConf->getDouble(chipconfigSec,"transistor_count"); pin_count_ =SescConf->getDouble(chipconfigSec,"pin_count"); pins_height_ =SescConf->getDouble(chipconfigSec,"pins_height"); pin_pitch_ =SescConf->getDouble(chipconfigSec,"pin_pitch"); chip_width_ =SescConf->getDouble(chipconfigSec,"chip_width"); chip_height_ =SescConf->getDouble(chipconfigSec,"chip_height"); chip_thickness_ =SescConf->getDouble(chipconfigSec,"chip_thickness"); package_height_ =SescConf->getDouble(chipconfigSec,"package_height"); package_width_ =SescConf->getDouble(chipconfigSec,"package_width"); package_thickness_ =SescConf->getDouble(chipconfigSec,"package_thickness"); technology_=SescConf->getInt(chipconfigSec,"technology"); switch(technology_){ case 250: technology_=TECH_250; break; case 180: technology_=TECH_180; break; case 130: technology_=TECH_130; break; case 90: technology_=TECH_90; break; case 65: technology_=TECH_65; break; default: std::cerr << "sesctherm3Dconfig::get_config_data() => Invalid process technology [" << technology_ << "] defined in config file" << std::endl; exit(1); } //GET THE HEAT SINK/SPREADER PROPERTIES const char *spreadersinkconfigSec = SescConf->getCharPtr(thermSec,"spreader_sink"); heat_sink_height_=SescConf->getDouble(spreadersinkconfigSec,"heat_sink_height"); //height heat_sink_width_=SescConf->getDouble(spreadersinkconfigSec,"heat_sink_width"); //width heat_sink_thickness_=SescConf->getDouble(spreadersinkconfigSec,"heat_sink_thickness"); //thickness heat_spreader_height_=SescConf->getDouble(spreadersinkconfigSec,"heat_spreader_height"); //height heat_spreader_width_=SescConf->getDouble(spreadersinkconfigSec,"heat_spreader_width"); //width heat_spreader_thickness_=SescConf->getDouble(spreadersinkconfigSec,"heat_spreader_thickness"); //thickness heat_sink_fins_thicknsss_=SescConf->getDouble(spreadersinkconfigSec,"heat_sink_fins_thickness"); //thickness heat_spreader_microhardness_ = SescConf->getDouble(spreadersinkconfigSec,"heat_spreader_microhardness")*pow(10.0,6.0); //microhardness heat_spreader_surfaceroughness_ = SescConf->getDouble(spreadersinkconfigSec,"heat_spreader_surfaceroughness")*pow(10.0,-6.0); //surface roughness heat_sink_fin_number_=SescConf->getInt(spreadersinkconfigSec,"heat_sink_fins"); heat_sink_fin_number_+=heat_sink_fin_number_-1; //if we specify 5 fins, we have 9 fins regions //note: specify the value as -1 to have the model determine the interface resistance based upon material properties heat_sink_resistance_ =SescConf->getDouble(spreadersinkconfigSec,"heat_sink_resistance")*pow(10.0,-4.0); //total interface resistance (for .02mm epoxy, 0.2-0.9 (x10^4*m^2*K/W) heat_sink_microhardness_ = SescConf->getDouble(spreadersinkconfigSec,"heat_sink_microhardness")*pow(10.0,6.0); //microhardness heat_sink_surfaceroughness_ = SescConf->getDouble(spreadersinkconfigSec,"heat_sink_surfaceroughness")*pow(10.0,-6.0); //surface roughness heat_sink_contactpressure_ = SescConf->getDouble(spreadersinkconfigSec,"heat_sink_contactpressure")*pow(10.0,6.0); //contact pressure (range of 0.07-0.17MPa --megapascals) //this would be a thermal compound placed between the heat spreader and the heatsink //Note: if the heatsink resistance is defined, these parameters are ignored //thermal conductivity (W/mK) interface_material_conductivity_= SescConf->getDouble(spreadersinkconfigSec,"interface_material_conductivity"); //gas parameter (M0 x 10^6,m) interface_material_gasparameter_= SescConf->getDouble(spreadersinkconfigSec,"interface_material_gasparameter"); //GET THE MATERIAL PROPERTIES min = SescConf->getRecordMin(thermSec,"materials_bulk") ; max = SescConf->getRecordMax(thermSec,"materials_bulk") ; for (int id=min;id<=max;id++) { const char *name = SescConf->getCharPtr(thermSec,"materials_bulk",id); name_str=name; datalibrary_->layer_materials_.create(name_str, SescConf->getDouble(name,"density"), SescConf->getDouble(name,"specHeat"), SescConf->getDouble(name,"conductivity"), SescConf->getDouble(name,"emissivity")); } //GET THE MODEL LAYERS min = SescConf->getRecordMin(thermSec,"layer"); max = SescConf->getRecordMax(thermSec,"layer"); for (int id=min;id<=max;id++) { const char *name = SescConf->getCharPtr(thermSec,"layer",id); const char *layername = SescConf->getCharPtr(name, "name"); const char *type = SescConf->getCharPtr(name, "type"); MATRIX_DATA thickness = SescConf->getDouble(name, "thickness"); MATRIX_DATA width = SescConf->getDouble(name, "width"); MATRIX_DATA height = SescConf->getDouble(name, "height"); MATRIX_DATA granularity = SescConf->getDouble(name, "granularity"); MATRIX_DATA lock_temp = SescConf->getDouble(name, "lock_temp"); int flp_num = SescConf->getInt(name, "floorplan"); ChipLayers* info= new ChipLayers(datalibrary_, max-min); datalibrary_->all_layers_info_.push_back(info); info->layer_number_=id-min; info->name_=layername; info->thickness_=thickness; info->width_=width; info->height_=height; info->granularity_=granularity; info->flp_num_=flp_num; if(lock_temp < 0){ info->temp_locking_enabled_=false; }else { info->temp_locking_enabled_=true; info->lock_temp_=lock_temp; } //need to determine lumped spec_heat/conductivity and density for each layer info->spec_heat_=-1.0; info->vertical_conductivity_up_=-1.0; info->vertical_conductivity_down_=-1.0; info->horizontal_conductivity_=-1.0; info->density_=-1.0; if (!strcmp(type, "mainboard")){ info->type_=MAINBOARD_LAYER; } else if (!strcmp(type, "pins")){ info->type_=PINS_LAYER; } else if (!strcmp(type, "package_pwb")){ info->type_=PWB_LAYER; } else if (!strcmp(type, "package_substrate_c5")){ info->type_=FCPBGA_LAYER; } else if (!strcmp(type, "c4_underfill")){ info->type_=C4_UNDERFILL_LAYER; } else if (!strcmp(type, "interconnect")){ info->type_=INTERCONNECT_LAYER; } else if (!strcmp(type, "die_transistor")){ info->type_=DIE_TRANSISTOR_LAYER; } else if (!strcmp(type, "bulk_silicon")){ info->type_=BULK_SI_LAYER; } else if (!strcmp(type, "oil")){ info->type_=OIL_LAYER; } else if (!strcmp(type, "air")){ info->type_=AIR_LAYER; } else if (!strcmp(type, "ucool")){ I(0); // info->type_=UCOOL_LAYER; } else if (!strcmp(type, "heat_spreader")){ info->type_=HEAT_SPREADER_LAYER; } else if (!strcmp(type, "heat_sink_bottom")){ info->type_=HEAT_SINK_LAYER; } else if (!strcmp(type, "heat_sink_fins")){ info->type_=HEAT_SINK_FINS_LAYER; } else{ std::cerr<< "FATAL: ConfigData::get_config_data() -- undefined layer type [" << type << "] defined in configuration file" << std::endl; exit(1); } } config_data_defined_=true; /**************** //if the heat_sink_resistance is a negative number, this means that we are to determine the value if (LT(heat_sink_resistance_,0)) { MATRIX_DATA heat_sink_conductivity=layer_material_[3]->conductivity_; MATRIX_DATA heat_spreader_conductivity=layer_material_[2]->conductivity_; MATRIX_DATA heat_sink_surface_roughness=heat_sink_surfaceroughness_; MATRIX_DATA heat_spreader_surface_roughness=heat_spreader_surfaceroughness_; MATRIX_DATA overall_conductivity=(2*heat_spreader_conductivity*heat_sink_conductivity)/(heat_spreader_conductivity+heat_sink_conductivity); //ks=2k1k2/(k1+k2) MATRIX_DATA RMS_surface_roughness=sqrt(pow(heat_sink_surface_roughness,2) + pow(heat_spreader_surface_roughness,2)); //sqrt(roughness1^2+roughness2^2) MATRIX_DATA asperity_slope_1=0.125*pow(heat_sink_surface_roughness*pow(10.0,6.0),0.402); //m=0.125(roughnessx16^6)^0.402 MATRIX_DATA asperity_slope_2=0.125*pow(heat_spreader_surface_roughness*pow(10.0,6.0),0.402); //m=0.125(roughnessx16^6)^0.402 MATRIX_DATA eff_mean_abs_asp_slope=sqrt(pow(asperity_slope_1,2)+pow(asperity_slope_2,2)); //m=sqrt(m1^2+m2^2) MATRIX_DATA min_microhardness=MIN(heat_sink_microhardness_,heat_spreader_microhardness_); MATRIX_DATA contact_pressure=heat_sink_contactpressure_; MATRIX_DATA contact_conductivity=1.25*overall_conductivity*(eff_mean_abs_asp_slope/RMS_surface_roughness)*pow(contact_pressure/min_microhardness,0.95); //hc=1.25Ks(m/RMSroughness)(P/Hc)^0.95 MATRIX_DATA eff_gap_thickness=1.53*RMS_surface_roughness*pow(contact_pressure/min_microhardness,-0.097); //Y=1.536*RMS_roughness(pressure/microhardness)^-0.097 MATRIX_DATA gap_conductivity=interface_material_conductivity_/(eff_gap_thickness+0); //Hg=Kg/(Y+M) //FIXME: currently does not support gas parameter (M=0) //this depends upon temperature which involves a rewrite of the model unit calculation methods MATRIX_DATA joint_conductivity=contact_conductivity+gap_conductivity; heat_sink_resistance_=1/joint_conductance; #ifdef _ESESCTHERM_DEBUG cerr << "heat_sink_conductivity:" << heat_sink_conductivity << endl; cerr << "heat_spreader_conductivity:" << heat_spreader_conductivity << endl; cerr << "heat_sink_surface_roughness:" << heat_sink_surface_roughness << endl; cerr << "overall_conductance:" << overall_conductance << endl; cerr << "RMS_surface_roughness:" << RMS_surface_roughness << endl; cerr << "asperity_slope_1:" << asperity_slope_1 << endl; cerr << "asperity_slope_2:" << asperity_slope_2 << endl; cerr << "eff_mean_abs_asp_slope:" << eff_mean_abs_asp_slope << endl; cerr << "min_microhardness:" << min_microhardness << endl; cerr << "contact_pressure:" << contact_pressure << endl; cerr << "contact_conductance:" << contact_conductance << endl; cerr << "eff_gap_thickness:" << eff_gap_thickness << endl; cerr << "gap_conductance:" << gap_conductance << endl; cerr << "joint_conductance:" << joint_conductance << endl; cerr << "heat_sink_resistance:" << heat_sink_resistance_ << endl; } #endif ***************/ }
inline void LogCodec::LogField::read(const char *buf, pion::platform::Event& e) { switch(log_term.term_type) { case pion::platform::Vocabulary::TYPE_NULL: case pion::platform::Vocabulary::TYPE_OBJECT: break; // ignore unsupported field case pion::platform::Vocabulary::TYPE_INT8: case pion::platform::Vocabulary::TYPE_INT16: case pion::platform::Vocabulary::TYPE_INT32: e.setInt(log_term.term_ref, boost::lexical_cast<boost::int32_t>(buf)); break; case pion::platform::Vocabulary::TYPE_INT64: e.setBigInt(log_term.term_ref, boost::lexical_cast<boost::int64_t>(buf)); break; case pion::platform::Vocabulary::TYPE_UINT8: case pion::platform::Vocabulary::TYPE_UINT16: case pion::platform::Vocabulary::TYPE_UINT32: e.setUInt(log_term.term_ref, boost::lexical_cast<boost::uint32_t>(buf)); break; case pion::platform::Vocabulary::TYPE_UINT64: e.setUBigInt(log_term.term_ref, boost::lexical_cast<boost::uint64_t>(buf)); break; case pion::platform::Vocabulary::TYPE_FLOAT: e.setFloat(log_term.term_ref, boost::lexical_cast<float>(buf)); break; case pion::platform::Vocabulary::TYPE_DOUBLE: e.setDouble(log_term.term_ref, boost::lexical_cast<double>(buf)); break; case pion::platform::Vocabulary::TYPE_LONG_DOUBLE: e.setLongDouble(log_term.term_ref, boost::lexical_cast<long double>(buf)); break; case pion::platform::Vocabulary::TYPE_SHORT_STRING: case pion::platform::Vocabulary::TYPE_STRING: case pion::platform::Vocabulary::TYPE_LONG_STRING: if (log_urlencode) { std::string temp_str(algo::url_decode(buf)); e.setString(log_term.term_ref, temp_str); } else { e.setString(log_term.term_ref, buf); } break; case pion::platform::Vocabulary::TYPE_BLOB: case pion::platform::Vocabulary::TYPE_ZBLOB: if (log_urlencode) { std::string temp_str(algo::url_decode(buf)); e.setBlob(log_term.term_ref, temp_str); } else { e.setBlob(log_term.term_ref, buf); } break; case pion::platform::Vocabulary::TYPE_CHAR: if (log_urlencode) { std::string temp_str(algo::url_decode(buf)); if (temp_str.size() > log_term.term_size) temp_str.resize(log_term.term_size); e.setString(log_term.term_ref, temp_str); } else if (strlen(buf) > log_term.term_size) { e.setString(log_term.term_ref, std::string(buf, log_term.term_size)); } else { e.setString(log_term.term_ref, buf); } break; case pion::platform::Vocabulary::TYPE_DATE_TIME: case pion::platform::Vocabulary::TYPE_DATE: case pion::platform::Vocabulary::TYPE_TIME: { PionDateTime dt; if (log_urlencode) { std::string temp_str(algo::url_decode(buf)); log_time_facet.fromString(temp_str, dt); } else { log_time_facet.fromString(buf, dt); } if (log_do_time_offset) { dt += log_time_offset; } e.setDateTime(log_term.term_ref, dt); break; } } }
inline void LogCodec::LogField::write(std::ostream& out, const pion::platform::Event::ParameterValue& value) { std::ostringstream oss; switch(log_term.term_type) { case pion::platform::Vocabulary::TYPE_NULL: case pion::platform::Vocabulary::TYPE_OBJECT: break; // ignore unsupported field case pion::platform::Vocabulary::TYPE_INT8: case pion::platform::Vocabulary::TYPE_INT16: case pion::platform::Vocabulary::TYPE_INT32: oss << boost::get<boost::int32_t>(value); break; case pion::platform::Vocabulary::TYPE_INT64: oss << boost::get<boost::int64_t>(value); break; case pion::platform::Vocabulary::TYPE_UINT8: case pion::platform::Vocabulary::TYPE_UINT16: case pion::platform::Vocabulary::TYPE_UINT32: oss << boost::get<boost::uint32_t>(value); break; case pion::platform::Vocabulary::TYPE_UINT64: oss << boost::get<boost::uint64_t>(value); break; case pion::platform::Vocabulary::TYPE_FLOAT: oss << boost::get<float>(value); break; case pion::platform::Vocabulary::TYPE_DOUBLE: // using boost::lexical_cast<std::string> ensures precision appropriate to type double oss << boost::lexical_cast<std::string>(boost::get<double>(value)); break; case pion::platform::Vocabulary::TYPE_LONG_DOUBLE: // using boost::lexical_cast<std::string> ensures precision appropriate to type long double oss << boost::lexical_cast<std::string>(boost::get<long double>(value)); break; case pion::platform::Vocabulary::TYPE_SHORT_STRING: case pion::platform::Vocabulary::TYPE_STRING: case pion::platform::Vocabulary::TYPE_LONG_STRING: case pion::platform::Vocabulary::TYPE_BLOB: case pion::platform::Vocabulary::TYPE_ZBLOB: { const pion::platform::Event::BlobType& ss = boost::get<const pion::platform::Event::BlobType&>(value); if (ss.size() > 0) { if (log_urlencode) { std::string temp_str(ss.get()); oss << algo::url_encode(temp_str); } else { oss.write(ss.get(), ss.size()); } } break; } case pion::platform::Vocabulary::TYPE_CHAR: { const pion::platform::Event::BlobType& ss = boost::get<const pion::platform::Event::BlobType&>(value); if (ss.size() > 0) { if (log_urlencode) { std::string temp_str(ss.get()); temp_str = algo::url_encode(temp_str); if (temp_str.size() > log_term.term_size) temp_str.resize(log_term.term_size); oss << temp_str; } else { oss.write(ss.get(), ss.size() < log_term.term_size ? ss.size() : log_term.term_size); } } break; } case pion::platform::Vocabulary::TYPE_DATE_TIME: case pion::platform::Vocabulary::TYPE_DATE: case pion::platform::Vocabulary::TYPE_TIME: { PionDateTime dt = boost::get<const PionDateTime&>(value); if (log_do_time_offset) { dt -= log_time_offset; } if (log_urlencode) { std::string temp_str; log_time_facet.toString(temp_str, dt); oss << algo::url_encode(temp_str); } else { log_time_facet.write(oss, dt); } break; } } if (log_delim_start != '\0') out << log_delim_start; if (oss.str().empty()) out << log_empty_val; else { std::string src = oss.str(); std::string dst; for (std::string::iterator i = src.begin(); i != src.end(); i++) { if (*i == log_delim_end) dst.push_back(log_escape_char); dst.push_back(*i); } out << dst; } if (log_delim_end != '\0') out << log_delim_end; }
//针对GBK编码方式处理含有中文的字符串,将每个字符提取出来,作为单独一个元素存放到数组中 //如果字符串中夹杂着数字或者字母,则将数字或者字母合并为一个字符 //比如: “2.5亿网民”会被处理成 ”2.”"亿" "网" "民" vector<string> StringFun::explode(const string &str) { set<string> filted_chars; filted_chars.insert("“"); filted_chars.insert("("); filted_chars.insert(")"); filted_chars.insert("、"); filted_chars.insert(","); filted_chars.insert("。"); filted_chars.insert("【"); filted_chars.insert("】"); filted_chars.insert(":"); filted_chars.insert("”"); filted_chars.insert(" ?"); vector<string> result_array; string merge_value = ""; int pos = 0; while(pos < str.length()) { int value = str[pos]; // 将相连的数字和字母当成一个字处理,包括 "%",和"." if((value >= 48 && value <= 57) || (value >= 65 && value <= 90) || (value >= 97 && value <= 122) || 46 == value || 37 == value ) { merge_value += str[pos]; if(pos == str.length()-1) //已经达到字符串末尾 { result_array.push_back(merge_value); } pos++; } else if(value >=0 && value <= 127) { if(merge_value != "") { result_array.push_back(merge_value); merge_value = ""; } pos++; } else //中文字符串 { if(merge_value != "") { result_array.push_back(merge_value); merge_value = ""; } if(pos <= str.length() - 2) //防止产生越界错误 { string temp_str(str, pos, 2); //得到中文字符 if(filted_chars.count(temp_str) == 0) //非中文标点符号 { result_array.push_back(temp_str); } } pos += 2; } } return result_array; }
/* Main - create the threads and start the processing */ int main(int argc, char *argv[]) { /* Check for argument count */ if (argc != 2) { std::cerr << "Invalid number of arguments." << std::endl; return -1; } /* Read the path to the data */ std::string path(argv[1]); /* Read the list of directories to process */ std::string image_list_filename = path + "image_list.dat"; std::vector<std::string> input_images; FILE *file = fopen(image_list_filename.c_str(), "r"); if (!file) { std::cerr << "Could not open 'image_list.dat' inside '" << path << "'." << std::endl; return -1; } char line[128]; while (fgets(line, sizeof(line), file) != NULL) { line[strlen(line)-1] = 0; std::string temp_str(line); input_images.push_back(temp_str); } fclose(file); /* Create and prepare the file for metrics */ std::string metrics_file = path + "computed_metrics.csv"; std::ofstream data_stream; data_stream.open(metrics_file, std::ios::out); if (!data_stream.is_open()) { std::cerr << "Could not create the metrics file." << std::endl; return -1; } data_stream << "CZI Image,"; data_stream << "Z-index start,"; data_stream << "Z-index end,"; data_stream << "Total Cell Count,"; data_stream << "Neural Cell Count,"; data_stream << "Neural Nuclei Diameter (mean),"; data_stream << "Neural Nuclei Diameter (std. dev.),"; data_stream << "Neural Nuclei Aspect Ratio (mean),"; data_stream << "Neural Nuclei Aspect Ratio (std. dev.),"; data_stream << "Neural Nuclei Error Ratio (mean),"; data_stream << "Neural Nuclei Error Ratio (std. dev.),"; data_stream << "Neural Soma Diameter (mean),"; data_stream << "Neural Soma Diameter (std. dev.),"; data_stream << "Neural Soma Aspect Ratio (mean),"; data_stream << "Neural Soma Aspect Ratio (std. dev.),"; data_stream << "Neural Soma Error Ratio (mean),"; data_stream << "Neural Soma Error Ratio (std. dev.),"; data_stream << "Astrocyte Count,"; data_stream << "Astrocyte Diameter (mean),"; data_stream << "Astrocyte Diameter (std. dev.),"; data_stream << "Astrocyte Aspect Ratio (mean),"; data_stream << "Astrocyte Aspect Ratio (std. dev.),"; data_stream << "Astrocyte Error Ratio (mean),"; data_stream << "Astrocyte Error Ratio (std. dev.),"; // Synapse bins data_stream << "Synapse Contour Count,"; for (unsigned int i = 0; i < NUM_AREA_BINS-1; i++) { data_stream << i*BIN_AREA << " <= Synapse Contour Area < " << (i+1)*BIN_AREA << ","; } data_stream << "Synapse Contour Area >= " << (NUM_AREA_BINS-1)*BIN_AREA << ","; data_stream << std::endl; data_stream.close(); /* Process each image */ for (unsigned int index = 0; index < input_images.size(); index++) { std::cout << "Processing " << input_images[index] << std::endl; if (!processDir(path, input_images[index], metrics_file)) { std::cout << "ERROR !!!" << std::endl; return -1; } } return 0; }