예제 #1
0
파일: TestGolomb.cs 프로젝트: nofear/Mara
        public int Golomb( int n )
        {
            Golomb golomb		= new Golomb( n );
            Solver solver		= golomb.Solver;
            solver.IntObjective.Var		= golomb.MarkList[ golomb.MarkList.Count - 1 ];
            solver.IntObjective.Step	= 1;

            SolutionGoal solution	= new SolutionGoal( solver, solver.IntObjective.Var );

            solver.Solve(	new GoalAnd(
                                new IntGenerate( solver,
                                    golomb.MarkList.ToArray(),
                                    IntVarSelector.FirstNotBound,
                                    new IntSearchInstantiateBest() ),
                                solution ) );

            int count	= CountSolution( solver );

            return solution.Value;
        }
예제 #2
0
파일: AppGolomb.cs 프로젝트: nofear/Mara
        public static void Golomb( int n )
        {
            Golomb golomb		= new Golomb( n );
            Solver solver		= golomb.Solver;
            solver.IntObjective.Var		= golomb.MarkList[ golomb.MarkList.Count - 1 ];
            solver.IntObjective.Step	= 1;

            Objective objective		= new Objective();
            objective.Value			= int.MaxValue;
            objective.Register( solver.IntObjective );

            solver.Solve( new GoalAnd( new IntGenerate( solver,
                                                golomb.MarkList.ToArray(),
                                                IntVarSelector.FirstNotBound,
                                                new IntSearchInstantiateBest() ),
                                        new SolutionGoal( solver, solver.IntObjective, objective, "0" ) ) );

            SearchAll( solver );

            Console.Out.WriteLine();
            Console.Out.WriteLine( solver.Time.ToString() );
        }