Example #1
0
        public void Test()
        {
            Solver solver	= new Solver( -1000, 1000 );
            IntVar i0	= new IntVar( solver, 0, 10 );
            IntVar i1	= new IntVar( solver, 10, 20 );
            IntVar i2	= new IntVar( solver, 20, 30 );
            IntVar s	= new IntVar( solver, 30, 60 );

            IntVarList list		= new IntVarList( solver, new IntVar[] { i0, i1, i2 } );
            IntVarListSum sum	= list.Sum();

            solver.Add( sum );
            solver.Propagate();

            Assert.AreEqual( s.Domain, sum.Var0.Domain );
        }
Example #2
0
        static void Test1()
        {
            Solver solver		= new Solver( 0, 100 );
            IntVar a			= new IntVar( solver, 0, 10 );
            IntVar b			= new IntVar( solver, 0, 10 );
            IntVar c			= new IntVar( solver, 0, 10 );
            IntVarList l		= new IntVarList( a, b, c );
            IntVarListSum sum	= l.Sum();

            solver.Add( sum );
            solver.Propagate();

            sum.Var0.Value		= 6;

            a.Value		= 1;
            b.Value		= 2;
        }
Example #3
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();
            }
        }