17using Google.OrTools.Util;
19using System.Collections;
20using System.Collections.Generic;
22using System.Runtime.CompilerServices;
23using Google.Protobuf.Collections;
30 class SolverException : Exception
32 public SolverException(String methodName, String msg) : base(methodName +
": " + msg)
44 this.logCallback_ =
null;
54 if (logCallback_ ==
null)
56 helper_.ClearLogCallback();
60 helper_.SetLogCallbackFromDirectorClass(logCallback_);
62 helper_.Solve(model.
Helper);
63 if (!helper_.HasResponse())
67 return helper_.Status();
76 helper_.EnableOutput(enable);
82 helper_.SetTimeLimitInSeconds(limit);
88 helper_.SetSolverSpecificParameters(parameters);
97 return helper_.SolverIsSupported();
106 return helper_.InterruptSolve();
115 return helper_.HasResponse();
124 return helper_.HasSolution();
134 if (!helper_.HasSolution())
136 throw new SolverException(
"Solver.ObjectiveValue",
"Solve() was not called or no solution was found");
138 return helper_.ObjectiveValue();
149 if (!helper_.HasSolution())
151 throw new SolverException(
"Solver.BestObjectiveBound",
152 "Solve() was not called or no solution was found");
154 return helper_.BestObjectiveBound();
164 if (!helper_.HasSolution())
166 throw new SolverException(
"Solver.Value())",
"Solve() was not called or no solution was found");
168 return helper_.VariableValue(var.
Index);
176 if (!helper_.HasSolution())
178 throw new SolverException(
"Solver.ReducedCost())",
"Solve() was not called or no solution was found");
180 return helper_.ReducedCost(var.
Index);
189 if (!helper_.HasSolution())
191 throw new SolverException(
"Solver.DualValue())",
"Solve() was not called or no solution was found");
193 return helper_.DualValue(ct.
Index);
202 if (!helper_.HasSolution())
204 throw new SolverException(
"Solver.Activity())",
"Solve() was not called or no solution was found");
206 return helper_.Activity(ct.
Index);
218 logCallback_ = value;
228 return helper_.WallTime();
238 return helper_.UserTime();