public void Visit(Compiled.LTConstraint elem)
            {
                double diff = ValueOf(elem.Left) - ValueOf(elem.Right);

                if (diff < 0)
                {
                    LocalDerivative = 0;
                }

                /*else {
                 *      if (ArgumentIndex == 0) {
                 *              LocalDerivative = - elem.Derivative * Math.Max(elem.Steepness,(ValueOf(elem.Left)-ValueOf(elem.Right)));
                 *      } else {
                 *              LocalDerivative = elem.Derivative * Math.Max(elem.Steepness,(ValueOf(elem.Left)-ValueOf(elem.Right)));
                 *      }
                 * }*/
                //Normal behaviour:
                else
                {
                    if (ArgumentIndex == 0)
                    {
                        LocalDerivative = -elem.Steepness * elem.Adjoint;
                    }
                    else
                    {
                        LocalDerivative = elem.Steepness * elem.Adjoint;
                    }
                }
            }
            public int Visit(LTConstraint constraint)
            {
                return(Compile(constraint, () =>
                {
                    var lIndex = constraint.Left.Accept(this);
                    var rIndex = constraint.Right.Accept(this);

                    var element = new Compiled.LTConstraint
                    {
                        Left = lIndex,
                        Right = rIndex,
                        Steepness = constraint.Steepness,
                        Inputs = new Compiled.InputEdge[]
                        {
                            new Compiled.InputEdge {
                                Index = lIndex
                            },
                            new Compiled.InputEdge {
                                Index = rIndex
                            },
                        }
                    };
                    return element;
                }));
            }
 public void Visit(Compiled.LTConstraint elem)
 {
     if (ValueOf(elem.Left) < ValueOf(elem.Right))
     {
         elem.Value = 1;
     }
     else
     {
         elem.Value = elem.Steepness * (ValueOf(elem.Right) - ValueOf(elem.Left));
     }
 }
Exemple #4
0
            public void Visit(Compiled.LTConstraint elem)
            {
                double left  = ValueOf(elem.Left);
                double right = ValueOf(elem.Right);

                if (left < right)
                {
                    elem.Value            = 1;
                    elem.Inputs[0].Weight = 0;
                    elem.Inputs[1].Weight = 0;
                }
                else
                {
                    elem.Value            = elem.Steepness * (right - left);
                    elem.Inputs[0].Weight = -elem.Steepness;
                    elem.Inputs[1].Weight = elem.Steepness;
                }
            }