public void UnbuildableTest() { var set = new SetVariables(list, 10, 10, new SetVariables.Point(5, 5), new SetVariables.Point(0, 0)); set.Unbuildable(4, 4); for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if (i == 4 && j == 4) { Assert.AreEqual(-1, set.Domain(0).IndexOf(i * 10 + j)); } else { Assert.AreNotEqual(-1, set.Domain(0).IndexOf(i * 10 + j)); } } } var listPoint = new List <SetVariables.Point> { new SetVariables.Point(3, 9), new SetVariables.Point(8, 7), new SetVariables.Point(1, 1) }; set.Unbuildable(listPoint); for (int i = 0; i < 10; ++i) { for (int j = 0; j < 10; ++j) { if ((i == 4 && j == 4) || (i == 3 && j == 9) || (i == 8 && j == 7) || (i == 1 && j == 1)) { Assert.AreEqual(-1, set.Domain(0).IndexOf(i * 10 + j)); } else { Assert.AreNotEqual(-1, set.Domain(0).IndexOf(i * 10 + j)); } } } #if DEBUG set.Print(); #endif }
static void Main( string[] args ) { var unbuildables = new List< SetVariables.Point > { new SetVariables.Point( 7, 12 ), new SetVariables.Point( 7, 13 ), new SetVariables.Point( 7, 14 ), new SetVariables.Point( 7, 15 ), new SetVariables.Point( 8, 10 ), new SetVariables.Point( 8, 11 ), new SetVariables.Point( 8, 12 ), new SetVariables.Point( 8, 13 ), new SetVariables.Point( 8, 14 ), new SetVariables.Point( 8, 15 ), new SetVariables.Point( 9, 10 ), new SetVariables.Point( 9, 11 ), new SetVariables.Point( 9, 12 ), new SetVariables.Point( 9, 13 ), new SetVariables.Point( 9, 14 ), new SetVariables.Point( 9, 15 ), new SetVariables.Point( 10, 8 ), new SetVariables.Point( 10, 9 ), new SetVariables.Point( 10, 10 ), new SetVariables.Point( 10, 11 ), new SetVariables.Point( 10, 12 ), new SetVariables.Point( 10, 13 ), new SetVariables.Point( 10, 14 ), new SetVariables.Point( 10, 15 ), new SetVariables.Point( 11, 8 ), new SetVariables.Point( 11, 9 ), new SetVariables.Point( 11, 10 ), new SetVariables.Point( 11, 11 ), new SetVariables.Point( 11, 12 ), new SetVariables.Point( 11, 13 ), new SetVariables.Point( 11, 14 ), new SetVariables.Point( 11, 15 ) }; var domain = new ghost.Domain( 16 * 12, 0 ); var listBuildings = MakeTerranBuildings( domain ); var setBuildings = new SetVariables( listBuildings, 12, 16, new SetVariables.Point( 11, 7 ), new SetVariables.Point( 6, 15 ) ); setBuildings.Unbuildable( unbuildables ); var constraints = new List< Constraint > { new OverLap( setBuildings ), new Buildable( setBuildings ), new WallShape( setBuildings ), new StartingTargetTiles( setBuildings ) }; var objective = new GapObjective(); var solver = new ghost.Solver< Variable, SetVariables, Constraint >( setBuildings, constraints, objective ); Console.WriteLine( "Start solving trivial test" ); solver.solve( 20, 150, false ); // 3.4 GHz, mono 20,150 7 tours 44 iterations // C++ 12 tours 400 iteratons }
public void UnbuildableTest() { var set = new SetVariables( list, 10, 10, new SetVariables.Point( 5, 5 ), new SetVariables.Point( 0, 0 ) ); set.Unbuildable( 4, 4 ); for( int i = 0 ; i < 10 ; ++i ) for( int j = 0 ; j < 10 ; ++j ) if( i == 4 && j == 4 ) Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.EqualTo( -1 ) ); else Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.Not.EqualTo( -1 ) ); var listPoint = new List<SetVariables.Point> { new SetVariables.Point( 3, 9 ), new SetVariables.Point( 8, 7 ), new SetVariables.Point( 1, 1 )}; set.Unbuildable( listPoint ); for( int i = 0 ; i < 10 ; ++i ) for( int j = 0 ; j < 10 ; ++j ) if( ( i == 4 && j == 4 ) || ( i == 3 && j == 9 ) || ( i == 8 && j == 7 ) || ( i == 1 && j == 1 ) ) Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.EqualTo( -1 ) ); else Assert.That( set.Domain( 0 ).IndexOf( i * 10 + j ), Is.Not.EqualTo( -1 ) ); #if DEBUG set.Print(); #endif }