예제 #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));
 }