Пример #1
0
        /// <summary>
        /// Returns true iff exactly one argument is set for this solver using SetCbcMainArgs,
        /// and that argument is "-branchAndBound".
        /// </summary>
        /// <param name="solver"></param>
        /// <returns></returns>
        public static bool UseBranchAndBound(this COIN.OsiCbcSolverInterface solver)
        {
            string[] args = solver.GetCbcSolverArgs();
            if (args.Length == 1 && string.Equals(args[0], "-branchAndBound", StringComparison.CurrentCultureIgnoreCase))
            {
                return(true);
            }

            return(false);
        }
Пример #2
0
 /// <summary>
 /// Returns the array of arguments to be used when solving using an instance of OsiCbcSolverInterface.
 /// Returns an empty array if no arguments were found.
 /// See also Sonnet.Solve(..)
 /// </summary>
 /// <param name="solver">The OsiCbcSolverInterface instance.</param>
 /// <returns>The arguments for CbcMain1(..).</returns>
 public static string[] GetCbcSolverArgs(this COIN.OsiCbcSolverInterface solver)
 {
     if (cbcSolverArgs.TryGetValue(solver, out var result))
     {
         return(result.ToArray());
     }
     else
     {
         return(new string[0]);
     }
 }
Пример #3
0
        /// <summary>
        /// Adds one or more args to the array of arguments to be used when solving using an instance of OsiCbcSolverInterface.
        /// The final list of arguments passed to CbcMain is   [SolverArgs] -solve -quit
        /// See also Sonnet.Solve(..)        ///
        /// </summary>
        /// <param name="solver">The OsiCbcSolverInterface instance.</param>
        /// <param name="args">The list of arguments added for CbcMain1(..)</param>
        public static void AddCbcSolverArgs(this COIN.OsiCbcSolverInterface solver, params string[] args)
        {
            Ensure.NotNull(args);

            // Already have some args for this solver?
            List <string> result;

            if (!cbcSolverArgs.TryGetValue(solver, out result))
            {
                result = new List <string>();
                cbcSolverArgs[solver] = result;
            }

            result.AddRange(args);
        }
Пример #4
0
 /// <summary>
 /// Sets the array of arguments to be used when solving using an instance of OsiCbcSolverInterface.
 /// See also Sonnet.Solve(..)
 /// </summary>
 /// <param name="solver">The OsiCbcSolverInterface instance.</param>
 /// <param name="args">The arguments for CbcMain1(..).</param>
 public static void SetCbcSolverArgs(this COIN.OsiCbcSolverInterface solver, params string [] args)
 {
     cbcSolverArgs[solver] = args;
 }