Ge() публичный Метод

public Ge ( ConstraintTypes cType, int weight ) : void
cType ConstraintTypes
weight int
Результат void
Пример #1
0
    public static void Main(String[] args)
    {
        // Create a constraint network
        Network net = new Network();
        // Declare variables
        IntVariable x = new IntVariable(net);
        IntVariable y = new IntVariable(net);
        // x >= 0
        x.Ge(0);
        // y >= 0
        y.Ge(0);
        // x + y == 7
        x.Add(y).Equals(7);
        // 2x + 4y == 20
        x.Multiply(2).Add(y.Multiply(4)).Equals(20);
        // Solve the problem
        Solver solver = new DefaultSolver(net);
        /*Solution solution = solver.findAll(Solution);
        int xv = solution.getIntValue(x);
        int yv = solution.getIntValue(y);
        Console.Out.WriteLine("x = " + xv + ", y = " + yv);
        */

        for (solver.Start(); solver.WaitNext(); solver.Resume()) {
        Solution solution = solver.Solution;
        int xv = solution.GetIntValue(x);
        int yv = solution.GetIntValue(y);
        Console.Out.WriteLine("x8 = " + xv + ", y = " + yv);
        }
        solver.Stop();

        //solver.findAll(new FirstStepHandler(x, y));
        Console.In.ReadLine();
    }
Пример #2
0
        public static void Main(string[] args)
        {
            var net = new Network();

            var x = new IntVariable(net, 0, 708);
            var y = new IntVariable(net, 0, 708);
            var z = new IntVariable(net, 0, 708);
            var t = new IntVariable(net, 0, 708);
            x.Add(y).Add(z).Add(t).Equals(711);
            x.Ge(y);
            y.Ge(z);
            z.Ge(t);
            x.Multiply(y).Multiply(z).Multiply(t).Equals(711000000);
            Solver solver = new DefaultSolver(net);
            for (solver.Start(); solver.WaitNext(); solver.Resume())
            {
                var solution = solver.Solution;
                Console.Out.WriteLine();
                Console.Out.WriteLine(" {0:F} + {1:F} + {2:F} + {3:F} = {4:F} ",
                                      solution.GetIntValue(x)/100.0, solution.GetIntValue(y)/100.0,
                                      solution.GetIntValue(z)/100.0, solution.GetIntValue(t)/100.0,7.11 );
            }
            solver.Stop();
            Console.ReadLine();
        }