示例#1
0
        public CpSolverStatus SolveWithSolutionCallback(CpModel model, SolutionCallback cb)
        {
            // Setup search.
            CreateSolveWrapper();
            if (string_parameters_ != null)
            {
                solve_wrapper_.SetStringParameters(string_parameters_);
            }
            if (log_callback_ != null)
            {
                solve_wrapper_.AddLogCallbackFromClass(log_callback_);
            }
            if (cb != null)
            {
                solve_wrapper_.AddSolutionCallback(cb);
            }

            response_ = solve_wrapper_.Solve(model.Model);

            // Cleanup search.
            if (cb != null)
            {
                solve_wrapper_.ClearSolutionCallback(cb);
            }
            ReleaseSolveWrapper();

            return(response_.Status);
        }
示例#2
0
        public CpSolverStatus SearchAllSolutions(CpModel model, SolutionCallback cb)
        {
            string old_parameters = string_parameters_;

            string_parameters_ += " enumerate_all_solutions:true";
            Solve(model, cb);
            string_parameters_ = old_parameters;
            return(response_.Status);
        }
示例#3
0
 public CpSolverStatus Solve(CpModel model)
 {
     if (string_parameters_ != null)
     {
         response_ = SatHelper.SolveWithStringParameters(model.Model, string_parameters_);
     }
     else
     {
         response_ = SatHelper.Solve(model.Model);
     }
     return(response_.Status);
 }
示例#4
0
 public CpSolverStatus SolveWithSolutionCallback(CpModel model, SolutionCallback cb)
 {
     if (string_parameters_ != null)
     {
         response_ = SatHelper.SolveWithStringParametersAndSolutionCallback(model.Model, string_parameters_, cb);
     }
     else
     {
         response_ = SatHelper.SolveWithStringParametersAndSolutionCallback(model.Model, "", cb);
     }
     return(response_.Status);
 }
示例#5
0
 public CpSolverStatus SearchAllSolutions(CpModel model, SolutionCallback cb)
 {
     if (string_parameters_ != null)
     {
         string extra_parameters = " enumerate_all_solutions:true";
         response_ = SatHelper.SolveWithStringParametersAndSolutionCallback(
             model.Model, string_parameters_ + extra_parameters, cb);
     }
     else
     {
         string parameters = "enumerate_all_solutions:true";
         response_ = SatHelper.SolveWithStringParametersAndSolutionCallback(model.Model, parameters, cb);
     }
     return(response_.Status);
 }
示例#6
0
 public CumulativeConstraint(CpModel cp_model, CpModelProto model) : base(model)
 {
     this.cp_model_ = cp_model;
 }
示例#7
0
 public ReservoirConstraint(CpModel cp_model, CpModelProto model) : base(model)
 {
     this.cp_model_ = cp_model;
 }
示例#8
0
 public CpSolverStatus SolveWithSolutionCallback(CpModel model, SolutionCallback cb)
 {
     return(Solve(model, cb));
 }
示例#9
0
 public CpSolverStatus Solve(CpModel model)
 {
     SolveWithSolutionCallback(model, null);
     return(response_.Status);
 }