Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #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);
        }
Пример #5
0
        public static ClSimplexSolver AddPointStay(this ClSimplexSolver solver, ClPoint clp)
        {
            solver.AddPointStay(clp, 1.0);

            return(solver);
        }
Пример #6
0
        public static ClSimplexSolver AddPointStay(this ClSimplexSolver solver, ClVariable vx, ClVariable vy)
        {
            solver.AddPointStay(vx, vy, 1.0);

            return(solver);
        }
Пример #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));
        }
Пример #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));
        }
Пример #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));
 }