Beispiel #1
0
        public static ClSimplexSolver AddPointStay(this ClSimplexSolver solver, ClPoint clp, double weight)
        {
            solver.AddStay(clp.X, ClStrength.Weak, weight);
            solver.AddStay(clp.Y, ClStrength.Weak, weight);

            return(solver);
        }
Beispiel #2
0
        public static ClSimplexSolver AddPointStay(this ClSimplexSolver solver, ClVariable vx, ClVariable vy, double weight)
        {
            solver.AddStay(vx, ClStrength.Weak, weight);
            solver.AddStay(vy, ClStrength.Weak, weight);

            return(solver);
        }
Beispiel #3
0
        private static ClSimplexSolver AddConstraint(this ClSimplexSolver solver, IDictionary <string, ClAbstractVariable> variables, Expression body, ClStrength strength)
        {
            var constraints = FromExpression(variables, body, strength ?? _defaultStrength);

            foreach (var c in constraints)
            {
                solver.AddConstraint(c);
            }

            return(solver);
        }
Beispiel #4
0
        /// <summary>
        /// Add weak stays to the x and y parts of each point. These
        /// have increasing weights so that the solver will try to satisfy
        /// the x and y stays on the same point, rather than the x stay on
        /// one and the y stay on another.
        /// <param name="points">
        /// List of points to add weak stay constraints for.
        /// </param>
        /// </summary>
        public static ClSimplexSolver AddPointStays(this ClSimplexSolver solver, IEnumerable <ClPoint> points)
        {
            double       weight     = 1.0;
            const double MULTIPLIER = 2.0;

            foreach (ClPoint p in points)
            {
                solver.AddPointStay(p, weight);
                weight *= MULTIPLIER;
            }

            return(solver);
        }
Beispiel #5
0
        public static ClSimplexSolver AddPointStay(this ClSimplexSolver solver, ClPoint clp)
        {
            solver.AddPointStay(clp, 1.0);

            return(solver);
        }
Beispiel #6
0
        public static ClSimplexSolver AddPointStay(this ClSimplexSolver solver, ClVariable vx, ClVariable vy)
        {
            solver.AddPointStay(vx, vy, 1.0);

            return(solver);
        }
Beispiel #7
0
        private static ClSimplexSolver AddConstraint(this ClSimplexSolver solver, IEnumerable <ParameterExpression> parameters, Expression body, ClStrength strength)
        {
            Dictionary <string, ClAbstractVariable> variables = parameters.Select(a => solver.GetVariable(a.Name) ?? new ClVariable(a.Name)).ToDictionary(a => a.Name);

            return(AddConstraint(solver, variables, body, strength));
        }
Beispiel #8
0
        public static ClSimplexSolver AddConstraint(this ClSimplexSolver solver, ClAbstractVariable a, ClAbstractVariable b, ClAbstractVariable c, ClAbstractVariable d, Expression <Func <double, double, double, double, bool> > constraint, ClStrength strength = null)
        {
            Dictionary <string, ClAbstractVariable> variables = ConstructVariables(constraint.Parameters, a, b, c, d);

            return(AddConstraint(solver, variables, constraint.Body, strength));
        }
Beispiel #9
0
 public static ClSimplexSolver AddConstraint(this ClSimplexSolver solver, Expression <Func <double, double, double, double, bool> > constraint, ClStrength strength = null)
 {
     return(AddConstraint(solver, constraint.Parameters, constraint.Body, strength));
 }