Exemplo n.º 1
0
        static void Mul2()
        {
            IntDomain v = new IntDomain();

            for (int idx = 0; idx < 100000; ++idx)
            {
                Solver     s = new Solver(-1000, 1000);
                IntVar     a = new IntVar(s, IntDomain.Random(-100, 100, 1), "a");
                IntVar     b = new IntVar(s, IntDomain.Random(-100, 100, 1), "b");
                IntVar     c = new IntVar(s, IntDomain.Random(-100, 100, 1), "c");
                IntVar     d = new IntVar(s, IntDomain.Random(-100, 100, 1), "d");
                IntVarList l = new IntVarList(s, new IntVar[] { a, b, c, d });
                //p.Add( a + b + c + d );
                s.Add(l.Sum());

                s.Propagate();
                s.PrintVariables();
                s.PrintConstraints();
            }
        }
Exemplo n.º 2
0
        static void Mul1()
        {
            Solver       solver = new Solver(0, 10000);
            IntVarMatrix m1     = new IntVarMatrix(solver, 2, 2, new IntInterval(0, 100));

            int[]        v  = new int[] { 1, 2 };
            IntVarMatrix m2 = m1 * v;

            solver.Propagate();
            solver.PrintVariables(Console.Out);

            Solver     s1 = new Solver(-1000000, 1000000);
            IntVar     a  = new IntVar(s1, IntDomain.Random(-100, 100, 1), "a");
            IntVar     b  = new IntVar(s1, IntDomain.Random(-100, 100, 1), "b");
            IntVar     c  = new IntVar(s1, IntDomain.Random(-100, 100, 1), "c");
            IntVarList l  = new IntVarList(s1, new IntVar[] { a, b, c });

            s1.Add(l.Mul());
            s1.Propagate();
            s1.PrintVariables(Console.Out);
        }