static void GolombExecute( Solver solver, Objective objective, IntSearch search, string instance ) { DateTime start = DateTime.Now; solver.Solve( new GoalAnd( new IntGenerate( solver, solver.IntVarList.ToArray(), IntVarSelector.FirstNotBound, search ), new SolutionGoal( solver, solver.IntObjective, objective, instance ) ) ); SearchAll( solver, instance ); TimeSpan span = DateTime.Now - start; Console.Out.WriteLine(); Console.Out.WriteLine( instance + "\t" + span.ToString() ); }
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) ); } } }