示例#1
0
 protected FltVarExprVar( FltVar var0, FltVar var1, FltVar var2 )
     : base(var0.Solver, new Variable[] { var0, var1, var2 })
 {
     m_Var0	= var0;
     m_Var1	= var1;
     m_Var2	= var2;
 }
示例#2
0
 protected FltVarExprVar(FltVar var0, FltVar var1, FltVar var2) :
     base(var0.Solver, new Variable[] { var0, var1, var2 })
 {
     m_Var0 = var0;
     m_Var1 = var1;
     m_Var2 = var2;
 }
示例#3
0
 protected FltVarExprVal(FltVar var0, FltVar var1, double val) :
     base(var0.Solver, new Variable[] { var0, var1 })
 {
     m_Var0   = var0;
     m_Var1   = var1;
     m_Value  = val;
     m_Domain = new FltDomain(val);
 }
示例#4
0
文件: SolverCopy.cs 项目: nofear/Mara
        public FltVar[] Copy( FltVar[] other )
        {
            FltVar[] copy	= new FltVar[ other.Length ];
            for( int idx = 0; idx < other.Length; ++idx )
            {
                copy[ idx ]		= m_FltVarList[ other[ idx ].Index ];
            }

            return copy;
        }
示例#5
0
        public FltVar[] ToArray()
        {
            FltVar[] list = new FltVar[Count];

            for (int idx = 0; idx < Count; ++idx)
            {
                list[idx] = At(idx);
            }

            return(list);
        }
示例#6
0
        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 ) );
        }
示例#7
0
        private void InitMatrix(FltDomain domain)
        {
            m_VarList = new FltVarList(m_Solver, m_RowCount * m_ColCount);

            for (int row = 0; row < m_RowCount; ++row)
            {
                for (int col = 0; col < m_ColCount; ++col)
                {
                    string name = row.ToString() + "." + col.ToString();

                    FltVar cell = new FltVar(m_Solver, domain, name);

                    m_VarList.Add(cell);
                }
            }
        }
示例#8
0
        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 );
        }
示例#9
0
        public void Test()
        {
            Solver solver	= new Solver( -1000, 1000 );
            FltVar a	= new FltVar( solver, -10, -5, "a" );
            FltVar b	= new FltVar( solver, -1, 1, "b" );
            FltVar c	= new FltVar( solver, 5, 10, "c" );
            FltVarList list	= new FltVarList( solver, new FltVar[] { a, b, c } );

            IntVar index			= new IntVar( solver );
            FltVarListIndex cons	= list.At( index );
            FltVar result			= cons.Var0;

            solver.Add( cons );
            solver.Propagate();

            result.Intersect( -8, 8 );
            result.Difference( -2, 6 );
            cons.Index.Difference( 1 );
        }
示例#10
0
 public FltVarExprValMulRev(double val, FltVar var1) :
     this(new FltVar(var1.Solver), val, var1)
 {
 }
示例#11
0
 public FltVarExprDiv( FltVar var0, FltVar var1, FltVar var2 )
     : base(var0, var1, var2)
 {
 }
示例#12
0
 public FltVarCmpValLess(FltVar var0, double val) :
     base(var0, val)
 {
 }
示例#13
0
 public FltVarExprValAdd(FltVar var0, FltVar var1, double val) :
     base(var0, var1, val)
 {
 }
示例#14
0
 public FltVarExprDiv( FltVar var1, FltVar var2 )
     : this(new FltVar( var1.Solver ), var1, var2)
 {
 }
示例#15
0
        private void InitMatrix( FltDomain domain )
        {
            m_VarList	= new FltVarList( m_Solver, m_RowCount * m_ColCount );

            for( int row = 0; row < m_RowCount; ++row )
            {
                for( int col = 0; col < m_ColCount; ++col )
                {
                    string name		= row.ToString() + "." + col.ToString();

                    FltVar cell		= new FltVar( m_Solver, domain, name );

                    m_VarList.Add( cell );
                }
            }
        }
示例#16
0
 public FltVarExprValAdd(FltVar var1, double val) :
     this(new FltVar(var1.Solver), var1, val)
 {
 }
示例#17
0
文件: FltVarList.cs 项目: nofear/Mara
 public FltVarList( Solver solver, FltVar[] list )
     : this(solver)
 {
     foreach( FltVar var in list )
     {
         Add( var );
     }
 }
示例#18
0
 public FltVarExprValAddRev( FltVar var0, double val, FltVar var1 )
     : base(var0, var1, val)
 {
 }
示例#19
0
 public FltVarCmpLess(FltVar var0, FltVar var1) :
     base(var0, var1)
 {
 }
示例#20
0
 public FltVarCmpValGreater(FltVar var0, double val) :
     base(var0, val)
 {
 }
示例#21
0
 public FltVarExprValMulRev(FltVar var0, double val, FltVar var1) :
     base(var0, var1, val)
 {
 }
示例#22
0
 public FltVarCmpLess( FltVar var0, FltVar var1 )
     : base(var0, var1)
 {
 }
示例#23
0
 public FltVarList(FltVar v0, FltVar v1, FltVar v2) :
     this(v0.Solver, new FltVar[] { v0, v1, v2 })
 {
 }
示例#24
0
 public FltVarCmpValGreater( FltVar var0, double val )
     : base(var0, val)
 {
 }
示例#25
0
 public FltVarCmpValLess( FltVar var0, double val )
     : base(var0, val)
 {
 }
示例#26
0
 public FltVarExprValMul( FltVar var1, double val )
     : this(new FltVar( var1.Solver ), var1, val)
 {
 }
示例#27
0
文件: FltVarList.cs 项目: nofear/Mara
        public FltVar[] ToArray()
        {
            FltVar[] list	= new FltVar[ Count ];

            for( int idx = 0; idx < Count; ++idx )
            {
                list[ idx ]		= At( idx );
            }

            return list;
        }
示例#28
0
 public FltVarCmpEqual(FltVar var0, FltVar var1) :
     base(var0, var1)
 {
 }
 public FltVarCmpValNotEqual(FltVar var0, double val) :
     base(var0, val)
 {
 }
示例#30
0
 public FltVarExprValMul( FltVar var0, FltVar var1, double val )
     : base(var0, var1, val)
 {
 }
示例#31
0
 public FltVarExprDiv(FltVar var1, FltVar var2) :
     this(new FltVar(var1.Solver), var1, var2)
 {
 }
示例#32
0
文件: FltVarList.cs 项目: nofear/Mara
 public FltVarList( FltVar v0, FltVar v1, FltVar v2 )
     : this(v0.Solver, new FltVar[] { v0, v1, v2 })
 {
 }
示例#33
0
 public FltVarExprDiv(FltVar var0, FltVar var1, FltVar var2) :
     base(var0, var1, var2)
 {
 }
示例#34
0
 public FltVarExprValAddRev( double val, FltVar var1 )
     : this(new FltVar( var1.Solver ), val, var1)
 {
 }
示例#35
0
 public FltVarCmpValEqual( FltVar var0, double val )
     : base(var0, val)
 {
 }
示例#36
0
 public FltVarCmpEqual( FltVar var0, FltVar var1 )
     : base(var0, var1)
 {
 }
示例#37
0
文件: Program.cs 项目: nofear/Mara
        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) );
                }
            }
        }