public IntObjective( Solver solver ) : base(solver) { m_Variable = null; m_Value = int.MaxValue; m_Step = 1; }
protected ConstraintVar( Solver solver, Variable[] varList, VariableList[] varListList ) : base(solver) { m_VariableList = varList; m_VariableListList = varListList; OnSet(); }
protected Constraint( Solver solver ) : base(solver) { m_Level = PropagateLevel.Normal; m_CountFail = 0; m_CountUpdate = 0; m_Index = -1; }
public Cover( Solver solver, int columns, IntVarList list ) : base(solver) { m_Columns = columns; m_List = list; m_Avail = new IntVar( solver, 0, list.Count - 1 );; m_Index = new IntVar( solver, IntDomain.Empty, "" ); m_Union = new IntVar( solver, IntDomain.Empty, "" ); }
public void Enumerator() { Solver solver = new Solver( -1000, 1000 ); IntVar var = new IntVar( solver, 0 ); var.Difference( 0 ); foreach( int x in var ) { Assert.Fail(); } }
public void Test() { Solver solver = new Solver( -100, 100 ); FltVar a = new FltVar( solver, 5, 10, "a" ); FltVarNeg neg = -a; FltVar b = neg.Var0; solver.Add( neg ); solver.Propagate(); Assert.AreEqual( b.Domain, new FltDomain( -10, -5 ) ); }
public void Test() { Solver solver = new Solver( -1000, 1000 ); FltVar i0 = new FltVar( solver, 0, 10 ); FltVar i1 = new FltVar( solver, 10, 20 ); FltVar i2 = new FltVar( solver, 20, 30 ); FltVar s = new FltVar( solver, 30, 60 ); FltVarList list = new FltVarList( solver, new FltVar[] { i0, i1, i2 } ); FltVarListSum sum = list.Sum(); solver.Add( sum ); solver.Propagate(); Assert.AreEqual( s.Domain, sum.Var0.Domain ); }
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; }
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 Test() { Solver solver = new Solver( -10000, 10000 ); IntVar a = new IntVar( solver, 1, 2, "a" ); IntVar b = new IntVar( solver, 2, 3, "b" ); IntVar c = new IntVar( solver, 3, 4, "c" ); IntVar d = new IntVar( solver, 4, 5, "d" ); IntVarListDotProduct cons = new IntVarListDotProduct( solver, new IntVar[] { a, b, c, d }, new int[] { 1000, 100, 10, 1 } ); IntVar result = cons.Var0; solver.Add( cons ); solver.Propagate(); Assert.AreEqual( result.Domain, new IntDomain( 1234, 2345 ) ); }
public void Test() { Solver solver = new Solver( -1000, 1000 ); IntVar a = new IntVar( solver, -10, -5, "a" ); IntVar b = new IntVar( solver, -1, 1, "b" ); IntVar c = new IntVar( solver, 5, 10, "c" ); IntVarList list = new IntVarList( solver, new IntVar[] { a, b, c } ); IntVar index = new IntVar( solver ); IntVarListIndex cons = list.At( index ); IntVar result = cons.Var0; solver.Add( cons ); solver.Propagate(); result.Intersect( -8, 8 ); result.Difference( -2, 6 ); cons.Index.Difference( 1 ); }
public void High() { Solver solver = new Solver( -10000, 10000 ); IntVar a = new IntVar( solver, 1, 3, "a" ); IntVar b = new IntVar( solver, 1, 2, "b" ); IntVar c = new IntVar( solver, 1, 2, "c" ); IntVarListAllDifferent cons = new IntVarListAllDifferent( solver, new IntVar[] { a, b, c } ); cons.Level = PropagateLevel.High; solver.Add( cons ); solver.Propagate(); Assert.AreEqual( a.Domain, new IntDomain( 3, 3 ) ); Assert.AreEqual( b.Domain, new IntDomain( 1, 2 ) ); Assert.AreEqual( c.Domain, new IntDomain( 1, 2 ) ); }
public GoalPrintVar( Solver solver, Variable var ) : base(solver) { m_Var = var; }
public Problem( IntInterval horizon ) { m_Solver = new Solver( horizon ); }
static void Test3() { Solver solver = new Solver( 0, 10000 ); IntVar a = new IntVar( solver, 1, 9, "a" ); IntVar b = new IntVar( solver, 1, 9, "b" ); IntVarExpr expr = a * a + b * b; solver.Add( expr ); solver.Propagate(); a.Value = 4; b.Value = 2; }
public SolutionGoal( Solver solver, IntVar var ) : base(solver) { m_Variable = var; m_Value = m_Variable.Domain.Max; }
static void Prop1() { Solver solver = new Solver( -10000, 10000 ); IntVar a = new IntVar( solver, 6, 10, "a" ); IntVar b = new IntVar( solver, 1, 2, "b" ); IntVarExprVal cons = new IntVarExprValMul( a, b, 5 ); solver.Add( cons ); solver.Propagate(); Console.WriteLine(); }
static void Test2() { Solver solver = new Solver( 0, 100 ); IntVar a = new IntVar( solver, 1, 3, "a" ); IntVar b = new IntVar( solver, 1, 3, "b" ); IntVar c = new IntVar( solver, 1, 3, "c" ); IntVarList l = new IntVarList( a, b, c ); IntVarListAllDifferent diff = l.AllDifferent(); solver.Add( diff ); solver.Propagate(); a.Value = 1; b.Value = 2; }
public SolutionGoal( Solver solver, IntObjective objective, Objective value, string instance ) : base(solver) { m_Objective = objective; m_Value = value; m_Instance = instance; }
public SolverBase( Solver solver ) { m_Solver = solver; }
public GoalDelegate( Solver solver, ExecuteDelegate execute ) : base(solver) { m_Execute = execute; }
protected Goal( Solver solver ) : base(solver) { }
public FltVarList( Solver solver ) : this(solver, 0) { }
public GoalAnd( Solver solver, Goal[] goalList ) : base(solver) { m_GoalList = goalList; m_Index = new RevValue<int>( solver.StateStack, 0 ); }
public FltVarList( Solver solver, FltVar[] list ) : this(solver) { foreach( FltVar var in list ) { Add( var ); } }
public Problem(IntInterval horizon) { m_Solver = new Solver(horizon); }
static void Test1() { Solver solver = new Solver( 0, 100 ); IntVar a = new IntVar( solver, 0, 10 ); IntVar b = new IntVar( solver, 0, 10 ); IntVar c = new IntVar( solver, 0, 10 ); IntVarList l = new IntVarList( a, b, c ); IntVarListSum sum = l.Sum(); solver.Add( sum ); solver.Propagate(); sum.Var0.Value = 6; a.Value = 1; b.Value = 2; }
public FltVarList( Solver solver, int capacity ) : base(solver) { Capacity = capacity; }
public GoalOr( Solver solver, Goal[] goalList ) : base(solver) { m_GoalList = goalList; m_Index = 0; }
public SolverBaseCopy( Solver solver ) : base(solver) { }
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) ); } } }