Exemple #1
0
        internal void SetTree(ObjectFormulaTree tree,
                              bool next,
                              AssociatedAddition addition,
                              IList <IMeasurement> list)
        {
            string dn = "D" + symbol;

            this.tree = tree;
            IDistribution d = DeltaFunction.GetDistribution(tree);

            if (next)
            {
                if (d != null)
                {
                    temp = new FormulaMeasurementDerivationDistribution(tree, null, symbol, addition);
                }
                else
                {
                    temp = new FormulaMeasurementDerivation(tree, null, symbol, addition);
                }
                derivation = temp;
                list.Add(derivation);
                return;
            }
            if (d != null)
            {
                derivation = new FormulaMeasurementDistribution(tree, symbol, addition);
            }
            else
            {
                derivation = new FormulaMeasurement(tree, symbol, addition);
            }
            list.Add(derivation);
            return;
        }
Exemple #2
0
 /// <summary>
 /// Updates itself
 /// </summary>
 public virtual void Update()
 {
     try
     {
         object o = tree.Result;
         checkValue(o);
         ret = o;
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
         object o  = associated.Additional;
         object ot = null;
         if (o == null)
         {
             ot = name;
         }
         else if (o is object[])
         {
             List <object> l = new List <object>();
             l.AddRange(o as object[]);
             l.Add(name);
             ot = l.ToArray();
         }
         else
         {
             ot = new object[] { o, name };
         }
         AssociatedAddition aa =
             new AssociatedAddition(associated.AssociatedObject, ot);
         AssociatedException.Throw(aa, ex);
     }
 }
        /// <summary>
        /// Iterates calculation of derivation
        /// </summary>
        /// <param name="next">The "next" msign</param>
        /// <param name="addition">Associated addition</param>
        /// <returns>Next derivation iteration</returns>
        public FormulaMeasurementDerivation Iterate(bool next, AssociatedAddition addition)
        {
            string             dn = "D" + name;
            ObjectFormulaTree  t  = tree.Derivation("d/dt");
            IDistribution      d  = DeltaFunction.GetDistribution(t);
            AssociatedAddition aa = FormulaMeasurementDerivation.Create(associated);

            if (next)
            {
                FormulaMeasurementDerivation der = null;
                if (d != null)
                {
                    der = new FormulaMeasurementDerivationDistribution(t, dn, aa);
                }
                else
                {
                    der = new FormulaMeasurementDerivation(t, dn, aa);
                }
                derivation = der;
                return(der);
            }
            if (d != null)
            {
                derivation = new FormulaMeasurementDistribution(t, dn, aa);
            }
            else
            {
                derivation = new FormulaMeasurement(t, dn, aa);
            }
            return(null);
        }
Exemple #4
0
 private void CreateProxyInternal()
 {
     try
     {
         List <IMeasurement> outNew = new List <IMeasurement>();
         update = UpdateFormulas;
         proxy  = null;
         proxy  = this.CreateProxy();
         //int k = 0;
         dictF = new Dictionary <char, FormulaMeasurement>();
         AssociatedAddition aa = new AssociatedAddition(this, null);
         foreach (char c in variables.Keys)
         {
             object[]           o    = variables[c] as object[];
             ObjectFormulaTree  tree = o[1] as ObjectFormulaTree;
             FormulaMeasurement fm   = FormulaMeasurement.Create(tree, 0, c + "", aa);
             dictF[c] = fm;
             outNew.Add(fm);
         }
         List <IMeasurement> lm = new List <IMeasurement>();
         foreach (IMeasurement mm in dictF.Values)
         {
             lm.Add(mm);
         }
         FormulaMeasurement.Set(lm, proxy);
         update = UpdateProxy;
         output = outNew;
     }
     catch (Exception ex)
     {
         ex.ShowError(10);
     }
 }
Exemple #5
0
 public FormulaMeasurement(ObjectFormulaTree tree, string name,
                           AssociatedAddition associated)
 {
     this.tree       = tree;
     this.name       = name;
     this.associated = associated;
     par             = GetDefaultValue;
 }
Exemple #6
0
 /// <summary>
 /// Throws exception
 /// </summary>
 /// <param name="addition">Associated addition</param>
 /// <param name="exception">Internal exception</param>
 public static void Throw(AssociatedAddition addition,
                          Exception exception)
 {
     if ((exception is DiagramException) | (exception is AssociatedException))
     {
         throw exception;
     }
     throw new AssociatedException(addition, exception);
 }
Exemple #7
0
        /// <summary>
        /// Creates measure
        /// </summary>
        /// <param name="tree">Tree</param>
        /// <param name="n">Number of tree</param>
        /// <param name="name">Name</param>
        /// <param name="associated">Associated addition</param>
        /// <returns>Measurement</returns>
        public static FormulaMeasurement Create(ObjectFormulaTree tree, int n,
                                                string name, AssociatedAddition associated)
        {
            object ret = null;

            try
            {
                ret = tree.Result;
            }
            catch (Exception ex)
            {
                ex.ShowError(-1);
            }
            FormulaMeasurement fm;

            if (n == 0)
            {
                IDistribution d = DeltaFunction.GetDistribution(tree);
                if (d != null)
                {
                    return(new FormulaMeasurementDistribution(tree, name, associated));
                }
                fm     = new FormulaMeasurement(tree, name, associated);
                fm.ret = ret;
                return(fm);
            }
            string            dn = "D" + name;
            ObjectFormulaTree t  = tree.Derivation("d/dt");

            if (t == null)
            {
                throw new Exception("VariableMeasure.Derivation");
            }
            AssociatedAddition aa  = FormulaMeasurementDerivation.Create(associated);
            FormulaMeasurement der = Create(t, n - 1, dn, aa);

            fm = new FormulaMeasurementDerivation(tree, der, name, aa);
            try
            {
                fm.ret = t.Result;
            }
            catch (Exception exc)
            {
                exc.ShowError(10);
            }
            return(fm);
        }
        public static AssociatedAddition Create(AssociatedAddition associated)
        {
            object o = associated.Additional;

            object[] ot = null;
            if (o is object[])
            {
                object[] oa = o as object[];
                int      k  = (int)oa[1] + 1;
                ot = new object[] { oa[0], k };
            }
            else
            {
                ot = new object[] { o, 0 };
            }
            return(new AssociatedAddition(associated.AssociatedObject, ot));
        }
 /// <summary>
 /// Accepts formulas
 /// </summary>
 private void acceptFormulas()
 {
     try
     {
         AssociatedAddition aa = new AssociatedAddition(this, null);
         int n = Dimension;
         measurements = new FormulaMeasurement[n];
         result       = new object[n, 2];
         for (int i = 0; i < n; i++)
         {
             MathFormula       formula = MathFormula.FromString(MathSymbolFactory.Sizes, formulaString[i]);
             MathFormula       f       = formula.FullTransform(null);
             ObjectFormulaTree t       = ObjectFormulaTree.CreateTree(f, ElementaryFunctionsCreator.Object);
             measurements[i] = FormulaMeasurement.Create(t, deriOrder, Formula_ + (i + 1), aa);
         }
     }
     catch (Exception e)
     {
         e.ShowError(10);
         this.Throw(e);
     }
 }
Exemple #10
0
 public FormulaMeasurementDerivationDistribution(ObjectFormulaTree tree,
                                                 FormulaMeasurement derivation,
                                                 string name, AssociatedAddition associated)
     : base(tree, derivation, name, associated)
 {
 }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tree">Tree</param>
 /// <param name="name">Measure name</param>
 /// <param name="associated">Associated addition</param>
 protected FormulaMeasurementDerivation(ObjectFormulaTree tree,
                                        string name, AssociatedAddition associated)
     : base(tree, name, associated)
 {
 }
 public FormulaMeasurementDerivation(ObjectFormulaTree tree,
                                     FormulaMeasurement derivation, string name, AssociatedAddition associated)
     : base(tree, name, associated)
 {
     this.derivation = derivation;
 }
Exemple #13
0
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="associated">Associated addition</param>
 /// <param name="exception">Internal exception</param>
 protected AssociatedException(AssociatedAddition associated,
                               Exception exception)
 {
     this.associated = associated;
     this.exception  = exception;
 }
Exemple #14
0
 public Variable(string symbol, AssociatedAddition addition)
 {
     this.symbol   = symbol;
     par           = GetValue;
     this.addition = addition;
 }
Exemple #15
0
        internal void Iterate(bool next)
        {
            AssociatedAddition aa = FormulaMeasurementDerivation.Create(addition);

            temp = temp.Iterate(next, aa);
        }
Exemple #16
0
        /// <summary>
        /// Throws exception
        /// </summary>
        /// <param name="addition">Associated addition</param>
        /// <param name="message">Exception message</param>
        public static void Throw(AssociatedAddition addition, string message)
        {
            Exception ex = new Exception(message);

            Throw(addition, ex);
        }
 /// <summary>
 /// Constructor
 /// </summary>
 /// <param name="tree">Tree</param>
 /// <param name="name">Name</param>
 /// <param name="addition">Addition</param>
 public FormulaMeasurementDistribution(ObjectFormulaTree tree,
                                       string name, AssociatedAddition addition)
     : base(tree, name, addition)
 {
 }