Пример #1
0
        public override Cplex.Goal Execute(Cplex cplex)
        {
            if (IsIntegerFeasible())
            {
                return(null);
            }

            int num = cut.Length;

            Cplex.Goal goal = this;
            for (int i = 0; i < num; ++i)
            {
                IRange thecut = cut[i];
                if (thecut != null)
                {
                    double val = GetValue(thecut.Expr);
                    if (thecut.LB > val + eps || val - eps > thecut.UB)
                    {
                        goal   = cplex.And(cplex.GlobalCutGoal(thecut), goal);
                        cut[i] = null;
                    }
                }
            }

            if (goal == this)
            {
                goal = cplex.And(cplex.BranchAsCplex(), goal);
            }

            return(goal);
        }
Пример #2
0
      public override  Cplex.Goal Execute(Cplex cplex) {
         if ( IsIntegerFeasible() )
            return null;
       
         int num = cut.Length;
         Cplex.Goal goal = this;
         for (int i = 0; i < num; ++i) {
	    IRange thecut = cut[i];
            if ( thecut != null ) {
               double val = GetValue(thecut.Expr);
               if ( thecut.LB > val+eps || val-eps > thecut.UB ) {
                  goal = cplex.And(cplex.GlobalCutGoal(thecut), goal);
                  cut[i] = null;
               }
            }
         }

         if ( goal == this )
            goal = cplex.And(cplex.BranchAsCplex(), goal);

         return goal;
      }
Пример #3
0
        public override Cplex.Goal Execute(Cplex cplex)
        {
            int    besti      = -1;
            double maxObjCoef = System.Double.MinValue;

            // From among all variables that do not respect their minimum
            // usage levels, select the one with maximum objective coefficient.
            for (int i = 0; i < _scVars.Length; i++)
            {
                double val = GetValue(_scVars[i]);
                if (val >= 1e-5 &&
                    val <= _scLbs[i] - 1e-5)
                {
                    if (GetObjCoef(_scVars[i]) >= maxObjCoef)
                    {
                        besti      = i;
                        maxObjCoef = GetObjCoef(_scVars[i]);
                    }
                }
            }

            //  If any are found, branch to enforce the condition that
            //  the variable must either be 0.0 or greater than
            //  the minimum usage level.
            if (besti != -1)
            {
                return(cplex.And(cplex.Or(cplex.LeGoal(_scVars[besti], 0.0),
                                          cplex.GeGoal(_scVars[besti],
                                                       _scLbs[besti])),
                                 this));
            }
            else if (!IsIntegerFeasible())
            {
                return(cplex.And(cplex.BranchAsCplex(), this));
            }

            return(null);
        }
Пример #4
0
        public override Cplex.Goal Execute(Cplex cplex)
        {
            int besti = -1;
             double maxObjCoef = System.Double.MinValue;

             // From among all variables that do not respect their minimum
             // usage levels, select the one with maximum objective coefficient.
             for (int i = 0; i < _scVars.Length; i++) {
            double val = GetValue(_scVars[i]);
            if ( val >= 1e-5            &&
                 val <= _scLbs[i] - 1e-5  ) {
               if (GetObjCoef(_scVars[i]) >= maxObjCoef) {
                  besti = i;
                  maxObjCoef = GetObjCoef(_scVars[i]);
               }
            }
             }

             //  If any are found, branch to enforce the condition that
             //  the variable must either be 0.0 or greater than
             //  the minimum usage level.
             if ( besti != -1 ) {
            return cplex.And(cplex.Or(cplex.LeGoal(_scVars[besti], 0.0),
                                      cplex.GeGoal(_scVars[besti],
                                                   _scLbs[besti])),
                             this );
             }
             else if ( !IsIntegerFeasible() ) {
            return cplex.And(cplex.BranchAsCplex(), this );
             }

             return null;
        }