示例#1
0
            public void Visit(Compiled.Min elem)
            {
                double left  = ValueOf(elem.Left);
                double right = ValueOf(elem.Right);

                elem.Value = Math.Min(left, right);
                if (left < right)
                {
                    elem.Inputs[0].Weight = 1;
                    elem.Inputs[1].Weight = 0;
                }
                else
                {
                    elem.Inputs[0].Weight = 0;
                    elem.Inputs[1].Weight = 1;
                }
            }
 public void Visit(Compiled.Min elem)
 {
     if (ArgumentIndex == 0)
     {
         if (ValueOf(elem.Left) < ValueOf(elem.Right))
         {
             LocalDerivative = elem.Adjoint;
         }
         else if (ValueOf(elem.Left) == ValueOf(elem.Right))
         {
             if (ValueOf(elem.Left) < 0.5)
             {
                 LocalDerivative = elem.Adjoint;
             }
             else
             {
                 LocalDerivative = 0;                         //elem.Derivative*.5;
             }
         }
         else
         {
             LocalDerivative = 0;
         }
     }
     else
     {
         if (ValueOf(elem.Left) > ValueOf(elem.Right))
         {
             LocalDerivative = elem.Adjoint;
         }
         else if (ValueOf(elem.Left) == ValueOf(elem.Right))
         {
             LocalDerivative = 0;                        //elem.Derivative*.5;
         }
         else
         {
             LocalDerivative = 0;
         }
     }
 }
 //Additions by Carpe Noctem:
 public int Visit(Min min)
 {
     return(Compile(min, () =>
     {
         var leftIndex = min.Left.Accept(this);
         var rightIndex = min.Right.Accept(this);
         var element = new Compiled.Min
         {
             Left = leftIndex,
             Right = rightIndex,
             Inputs = new Compiled.InputEdge[]
             {
                 new Compiled.InputEdge {
                     Index = leftIndex
                 },
                 new Compiled.InputEdge {
                     Index = rightIndex
                 },
             }
         };
         return element;
     }));
 }
 public void Visit(Compiled.Min elem)
 {
     elem.Value = Math.Min(ValueOf(elem.Left), ValueOf(elem.Right));
 }