예제 #1
0
            public void Visit(Compiled.Max elem)
            {
                double left  = ValueOf(elem.Left);
                double right = ValueOf(elem.Right);

                elem.Value = Math.Max(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 int Visit(Max max)
 {
     return(Compile(max, () =>
     {
         var leftIndex = max.Left.Accept(this);
         var rightIndex = max.Right.Accept(this);
         var element = new Compiled.Max
         {
             Left = leftIndex,
             Right = rightIndex,
             Inputs = new Compiled.InputEdge[]
             {
                 new Compiled.InputEdge {
                     Index = leftIndex
                 },
                 new Compiled.InputEdge {
                     Index = rightIndex
                 },
             }
         };
         return element;
     }));
 }
 public void Visit(Compiled.Max 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;
             }
         }
         else
         {
             LocalDerivative = 0;
         }
     }
     else
     {
         if (ValueOf(elem.Right) > ValueOf(elem.Left))
         {
             LocalDerivative = elem.Adjoint;
         }
         else
         {
             LocalDerivative = 0;
         }
     }
 }
 public void Visit(Compiled.Max elem)
 {
     elem.Value = Math.Max(ValueOf(elem.Left), ValueOf(elem.Right));
 }