bool roll_validator(LinApprox linmodel, bool[] changed, bool[] reassigned) { bool ret = false; changed.CopyTo(reassigned, 0); if (linmodel.tpars[2] > 0.0) // friction must kill rotation { linmodel.tpars[2] = 0.0; reassigned[1] = false; ret = true; } if (HasControlSurfaces) { if (linmodel.tpars[3] < 1e-6) // authority can't be negative or zero { linmodel.tpars[3] = MOI[ROLL] / 1000.0; reassigned[2] = false; ret = true; } } else { linmodel.tpars[3] = 0.0; } return(ret); }
bool pitch_lift_validator(LinApprox linmodel, bool[] changed, bool[] reassigned) { // plane airframe must provide positive lift derivative double sign = Math.Sign(Math.Abs(AoA(PITCH)) - 90.0 * dgr2rad); if (linmodel.tpars[1] * sign > 0.0) { changed.CopyTo(reassigned, 0); linmodel.tpars[1] = -sign * sum_mass / 10.0; reassigned[0] = false; return(true); } return(false); }
protected override void _drawGUI(int id) { GUILayout.BeginVertical(); AutoGUI.AutoDrawObject(trainer); for (int i = 0; i < trainer.tasks.Count; i++) { GUILayout.Space(8.0f); AutoGUI.AutoDrawObject(trainer.tasks[i]); LinApprox linmodel = trainer.tasks[i].linmodel; GUILayout.Label("linmodel:", GUIStyles.labelStyleLeft); GUILayout.Label(String.Join(",", linmodel.pars.Select(v => v.ToString("G5")).ToArray()), GUIStyles.labelStyleCenter); } GUILayout.EndVertical(); GUI.DragWindow(); }
public void Train() { if (updated) { update_train_buf(); updated = false; if (cur_time > time_reset) { reset_time(); } update_weights(); if (input_view == null) { create_views(); } if (input_view != null) { if (input_view.Count > 0) { reset_view_caches(); update_singularity(input_view); for (int i = 0; i < tasks.Count; i++) { LinApprox linmodel = tasks[i].linmodel; set_parameters(tasks[i]); linmodel.weighted_lsqr(input_view, output_view, weight_view, inputs_changed); bool redo = tasks[i].validator(inputs_changed, reassigned); if (redo) { linmodel.weighted_lsqr(input_view, output_view, weight_view, reassigned); } if (tasks[i].zero_immediate) { linmodel.weighted_lsqr(imm_training_inputs, imm_training_outputs, imm_error_weights, nothing_changed); } linmodel.signalUpdated(); } check_linearity(); clear_old_records(); } } } }
bool pitch_validator(LinApprox linmodel, bool[] changed, bool[] reassigned) { if (HasControlSurfaces) { if (linmodel.tpars[2] < 1e-6) // authority can't be negative or zero { linmodel.tpars[2] = MOI[0] / 1000.0; changed.CopyTo(reassigned, 0); reassigned[1] = false; return(true); } else { } } else { linmodel.tpars[2] = 0.0; } return(false); }
void check_linearity() { if (imm_training_inputs.Size > 0) { double sum_error = 0.0; LinApprox linmodel = linearity_check_task.linmodel; for (int i = 0; i < imm_training_inputs.Size; i++) { Vector input = imm_training_inputs[i]; double true_output = imm_training_outputs[i]; double lin_output = linmodel.eval_training(input); double scaled_err = (lin_output - true_output) / max_output_value; sum_error += Math.Abs(scaled_err); } //for (int i = 0; i < grad_training.Size; i++) //{ // Vector input = grad_training[i].coord; // double true_output = grad_training[i].val; // double lin_output = linmodel.eval_training(input); // double scaled_err = (lin_output - true_output) / max_output_value; // sum_error += Math.Abs(scaled_err); //} //Vector input = imm_training_inputs.getLast(); //double true_output = imm_training_outputs.getLast(); //double lin_output = linmodel.eval_training(input); //sum_error = Math.Abs((lin_output - true_output) / max_output_value); linear_param = (float)(sum_error / (double)(imm_training_inputs.Size));// + grad_training.Size)); linear = linear_param < linear_err_criteria; //linear_param = (float)sum_error; //linear = sum_error < linear_err_criteria; if (linear) { nonlin_time = 0; } else { nonlin_time = Math.Min(1000, nonlin_time + iteration_time); } } }