示例#1
0
文件: TestBase.cs 项目: nofear/Mara
        public static int CountSolution( Solver solver )
        {
            int count	= 1;
            while( solver.Next() )
            {
                if( count % 100 == 0 )
                {
                    Console.Out.Write( "." );
                }

                ++count;
            }

            Console.Out.WriteLine( " #" + count.ToString() );

            return count;
        }
示例#2
0
文件: Program.cs 项目: nofear/Mara
        private static void Poly1()
        {
            Random rnd	= new Random(0);
            for( int i = 0; i < 10000000; ++i )
            {
                double a	= rnd.Next( -10, 10 );
                double b	= rnd.Next( -10, 10 ) ;
                double c	= rnd.Next( -10, 10 ) ;

                a=2;b=8;c=8;

                Solver s		= new Solver( -1000000, 1000000 );
                FltVar x		= new FltVar( s, "x" );
                FltVarExpr exp	= a*x*x+ b*x;
                s.Add( exp );
                s.Add( exp == -c );

                s.PrintConstraints();
                s.PrintVariables();

                Console.Out.WriteLine( "{0}.x^2 + {1}.x + {2} = 0", a, b, c );

                s.Solve( new FltGenerate( s, new FltVar[] { x } ) );
                Console.Out.WriteLine( x.ToString(true) );
                while( s.Next() )
                {
                    Console.Out.WriteLine( x.ToString(true) );
                }
            }
        }