Exemple #1
0
        public void Solve(Hashtable hashAttributeValue)
        {
            double dValue;
            double dMinimum;
            double dMaximum;

            _answer = new double[100];
            if (IsModule)
            {
                if (IsCRS)
                {
                    String strType     = hashAttributeValue[_attributesEquation[0].ToString()].ToString();
                    double dCRS        = Convert.ToDouble(hashAttributeValue[_attributesEquation[1].ToString()]);
                    double dThick      = Convert.ToDouble(hashAttributeValue[_attributesEquation[2].ToString()]);
                    double dESAL       = Convert.ToDouble(hashAttributeValue[_attributesEquation[3].ToString()]);
                    double dESALGrowth = Convert.ToDouble(hashAttributeValue[_attributesEquation[4].ToString()]);

                    double dRSL;
                    double dBenefit;
                    _answer[0] = dCRS;
                    for (int n = 1; n < 100; n++)
                    {
                        double dAge = (double)n;
                        dValue = SimulationMessaging.crs.CalculateCRSBenefit(false, strType, dCRS, dThick, dESAL, dESALGrowth, 1, dAge, SimulationMessaging.Method.BenefitLimit, out dBenefit, out dRSL);
                        try
                        {
                            if (SimulationMessaging.GetAttributeMaximum(this.Attribute, out dMaximum))
                            {
                                if (dValue > dMaximum)
                                {
                                    dValue = dMaximum;
                                }
                            }

                            if (SimulationMessaging.GetAttributeMinimum(this.Attribute, out dMinimum))
                            {
                                if (dValue < dMinimum)
                                {
                                    dValue = dMinimum;
                                }
                            }
                        }
                        catch
                        {
                            String strValue = SimulationMessaging.GetAttributeDefault(this.Attribute);
                            dValue = double.Parse(strValue);
                        }
                        _answer[n] = dValue;
                    }
                    return;
                }
                else if (IsOCI)
                {
                }
            }

            object[] input = new object[_attributesEquation.Count];

            int i    = 0;
            int nAge = -1;

            foreach (String str in _attributesEquation)
            {
                if (str == "AGE")
                {
                    nAge = i;
                }
                input[i] = hashAttributeValue[str];;
                i++;
            }

            for (int n = 0; n < 100; n++)
            {
                double dAge = (double)n;
                if (nAge >= 0)
                {
                    input[nAge] = dAge;
                }
                try
                {
                    object result = _calculate.RunMethod(input);
                    try
                    {
                        dValue = (double)result;
                        if (SimulationMessaging.GetAttributeMaximum(this.Attribute, out dMaximum))
                        {
                            if (dValue > dMaximum)
                            {
                                dValue = dMaximum;
                            }
                        }

                        if (SimulationMessaging.GetAttributeMinimum(this.Attribute, out dMinimum))
                        {
                            if (dValue < dMinimum)
                            {
                                dValue = dMinimum;
                            }
                        }
                    }
                    catch
                    {
                        String strValue = SimulationMessaging.GetAttributeDefault(this.Attribute);
                        dValue = double.Parse(strValue);
                    }
                    _answer[n] = dValue;
                }
                catch (Exception exc)
                {
                    SimulationMessaging.AddMessage(new SimulationMessage("Error in RunMethod.   " + _calculate.OriginalInput + " " + exc.Message));
                }
            }
            return;
        }