Exemple #1
0
 public IntGenerate( Solver solver, IntVar[] list, IntVarSelector.Select select, IntSearch search )
     : base(solver)
 {
     m_IntVarList		= list;
     m_SelectVar			= select;
     m_Search			= search;
     m_Depth				= new RevValue<double>( solver.StateStack, 1 );
 }
Exemple #2
0
 public IntGenerate( Solver solver, IntVar[] list )
     : base(solver)
 {
     m_IntVarList		= list;
     m_SelectVar			= IntVarSelector.CardinalityMin;
     m_Search			= new IntSearchDichotomize();
     m_Depth				= new RevValue<double>( solver.StateStack, 1 );
 }
        public void beforTest()
        {
            ARelation r5 = new Between_Int(1, 2, "a", "b");
            ARelation r6 = new Between_String("a", "b", "c", "d");
            ARelation r3 = new IntSearch(1234, "a", "b");
            ARelation r4 = new EndingAttributeSearch(Ending.Attribute.Cold, "a", "b");
            ARelation r1 = new StringSearch("a", "b", "c");
            ARelation r2 = new ComplexRelation();

            rArray = new ARelation[4] { r1, r2, r3, r4 };
        }
Exemple #4
0
        private void Test( IntSearch search )
        {
            MagicSquare ms	= new MagicSquare( 4 );
            Solver solver	= ms.Solver;

            solver.Solve( new IntGenerate( solver,
                                    solver.IntVarList.ToArray(),
                                    IntVarSelector.CardinalityMin,
                                    search ) );

            int count	= CountSolution( solver );

            Assert.AreEqual( count, 880 );
        }
Exemple #5
0
        private void Test(IntSearch search)
        {
            MagicSquare ms     = new MagicSquare(4);
            Solver      solver = ms.Solver;

            solver.Solve(new IntGenerate(solver,
                                         solver.IntVarList.ToArray(),
                                         IntVarSelector.CardinalityMin,
                                         search));

            int count = CountSolution(solver);

            Assert.AreEqual(count, 880);
        }
Exemple #6
0
        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());
        }
Exemple #7
0
        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() );
        }
        public void can_search_Titel_or_Bpm2()
        {
            int bpm = 100;

            ASimpleRelation BPM = new IntSearch(bpm, Track.Property.Bpm.ToString(), Bpm.Property.Value.ToString());
            ComplexRelation cr = new ComplexRelation(Relator.Binary.OR, BPM, this.TITEL);

            IList<Track> tracks = TrackSearch_Service.getTrackListing(cr);
            IList<Track> tracksTITEL = TrackSearch_Service.getTrackListing(this.TITEL);

            foreach(Track track in tracks)
                Assert.IsTrue(
                    (track.Bpm ?? new Bpm(0)).Value == bpm ||
                    Regex.IsMatch(track.Titel.Name, this.titel, RegexOptions.IgnoreCase)
                    );

            Assert.IsTrue(tracks.Count >= tracksTITEL.Count);
        }
        public void can_search_for_Bpm2()
        {
            int bpm = 100;

            ASimpleRelation BPM = new IntSearch(bpm, Track.Property.Bpm.ToString(), Bpm.Property.Value.ToString());
            IList<Track> tracksBPM = TrackSearch_Service.getTrackListing(BPM);

            foreach(Track track in tracksBPM )
                Assert.IsTrue(track.Bpm.Value == bpm);
        }
        public void can_search_Bpm_or_Year()
        {
            Bpm bpm = new Bpm(140);
            Year year = new Year(8);

            ASimpleRelation BPM = new IntSearch(140, Track.Property.Bpm.ToString(), Bpm.Property.Value.ToString());
            ASimpleRelation YEAR = new IntSearch(2008, Track.Property.Year.ToString(), Year.Property.Value.ToString());

            ComplexRelation cr = new ComplexRelation(Relator.Binary.OR, BPM, YEAR);

            IList<Track> tracks = TrackSearch_Service.getTrackListing(cr);

            foreach(Track track in tracks)
                Assert.IsTrue(track.Bpm.Value == bpm.Value || track.Year.Value == year.Value);
        }
        public void can_searchFor_Year_value()
        {
            Year year = new Year(8);

            ASimpleRelation YEAR = new IntSearch(2008, Track.Property.Year.ToString(), Year.Property.Value.ToString());
            IList<Track> tracks = TrackSearch_Service.getTrackListing(YEAR);

            foreach(Track track in tracks)
                Assert.IsTrue(track.Year.Value == year.Value);
        }
Exemple #12
0
 public static Expression BuildIntSearch <TEntity>(Expression target, ParameterExpression parameter, Expression <Func <TEntity, int> > getter, IntSearch search)
 {
     return(BuildMultiValueSearch(target, parameter, getter, search));
 }