public void Initialize(Int32 actionNumber, WeibullMarkovModel model) { for (Int32 i = 0; i < 4; i++) { _cbApplic[i].Checked = false; _tbCost[i].Value = 999999.00; for (Int32 j = 0; j < 4; j++) { _tbProb[i, j].Value = (j == 0 ? 100.0 : 0.0); } } for (Int32 i = 0; i < model.States.Count; i++) { foreach (WeibullMarkovAction action in model.States[i].Actions) { if (action.Number == actionNumber && action.IsApplicable) { _cbApplic[i].Checked = true; _tbCost[i].Value = action.Cost; for (Int32 j = 0; j < 4; j++) { _tbProb[i, j].Value = 100.0 * action.TranProb[j]; } } } } CheckRow1(); CheckRow2(); CheckRow3(); CheckRow4(); ValidateInput(); }
public void A2_SolveModelSimple() { String errorMessage = null; Boolean ok = true; String modelXmlFileName = @"C:\SVN_Sandbox\Weibull-Markov\TWeibullMarkov\App_Data\Examples\Paper Example 3.xml"; String modelXsdFileName = @"C:\SVN_Sandbox\Weibull-Markov\TWeibullMarkov\App_Data\WeibullMarkovModel.xsd"; try { WeibullMarkovModel model = WeibullMarkovModel.LoadFromXml(modelXmlFileName, modelXsdFileName, out errorMessage); Assert.IsNotNull(model, errorMessage); ok = (model != null); if (ok) { Int32 numIter = 0; Boolean failCostOverridden = false; Double failureCost = -1.0; ok = model.Solve(30, out numIter, out failCostOverridden, out failureCost, out errorMessage); if (ok) { ok = model.SaveToXml("SolvedModel.xml", out errorMessage); } } } catch (Exception ex) { errorMessage = ex.Message; ok = false; } Assert.IsTrue(ok, errorMessage); }
public void Initialize(WeibullMarkovModel model) { try { } catch (Exception) { } }
public Boolean Initialize(String modelFilePath, out String errorMessage) { Boolean ok = true; errorMessage = null; WeibullMarkovModel model = null; try { String localSchemaPath = MapPath(UCPolicy.SCHEMA_FILE_PATH); if (System.IO.File.Exists(localSchemaPath)) { ok = TWeibullMarkovLibrary.Utilities.ValidateXMLvsXSD(modelFilePath, localSchemaPath, null, out errorMessage); } if (ok) { // It is already validated, that's whay the second argument is null model = WeibullMarkovModel.LoadFromXml(modelFilePath, null, out errorMessage); ok = (model != null); } if (ok) { UCWeibullPane1.Initialize(1, model); UCWeibullPane2.Initialize(2, model); UCWeibullPane3.Initialize(3, model); UCWeibullPane4.Initialize(4, model); UCActionPane1.Initialize(1, model); UCActionPane2.Initialize(2, model); UCFailureCost1.Initialize(model); UCDiscounting1.Initialize(model); UCPolicy1.Initialize(model); } } catch (Exception ex) { errorMessage = ex.Message; ok = false; } if (!ok) { UCPolicy1.DisplayError(errorMessage); } return(ok); }
public void Initialize(WeibullMarkovModel model) { if (model.FailCostEstimate) { RadioButton1.Checked = true; RadioButton2.Checked = false; RadNumericTextBox1.Value = 0.0; CheckBox1.Checked = false; } else { RadioButton1.Checked = false; RadioButton2.Checked = true; RadNumericTextBox1.Value = model.FailureCost; CheckBox1.Checked = model.FailCostOverride; } SetControlsAvailability(); }
public void Initialize(Int32 stateNumber, WeibullMarkovModel model) { foreach (WeibullMarkovConditionState state in model.States) { if (state.Number == stateNumber) { RadNumericTextBox1.Value = state.t50.Value; if (state.x != null && state.t9X.HasValue) { RadNumericTextBox2.Value = state.t9X.Value; RadNumericTextBox2.Visible = true; LabelAndSetPeriod.Visible = true; } else { LabelAndSetPeriod.Visible = false; RadNumericTextBox2.Visible = false; } if (state.x != null) { RadComboBoxItem item = RadComboBox1.FindItemByValue(state.x); RadComboBox1.SelectedIndex = (item == null ? 0 : item.Index); } else { RadComboBox1.SelectedIndex = 0; } break; } } if (stateNumber == 4) { LastState = "true"; } IsModelEstimated = false; RadButtonEstimate_Click(RadButtonEstimate, null); }
public void A1_CreateAndSaveModel() { String errorMessage = null; try { WeibullMarkovModel model = new WeibullMarkovModel(5, 3, true, null, false, 0.07); String[] keys = model.AllocateKeys(4, out errorMessage); Assert.IsNotNull(keys, errorMessage); Assert.IsTrue(keys.Length == 4, "keys.Length <> 4"); keys[0] = "раз"; keys[1] = "два"; keys[2] = "три"; keys[3] = "четыре"; WeibullMarkovConditionState state1 = model.AddConditionState(27.10497512, 3.012514254, 0, 0, 0, 0, out errorMessage); Assert.IsNotNull(state1, errorMessage); WeibullMarkovConditionState state2 = model.AddConditionState(31.32526401, 3.266009211, 0, 0, 0, 0, out errorMessage); Assert.IsNotNull(state2, errorMessage); WeibullMarkovConditionState state3 = model.AddConditionState(19.18160534, 5.764593918, 0, 0, 0, 0, out errorMessage); Assert.IsNotNull(state3, errorMessage); WeibullMarkovConditionState state4 = model.AddConditionState(10.81636701, 4.670420484, 0, 0, 0, 0, out errorMessage); Assert.IsNotNull(state4, errorMessage); Assert.IsTrue(model.States.Count == 4, "Wrong number of condition states"); WeibullMarkovAction action21 = state2.AddAction(1, 4, true, 1.92); action21.TranProb[0] = 0.99; action21.TranProb[1] = 0.01; WeibullMarkovAction action31 = state3.AddAction(1, 4, true, 23.04); action31.TranProb[0] = 0.9; action31.TranProb[1] = 0.05; action31.TranProb[2] = 0.03; action31.TranProb[3] = 0.02; WeibullMarkovAction action32 = state3.AddAction(2, 4, true, 190.04); action32.TranProb[0] = 1.00; WeibullMarkovAction action41 = state4.AddAction(1, 4, true, 232.28); action41.TranProb[0] = 0.7; action41.TranProb[1] = 0.2; action41.TranProb[2] = 0.05; action41.TranProb[3] = 0.05; WeibullMarkovAction action42 = state4.AddAction(2, 4, true, 600.0); action42.TranProb[0] = 1.00; Double F = model.States[0].ComputeTFF(); Assert.IsTrue(F == 0.99, "F<>0.99"); Boolean ok = model.SaveToXml(modelXmlFileName, out errorMessage); Assert.IsTrue(ok, errorMessage); if (ok && !String.IsNullOrEmpty(modelXsdFileName)) { ok = TWeibullMarkovLibrary.Utilities.ValidateXMLvsXSD(modelXmlFileName, modelXsdFileName, null, out errorMessage); Assert.IsTrue(ok, errorMessage); } } catch (Exception ex) { Assert.IsTrue(false, ex.Message); } }
public void Initialize(WeibullMarkovModel model) { RadNumericTextBox1.Value = Math.Min(RadNumericTextBox1.MaxValue, Math.Max(model.DiscRate, RadNumericTextBox1.MinValue)); ComputeDiscountingFactor(); }
public void EstimateModel(UCWeibullPane tp1, UCWeibullPane tp2, UCWeibullPane tp3, UCWeibullPane tp4, UCActionPane a1, UCActionPane a2, UCFailureCost failCost, UCDiscounting disc) { Boolean ok = true; try { String errorMessage = null; Double discRate = disc.AnnualRate; Boolean fcEstimate = failCost.Estimate; Boolean fcOverride = failCost.Override; Double? fcCost = failCost.FailureCost; UCWeibullPane[] tp = new UCWeibullPane[] { tp1, tp2, tp3, tp4 }; TWeibullMarkovLibrary.WeibullMarkovModel model = new WeibullMarkovModel(4, 3, fcEstimate, fcCost, fcOverride, discRate); // We are assuming throughout that the do nothing cost is zero TWeibullMarkovLibrary.WeibullMarkovConditionState[] state = new WeibullMarkovConditionState[4]; for (int i = 0; ok && i < 4; i++) { state[i] = model.AddConditionState(tp[i].Eta, tp[i].Beta, 0.0, tp[i].T, tp[i].f, tp[i].ff, out errorMessage); if (state[i] == null) { throw new Exception(errorMessage); } state[i].t50 = tp[i].t50; state[i].t9X = tp[i].t9x; state[i].x = tp[i].x; if (a1.IsApplicableToState(i)) { TWeibullMarkovLibrary.WeibullMarkovAction action = state[i].AddAction(1, 4, true, a1.GetCost(i)); for (Int32 j = 0; j < 4; j++) { action.TranProb[j] = a1.GetTranProb(i, j); } } if (a2.IsApplicableToState(i)) { TWeibullMarkovLibrary.WeibullMarkovAction action = state[i].AddAction(2, 4, true, a2.GetCost(i)); for (Int32 j = 0; j < 4; j++) { action.TranProb[j] = a2.GetTranProb(i, j); } } } if (ok) { String fileName = MapPath("~/App_Data/WeibullMarkovModel.xml"); ok = model.SaveToXml(fileName, out errorMessage); if (!ok) { throw new Exception(errorMessage); } String localSchemaPath = MapPath(SCHEMA_FILE_PATH); if (System.IO.File.Exists(localSchemaPath)) { ok = TWeibullMarkovLibrary.Utilities.ValidateXMLvsXSD(fileName, localSchemaPath, null, out errorMessage); if (!ok) { throw new Exception(errorMessage); } } } } catch (Exception ex) { labelError.Text = ex.Message; labelInfo.Text = String.Empty; labelError.Visible = true; labelInfo.Visible = false; } }