public void Visit(Compiled.ConstraintUtility elem)
 {
     if (ArgumentIndex == 0)
     {
         if (ValueOf(elem.Constraint) < 0.999)
         {
             LocalDerivative = elem.Adjoint;
         }
         else
         {
             LocalDerivative = 0;
         }
     }
     else
     {
         if (ValueOf(elem.Constraint) < 0.999)
         {
             LocalDerivative = 0;
         }
         else
         {
             LocalDerivative = ValueOf(elem.Constraint) * elem.Adjoint;
         }
     }
 }
 public void Visit(Compiled.ConstraintUtility elem)
 {
     if (ValueOf(elem.Constraint) < 0.999)
     {
         elem.Value = ValueOf(elem.Constraint);                    //Math.Max(0,ValueOf(elem.Constraint));
     }
     else
     {
         elem.Value = ValueOf(elem.Constraint) * ValueOf(elem.Utility);
     }
 }
Пример #3
0
            public void Visit(Compiled.ConstraintUtility elem)
            {
                double constraint = ValueOf(elem.Constraint);

                //double utility = ValueOf(elem.Utility);
                if (constraint > 0)
                {
                    elem.Value            = ValueOf(elem.Utility);          //utility;
                    elem.Inputs[0].Weight = 0;
                    elem.Inputs[1].Weight = 1;
                }
                else
                {
                    elem.Value            = constraint;
                    elem.Inputs[0].Weight = 1;
                    elem.Inputs[1].Weight = 0;
                }
            }
            public int Visit(ConstraintUtility cu)
            {
                return(Compile(cu, () =>
                {
                    var constraint = cu.Constraint.Accept(this);
                    var util = cu.Utility.Accept(this);

                    var element = new Compiled.ConstraintUtility
                    {
                        Constraint = constraint,
                        Utility = util,
                        Inputs = new Compiled.InputEdge[]
                        {
                            new Compiled.InputEdge {
                                Index = constraint
                            },
                            new Compiled.InputEdge {
                                Index = util
                            },
                        }
                    };
                    return element;
                }));
            }