示例#1
0
 internal NumericVariable([NotNull] string shortName, [NotNull] string definition, [NotNull] SimpleConstraintSolver solver, double?lo, double?hi, float interpolate)
 {
     if (shortName.Length > 1000)
     {
         throw new ArgumentException("string too long", nameof(shortName));
     }
     if (definition.Length > 1000)
     {
         throw new ArgumentException("string too long", nameof(definition));
     }
     Definition  = definition;
     Name        = ShortName = shortName;
     _solver     = solver;
     Interpolate = interpolate;
     Value       = new Range(lo ?? double.NegativeInfinity, hi ?? double.PositiveInfinity, solver.Eps);
 }
示例#2
0
 public IEnumerable <NumericVariable> Propagate(SimpleConstraintSolver solver)
 {
     if (IsDirty)
     {
         IEnumerable <NumericVariable> outputVariablesFromOldestToNewest =
             _outputVariables.OrderBy(v => v.LastChangedAt);
         IEnumerable <NumericVariable> changed = Update(outputVariablesFromOldestToNewest);
         _lastPropagatedAt = solver.Now;
         _isDirty          = false;
         return(changed.Where(ch => ch != null));
     }
     else
     {
         return(Enumerable.Empty <NumericVariable>());
     }
 }
示例#3
0
 public VariableVector(string name, SimpleConstraintSolver solver, double?x = null, double?y = null, float interpolate = 0.5f)
     : this(name, solver.CreateVariable(name + ".X", x, x, interpolate), solver.CreateVariable(name + ".Y", y, y, interpolate))
 {
 }