void motionModel_exportEach(string path_save, m_Motion motion) { List <m_Motion> motion_list = new List <m_Motion>(); motion_list.Add(motion); TheMapData.saveXML_Motion(path_save, motion_list); }
//Output is f2 and so on void selectCandidate_withText( string path_saveFolder, int methodSelection, int loopTime) { temp_summary.Clear(); DateTime time_start = DateTime.Now; String name = TheTool.getFileName_byPath(path_saveFolder); TheTool.Folder_CreateIfMissing(path_saveFolder); path_saveFolder = path_saveFolder + @"\"; //----------------- string path_prefix = path_saveFolder + name + " Quality fi"; List <Feature> list_S0 = model_generator.process02_selectCandidate(path_prefix, methodSelection, loopTime); temp_posture_current = TheMapData.convertfeaturelist_to_ListIf(list_S0);//add model temp_score_regession = model_generator.score_regression_summary; //----------------- int i = 1; foreach (Feature f in list_S0) { temp_summary.Add(getSummarizedFeature(i, f)); i++; } //============================================ int timespan = (int)DateTime.Now.Subtract(time_start).TotalMilliseconds; //---------------- summary_total.Add("----- " + name + " (" + timespan + " ms) -----"); summary_total.AddRange(temp_summary); }
void loadData(m_If i) { i.type = TheMapData.if_type_FlexionAngle; i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text); i.value_d = TheTool.adjustRange(TheTool.getDouble(txtValue.Text), 0, 360); }
public void editIf(m_If i_origin) { try { addNew = false; this.Title = "Edit Change-from-Initial Condition"; butAdd.Content = "Edit"; // comboJ1.Text = TheMapData.getJointDef(i_origin.v); this.i_origin = i_origin; int value = (int)(i_origin.value_d * 100); comboDirect.Text = TheMapData.moveMoveDirection_getDef_byAxisDirection(i_origin.axis, 1); if (value >= 0) { comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, false); txtValue.Text = value.ToString(); } else { comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, true); txtValue.Text = (-value).ToString(); } } catch (Exception ex) { TheSys.showError(ex); } }
public static void motionModel_add1Posture(m_Motion target, List <m_If> rule) { if (target.inputs.Count > 0) { target.inputs.Add(TheMapData.get_m_If_TimeWithin(1)); //Add Time Within } target.inputs.AddRange(rule); }
public void editIf(m_If i_origin) { addNew = false; this.Title = "Edit Flexion Angle Condition"; butAdd.Content = "Edit"; this.i_origin = i_origin; // comboJ1.Text = TheMapData.getJointDef(i_origin.v); comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, i_origin.axis, i_origin.value_d); txtValue.Text = i_origin.value_d.ToString(); }
void loadData(m_If i) { int move_direction = comboDirect.SelectedIndex; int reverse = TheMapData.moveMoveDirection_list[move_direction].direction; double v_modified = TheTool.getDouble(txtValue.Text) / 100; v_modified *= reverse; i.type = TheMapData.if_type_Change; i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.axis = TheMapData.moveMoveDirection_list[move_direction].axis; i.value_d = v_modified; i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text, i.axis, i.value_d); }
void loadData(m_If i) { i.type = TheMapData.if_type_SphereAngle; i.value = TheMapData.then_SphereAngle_Polar; if (comboAngle.SelectedIndex == 1) { i.value = TheMapData.then_SphereAngle_Azimuth; } i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.v2 = TheMapData.getJointName_byDef(comboJ2.Text); i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text); i.value_d = TheTool.adjustRange(TheTool.getDouble(txtValue.Text), 0, 360); }
void loadData(m_If i) { i.type = TheMapData.if_type_2Joint; i.v = TheMapData.getJointName_byDef(comboJ1.Text); i.v2 = TheMapData.getJointName_byDef(comboJ2.Text); i.axis = TheMapData.relation_getAxis_byDef(comboRelative.Text); i.opt = TheMapData.convertOpt_getMath_byDef(comboOpt.Text, i.axis, i.value_d); double v = TheTool.getDouble(txtValue.Text); v *= TheMapData.relation_getDirection_byDef(i.axis, comboRelative.Text); v /= 100; i.value_d = v; }
public void editIf(m_If i_origin) { addNew = false; this.Title = "Edit Relative Joints Condition"; butAdd.Content = "Edit"; this.i_origin = i_origin; // comboJ1.Text = TheMapData.getJointDef(i_origin.v); comboJ2.Text = TheMapData.getJointDef(i_origin.v2); comboRelative.Text = TheMapData.relation_getDef_byAxisValue(i_origin.axis, i_origin.value_d); comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, i_origin.axis, i_origin.value_d); txtValue.Text = (Math.Abs(i_origin.value_d) * 100).ToString(); }
public void editIf(m_If i_origin) { addNew = false; this.Title = "Edit Spherical Angle Condition"; butAdd.Content = "Edit"; this.i_origin = i_origin; // if (i_origin.value == TheMapData.then_SphereAngle_Azimuth) { comboAngle.SelectedIndex = 1; } else { comboAngle.SelectedIndex = 0; } comboJ1.Text = TheMapData.getJointDef(i_origin.v); comboJ2.Text = TheMapData.getJointDef(i_origin.v2); comboOpt.Text = TheMapData.convertOpt_getDef_byMath(i_origin.opt, i_origin.axis, i_origin.value_d); txtValue.Text = i_origin.value_d.ToString(); }
private void but_dbBrowse_Click(object sender, RoutedEventArgs e) { Nullable <bool> openDialog = TheTool.openFileDialog_01(false, ".xml", default_path); if (openDialog == true) { try { file_path_motionDB = TheTool.dialog.FileName; list_motions = TheMapData.loadXML_motion(file_path_motionDB); txtDB.Content = "Motion: " + list_motions.Count(); if (list_motions.Count() > 0) { butAnalyze.IsEnabled = true; } else { butAnalyze.IsEnabled = false; } } catch (Exception ex) { TheSys.showError(ex); } } }
//as a result new_f.v is optimized //current_rules remain the same as Feature is removed after testing //MAIN Output : new_f with optimized v void process02sub_optimizeFeature(List <m_If> current_rules, ref Feature new_f , ref double best_scoreTRUE, ref double best_scoreFALSE, ref double best_scoreTotal) { double best_threshold = new_f.v; current_rules.Add(TheMapData.convertFeature_to_If(new_f)); process02sub_computeScore(current_rules, ref best_scoreTRUE, ref best_scoreFALSE, ref best_scoreTotal); current_rules.RemoveAt(current_rules.Count - 1); int feature_num = current_rules.Count + 1; score_regression_summary.Add(feature_num + "," + new_f.name + "," + new_f.v + "," + best_scoreTotal + "," + best_scoreTRUE + "," + best_scoreFALSE); //----------- if (selection_optimizeThreshold) { if (feature_num > 1 && selection_avoidGabage && best_scoreTotal < previous_scoreTotal) { //first threshold show that this feature could drop the performance //do not enhance this feature, just eliminate let's further process eliminate it } else { while (best_scoreTotal < 100) { Feature f_a = new Feature(); f_a.name = new_f.name; f_a.opt = new_f.opt; f_a.v = Math.Round(new_f.v + new_f.momentum, 2); double f_a_scoreTRUE = 0; double f_a_scoreFALSE = 0; double f_a_scoreTotal = 0; current_rules.Add(TheMapData.convertFeature_to_If(f_a)); process02sub_computeScore(current_rules, ref f_a_scoreTRUE, ref f_a_scoreFALSE, ref f_a_scoreTotal); current_rules.RemoveAt(current_rules.Count - 1); this.score_regression_summary.Add(",," + f_a.v + "," + f_a_scoreTotal + "," + f_a_scoreTRUE + "," + f_a_scoreFALSE); // Feature f_b = new Feature(); f_b.name = new_f.name; f_b.opt = new_f.opt; f_b.v = Math.Round(new_f.v - new_f.momentum, 2); double f_b_scoreTRUE = 0; double f_b_scoreFALSE = 0; double f_b_scoreTotal = 0; current_rules.Add(TheMapData.convertFeature_to_If(f_b)); process02sub_computeScore(current_rules, ref f_b_scoreTRUE, ref f_b_scoreFALSE, ref f_b_scoreTotal); current_rules.RemoveAt(current_rules.Count - 1); this.score_regression_summary.Add(",," + f_b.v + "," + f_b_scoreTotal + "," + f_b_scoreTRUE + "," + f_b_scoreFALSE); // if (f_a_scoreTotal <= best_scoreTotal && f_b_scoreTotal <= best_scoreTotal) { break; } else { //At least one of them better than current threshold if (f_a_scoreTotal > f_b_scoreTotal) { best_scoreTotal = f_a_scoreTotal; best_scoreTRUE = f_a_scoreTRUE; best_scoreFALSE = f_a_scoreFALSE; new_f.v = f_a.v; } else { best_scoreTotal = f_b_scoreTotal; best_scoreTRUE = f_b_scoreTRUE; best_scoreFALSE = f_b_scoreFALSE; new_f.v = f_b.v; } new_f.momentum /= 2; if (new_f.momentum <= .01) { new_f.momentum = .01; } new_f.momentum = Math.Round(new_f.momentum, 2); } } } } }
//path_prefix = "" if no export needed //looptime is negative in case auto public List <Feature> process02_selectCandidate(string path_prefix, int methodSelection, int loopTime) { // F: threshold not needed, so just string // S: threshold is needed, so use Feature this.score_regression_summary = new List <String>();//keep summary String selected; List <string> local_list_F = new List <string>(); List <Feature> local_list_S0 = new List <Feature>(); List <string> local_list_S = new List <string>(); List <m_If> local_rules_forTest = new List <m_If>(); double best_scoreTRUE = 0; double best_scoreFALSE = 0; double best_scoreTotal = 0; //-- add first feature---------- Feature local_first_S = new Feature(); if (methodSelection == TheEntropy.methodSelection_DCFS) { local_list_F.AddRange(DCFS_first_list_F); local_first_S = this.DCFS_first_S.Copy(); } else { local_list_F.AddRange(EnAlgo_first_list_F); local_first_S = this.EnAlgo_first_S.Copy(); } selected = local_first_S.name; process02sub_optimizeFeature(local_rules_forTest, ref local_first_S, ref best_scoreTRUE, ref best_scoreFALSE, ref best_scoreTotal); process02sub_checkGoOn(best_scoreTRUE, best_scoreFALSE, best_scoreTotal); //get initial score local_list_S0.Add(local_first_S); //to add threshold local_list_S.Add(selected); local_rules_forTest.Add(TheMapData.convertFeature_to_If(local_first_S)); //------------------- if (selection_autoNumber) { loopTime = local_list_F.Count(); } for (int i = 2; i < loopTime + 2; i++) { if (local_list_F.Count == 0) { break; } //out of data if (methodSelection == TheEntropy.methodSelection_DCFS) { selected = DCFS_listDelta_getMaxValue(); if (path_prefix != "") { TheTool.exportCSV_orTXT(path_prefix + i + ".csv", DCFS_listDelta_getListString(true), false); } } else { selected = TheEntropy.select1Candidate_entropy(methodSelection, dt_ready, local_list_F, local_list_S, list_entropy, list_MI); if (path_prefix != "") { TheTool.exportCSV_orTXT(path_prefix + i + ".csv", TheTool.str_double_getListString(TheEntropy.temp_listEntropy), false); } } Feature selected0 = TheData.getFeature(selected, dt_threshold_pose1, dt_threshold_pose2); process02sub_optimizeFeature(local_rules_forTest, ref selected0, ref best_scoreTRUE, ref best_scoreFALSE, ref best_scoreTotal); Boolean goOn = process02sub_checkGoOn(best_scoreTRUE, best_scoreFALSE, best_scoreTotal); if (methodSelection == TheEntropy.methodSelection_DCFS) { DCFS_listDelta_update(selected); } if (selection_autoNumber == false || goOn) { local_list_F.Remove(selected); local_list_S0.Add(selected0); local_list_S.Add(selected); local_rules_forTest.Add(TheMapData.convertFeature_to_If(selected0)); } else { break; } } return(local_list_S0); }
public static List <string> log_BasicPostureAnalysis = new List <string>();//for show summary //canonical = useBasePose , if not use previous public static void BasicPostureAnalysis(List <UKI_Data_BasicPose> data_bp_selected, Boolean useBasePose) { try { log_BasicPostureAnalysis = new List <string>(); //--- Collect Header "Key Postures: 0,42,82,115,173,439" --------------- string s = "Key Postures: "; int a = 0; foreach (UKI_Data_BasicPose bp in data_bp_selected) { if (a > 0) { s += ","; } s += bp.id; a++; } log_BasicPostureAnalysis.Add(s); if (useBasePose) { log_BasicPostureAnalysis.Add("Canonical: Ready Stance"); } else { log_BasicPostureAnalysis.Add("Canonical: (Previous Posture)"); } log_BasicPostureAnalysis.Add(""); //--- Colelct Data ------------------------------------------------------- if (data_bp_selected.Count > 1) { UKI_Data_BasicPose[] arr_bp = data_bp_selected.ToArray(); UKI_Data_BasicPose canonical = arr_bp[0]; for (int p_num = 1; p_num < arr_bp.Count(); p_num++) { if (!useBasePose) { canonical = arr_bp[p_num - 1]; } //previos as canonical log_BasicPostureAnalysis.Add("Pose " + p_num); List <String> summary_human = new List <String>(); //summary in human language List <String> summary_code = new List <String>(); //summary in code for (int k = 0; k < arr_bp[p_num].basic_pose.Count(); k++) { int v_canonical = canonical.basic_pose[k]; int v_current = arr_bp[p_num].basic_pose[k]; if (v_current != v_canonical) { string v_name = TheUKI.data_bp_name[k]; summary_human.Add(TheTool.string_Tab(1) + TheMapData.convert_getBasePoseDef(v_name, v_current)); summary_code.Add(TheTool.string_Tab(2) + v_name + ": " + v_canonical + " -> " + v_current); } } if (summary_human.Count == 0) { summary_human.Add(TheTool.string_Tab(1) + "Ready Stance"); } foreach (string txt in summary_human) { log_BasicPostureAnalysis.Add(txt); } foreach (string txt in summary_code) { log_BasicPostureAnalysis.Add(txt); } } } } catch (Exception ex) { TheSys.showError("BasicPostureAnalysis: " + ex.ToString()); } }