<ahref="CpSolver_8java.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2021 Google LLC</span></div><divclass="line"><aname="l00002"></a><spanclass="lineno"> 2</span> <spanclass="comment">// Licensed under the Apache License, Version 2.0 (the "License");</span></div><divclass="line"><aname="l00003"></a><spanclass="lineno"> 3</span> <spanclass="comment">// you may not use this file except in compliance with the License.</span></div><divclass="line"><aname="l00004"></a><spanclass="lineno"> 4</span> <spanclass="comment">// You may obtain a copy of the License at</span></div><divclass="line"><aname="l00005"></a><spanclass="lineno"> 5</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00006"></a><spanclass="lineno"> 6</span> <spanclass="comment">// http://www.apache.org/licenses/LICENSE-2.0</span></div><divclass="line"><aname="l00007"></a><spanclass="lineno"> 7</span> <spanclass="comment">//</span></div><divclass="line"><aname="l00008"></a><spanclass="lineno"> 8</span> <spanclass="comment">// Unless required by applicable law or agreed to in writing, software</span></div><divclass="line"><aname="l00009"></a><spanclass="lineno"> 9</span> <spanclass="comment">// distributed under the License is distributed on an "AS IS" BASIS,</span></div><divclass="line"><aname="l00010"></a><spanclass="lineno"> 10</span> <spanclass="comment">// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.</span></div><divclass="line"><aname="l00011"></a><spanclass="lineno"> 11</span> <spanclass="comment">// See the License for the specific language governing permissions and</span></div><divclass="line"><aname="l00012"></a><spanclass="lineno"> 12</span> <spanclass="comment">// limitations under the License.</span></div><divclass="line"><aname="l00013"></a><spanclass="lineno"> 13</span> </div><divclass="line"><aname="l00014"></a><spanclass="lineno"> 14</span> <spanclass="keyword">package </span>com.google.ortools.sat;</div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> </div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> <spanclass="keyword">import</span><aclass="code"href="namespacecom.html">com</a>.<aclass="code"href="namespacecom_1_1google.html">google</a>.<aclass="code"href="namespacecom_1_1google_1_1ortools.html">ortools</a>.<aclass="code"href="namespacecom_1_1google_1_1ortools_1_1sat.html">sat</a>.<aclass="code"href="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverResponse.html">CpSolverResponse</a>;</div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="keyword">import</span><aclass="code"href="namespacecom.html">com</a>.<aclass="code"href="namespacecom_1_1google.html">google</a>.<aclass="code"href="namespacecom_1_1google_1_1ortools.html">ortools</a>.<aclass="code"href="namespacecom_1_1google_1_1ortools_1_1sat.html">sat</a>.<aclass="code"href="enumcom_1_1google_1_1ortools_1_1sat_1_1CpSolverStatus.html">CpSolverStatus</a>;</div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="keyword">import</span><aclass="code"href="namespacecom.html">com</a>.<aclass="code"href="namespacecom_1_1google.html">google</a>.<aclass="code"href="namespacecom_1_1google_1_1ortools.html">ortools</a>.<aclass="code"href="namespacecom_1_1google_1_1ortools_1_1sat.html">sat</a>.<aclass="code"href="classcom_1_1google_1_1ortools_1_1sat_1_1SatParameters.html">SatParameters</a>;</div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="keyword">import</span> java.util.List;</div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="keyword">import</span> java.util.function.Consumer;</div><
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a192d2a91adc9495a4109c494f976ee4d"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a192d2a91adc9495a4109c494f976ee4d">com.google.ortools.sat.CpSolver.objectiveValue</a></div><divclass="ttdeci">double objectiveValue()</div><divclass="ttdoc">Returns the best objective value found during search.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00117">CpSolver.java:117</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr_html"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr.html">com.google.ortools.sat.LinearExpr</a></div><divclass="ttdoc">A linear expression (sum (ai * xi) + b).</div><divclass="ttdef"><b>Definition:</b><ahref="LinearExpr_8java_source.html#l00019">LinearExpr.java:19</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a4b61919bdcff3d458bf6807086c48be6"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a4b61919bdcff3d458bf6807086c48be6">com.google.ortools.sat.CpSolver.solveWithSolutionCallback</a></div><divclass="ttdeci">CpSolverStatus solveWithSolutionCallback(CpModel model, CpSolverSolutionCallback cb)</div><divclass="ttdoc">Solves the given model, passes each incumber solution to the solution callback if not null,...</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00074">CpSolver.java:74</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a6eba1a016a99e80decec8801337f35de"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a6eba1a016a99e80decec8801337f35de">com.google.ortools.sat.CpSolver.numBranches</a></div><divclass="ttdeci">long numBranches()</div><divclass="ttdoc">Returns the number of branches explored during search.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00155">CpSolver.java:155</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a2eb2b2447bd59c1f00a9495e63d6b7e3"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a2eb2b2447bd59c1f00a9495e63d6b7e3">com.google.ortools.sat.CpSolver.wallTime</a></div><divclass="ttdeci">double wallTime()</div><divclass="ttdoc">Returns the wall time of the search.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00165">CpSolver.java:165</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_ad6a3705cb3e6ea4939bfb0bb578d4d01"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#ad6a3705cb3e6ea4939bfb0bb578d4d01">com.google.ortools.sat.CpSolver.booleanValue</a></div><divclass="ttdeci">Boolean booleanValue(Literal var)</div><divclass="ttdoc">Returns the Boolean value of a literal in the last solution found.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00140">CpSolver.java:140</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html">com.google.ortools.sat.CpSolver</a></div><divclass="ttdoc">Wrapper around the SAT solver.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00028">CpSolver.java:28</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a223d9fe8c0446517983a4cce6e8611ea"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a223d9fe8c0446517983a4cce6e8611ea">com.google.ortools.sat.CpSolver.value</a></div><divclass="ttdeci">long value(LinearArgument expr)</div><divclass="ttdoc">Returns the value of a linear expression in the last solution found.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00130">CpSolver.java:130</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a94cfac9362c485d50a8930688fe81a3e"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a94cfac9362c485d50a8930688fe81a3e">com.google.ortools.sat.CpSolver.solve</a></div><divclass="ttdeci">CpSolverStatus solve(CpModel model)</div><divclass="ttdoc">Solves the given model, and returns the solve status.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00037">CpSolver.java:37</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a14e6e324b58ee2744bfed85969fd0f10"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a14e6e324b58ee2744bfed85969fd0f10">com.google.ortools.sat.CpSolver.CpSolver</a></div><divclass="ttdeci">CpSolver()</div><divclass="ttdoc">Main construction of the CpSolver class.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00030">CpSolver.java:30</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a1cd8aaaecd8d26aeb54f5503a459b1d9"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a1cd8aaaecd8d26aeb54f5503a459b1d9">com.google.ortools.sat.CpSolver.userTime</a></div><divclass="ttdeci">double userTime()</div><divclass="ttdoc">Returns the user time of the search.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00170">CpSolver.java:170</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_abbdeb1fbb5ae548aa2cee56005659a67"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#abbdeb1fbb5ae548aa2cee56005659a67">com.google.ortools.sat.CpSolver.setLogCallback</a></div><divclass="ttdeci">void setLogCallback(Consumer< String > cb)</div><divclass="ttdoc">Sets the log callback for the solver.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00184">CpSolver.java:184</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr_html_aa7d6a5c7e69f4efdc6a44b85bbe22f1a"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr.html#aa7d6a5c7e69f4efdc6a44b85bbe22f1a">com.google.ortools.sat.LinearExpr.getOffset</a></div><divclass="ttdeci">long getOffset()</div><divclass="ttdoc">Returns the constant part of the expression.</div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr_html_ae9592a449a7c3bdebd04b8ea4f174871"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr.html#ae9592a449a7c3bdebd04b8ea4f174871">com.google.ortools.sat.LinearExpr.getVariableIndex</a></div><divclass="ttdeci">int getVariableIndex(int index)</div><divclass="ttdoc">Returns the index of the ith variable.</div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverResponse_html_aa1ceacd082bbcb6ff0ab3569c1c7bf4e"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverResponse.html#aa1ceacd082bbcb6ff0ab3569c1c7bf4e">com.google.ortools.sat.CpSolverResponse.getNumConflicts</a></div><divclass="ttdeci">.lang.Override long getNumConflicts()</div><divclass="ttdoc">int64 num_conflicts = 11;</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolverResponse_8java_source.html#l00735">CpSolverResponse.java:735</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_aa15253dcc329f3440cc61abbfe535267"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#aa15253dcc329f3440cc61abbfe535267">com.google.ortools.sat.CpSolver.getSolutionInfo</a></div><divclass="ttdeci">String getSolutionInfo()</div><divclass="ttdoc">Returns some information on how the solution was found, or the reason why the model or the parameters...</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00197">CpSolver.java:197</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearArgument_html"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearArgument.html">com.google.ortools.sat.LinearArgument</a></div><divclass="ttdoc">A object that can build a LinearExpr object.</div><divclass="ttdef"><b>Definition:</b><ahref="LinearArgument_8java_source.html#l00021">LinearArgument.java:21</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a41cc6d27816df71c3a42837dd3d7548c"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a41cc6d27816df71c3a42837dd3d7548c">com.google.ortools.sat.CpSolver.response</a></div><divclass="ttdeci">CpSolverResponse response()</div><divclass="ttdoc">Returns the internal response protobuf that is returned internally by the SAT solver.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00150">CpSolver.java:150</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_acc4bd421bc39812d901e20823d443f36"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#acc4bd421bc39812d901e20823d443f36">com.google.ortools.sat.CpSolver.stopSearch</a></div><divclass="ttdeci">synchronized void stopSearch()</div><divclass="ttdoc">Stops the search asynchronously.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00110">CpSolver.java:110</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_ab987e56bbb2a5c4e6f224469986eead3"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#ab987e56bbb2a5c4e6f224469986eead3">com.google.ortools.sat.CpSolver.getParameters</a></div><divclass="ttdeci">SatParameters.Builder getParameters()</div><divclass="ttdoc">Returns the builder of the parameters of the SAT solver for modification.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00179">CpSolver.java:179</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a963b901c7681493ccc15bc769a397be5"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a963b901c7681493ccc15bc769a397be5">com.google.ortools.sat.CpSolver.numConflicts</a></div><divclass="ttdeci">long numConflicts()</div><divclass="ttdoc">Returns the number of conflicts created during search.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00160">CpSolver.java:160</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a3675e4eff4f3825c371d8afaa003d365"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a3675e4eff4f3825c371d8afaa003d365">com.google.ortools.sat.CpSolver.bestObjectiveBound</a></div><divclass="ttdeci">double bestObjectiveBound()</div><divclass="ttdoc">Returns the best lower bound found when minimizing, of the best upper bound found when maximizing.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00125">CpSolver.java:125</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr_html_a59f9cb76db051cd784a42f38220f896d"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr.html#a59f9cb76db051cd784a42f38220f896d">com.google.ortools.sat.LinearExpr.numElements</a></div><divclass="ttdeci">int numElements()</div><divclass="ttdoc">Returns the number of terms (excluding the constant one) in this expression.</div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_adb1b01f7ab8973fc2b7a5f279dddc185"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#adb1b01f7ab8973fc2b7a5f279dddc185">com.google.ortools.sat.CpSolver.responseStats</a></div><divclass="ttdeci">String responseStats()</div><divclass="ttdoc">Returns some statistics on the solution found as a string.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00189">CpSolver.java:189</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1Literal_html"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1Literal.html">com.google.ortools.sat.Literal</a></div><divclass="ttdoc">Interface to describe a boolean variable or its negation.</div><divclass="ttdef"><b>Definition:</b><ahref="Literal_8java_source.html#l00017">Literal.java:17</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a2f03f2f4aeddeb9c537e8b29c9e19c5e"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a2f03f2f4aeddeb9c537e8b29c9e19c5e">com.google.ortools.sat.CpSolver.solve</a></div><divclass="ttdeci">CpSolverStatus solve(CpModel model, CpSolverSolutionCallback cb)</div><divclass="ttdoc">Solves the given model, calls the solution callback at each incumbent solution, and returns the solve...</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00045">CpSolver.java:45</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearArgument_html_a68a038d4ae2f7cf74dfa8e8fe21c4feb"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearArgument.html#a68a038d4ae2f7cf74dfa8e8fe21c4feb">com.google.ortools.sat.LinearArgument.build</a></div><divclass="ttdeci">LinearExpr build()</div><divclass="ttdoc">Builds a linear expression.</div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver_html_a7ffc251fef14d87ad82ac59f98d96cf9"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolver.html#a7ffc251fef14d87ad82ac59f98d96cf9">com.google.ortools.sat.CpSolver.searchAllSolutions</a></div><divclass="ttdeci">CpSolverStatus searchAllSolutions(CpModel model, CpSolverSolutionCallback cb)</div><divclass="ttdoc">Searches for all solutions of a satisfiability problem.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolver_8java_source.html#l00093">CpSolver.java:93</a></div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverSolutionCallback_html"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverSolutionCallback.html">com.google.ortools.sat.CpSolverSolutionCallback</a></div><divclass="ttdoc">Parent class to create a callback called at each solution.</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolverSolutionCallback_8java_source.html#l00039">CpSolverSolutionCallback.java:39</a></div></div>
<divclass="ttc"id="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr_html_a2c77626134edecc47b69efe661ea1904"><divclass="ttname"><ahref="interfacecom_1_1google_1_1ortools_1_1sat_1_1LinearExpr.html#a2c77626134edecc47b69efe661ea1904">com.google.ortools.sat.LinearExpr.getCoefficient</a></div><divclass="ttdeci">long getCoefficient(int index)</div><divclass="ttdoc">Returns the ith coefficient.</div></div>
<divclass="ttc"id="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverResponse_html_af7a3d7b367b568a826252566dccb6f7c"><divclass="ttname"><ahref="classcom_1_1google_1_1ortools_1_1sat_1_1CpSolverResponse.html#af7a3d7b367b568a826252566dccb6f7c">com.google.ortools.sat.CpSolverResponse.getNumBranches</a></div><divclass="ttdeci">.lang.Override long getNumBranches()</div><divclass="ttdoc">int64 num_branches = 12;</div><divclass="ttdef"><b>Definition:</b><ahref="CpSolverResponse_8java_source.html#l00746">CpSolverResponse.java:746</a></div></div>