Ejemplo n.º 1
0
        /// <summary>
        /// Loads all the consequences that are part of a compound treatment.
        /// </summary>
        /// <param name="strAttribute"></param>
        /// <param name="strChange"></param>
        public void LoadAttributeChange(String strAttribute, String strChange)
        {
            AttributeChange attributeChange = new AttributeChange();

            attributeChange.Attribute = strAttribute;
            _attributes.Add(strAttribute);
            attributeChange.Change = strChange;

            if (strChange.Contains("COMPOUND_TREATMENT"))
            {
                _compoundTreatment = strChange;
                _compoundTreatment = _compoundTreatment.Replace("COMPOUND_TREATMENT(", "");
                _compoundTreatment = _compoundTreatment.Replace(")", "");

                CompoundTreatment compoundTreatment = Simulation.CompoundTreatments.Find(delegate(CompoundTreatment ct) { return(ct.CompoundTreatmentName == _compoundTreatment); });
                if (compoundTreatment == null)
                {
                    compoundTreatment = new CompoundTreatment(_compoundTreatment);
                    Simulation.CompoundTreatments.Add(compoundTreatment);
                }
            }
            else
            {
                if (SimulationMessaging.AttributeMaximum.Contains(strAttribute))
                {
                    attributeChange.Maximum = SimulationMessaging.AttributeMaximum[strAttribute].ToString();
                }
                if (SimulationMessaging.AttributeMinimum.Contains(strAttribute))
                {
                    attributeChange.Minimum = SimulationMessaging.AttributeMinimum[strAttribute].ToString();
                }
            }
            AddAttributeChange(attributeChange);
        }
Ejemplo n.º 2
0
Archivo: Costs.cs Proyecto: jakedw7/iAM
 public double GetCost(Hashtable hashAttributeValue)
 {
     if (this._isCompoundTreatment)
     {
         CompoundTreatment compoundTreatment = Simulation.CompoundTreatments.Find(delegate(CompoundTreatment ct) { return(ct.CompoundTreatmentName == _compoundTreatment); });
         return(compoundTreatment.GetCost(hashAttributeValue));
     }
     else
     {
         int      i     = 0;
         object[] input = new object[_attributesEquation.Count];
         foreach (String str in _attributesEquation)
         {
             if (hashAttributeValue[str] != null)
             {
                 input[i] = hashAttributeValue[str];
             }
             else
             {
                 input[i] = 0;
             }
             i++;
         }
         try
         {
             object result = _calculate.RunMethod(input);
             return((double)result);
         }
         catch (Exception exc)
         {
             SimulationMessaging.AddMessage(new SimulationMessage("Error in RunMethod. " + exc.Message));
             return(0);
         }
     }
 }