<ahref="time__limit_8h.html">Go to the documentation of this file.</a><divclass="fragment"><divclass="line"><aname="l00001"></a><spanclass="lineno"> 1</span> <spanclass="comment">// Copyright 2010-2018 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="preprocessor">#ifndef OR_TOOLS_UTIL_TIME_LIMIT_H_</span></div><divclass="line"><aname="l00015"></a><spanclass="lineno"> 15</span> <spanclass="preprocessor">#define OR_TOOLS_UTIL_TIME_LIMIT_H_</span></div><divclass="line"><aname="l00016"></a><spanclass="lineno"> 16</span> </div><divclass="line"><aname="l00017"></a><spanclass="lineno"> 17</span> <spanclass="preprocessor">#include <algorithm></span></div><divclass="line"><aname="l00018"></a><spanclass="lineno"> 18</span> <spanclass="preprocessor">#include <atomic></span></div><divclass="line"><aname="l00019"></a><spanclass="lineno"> 19</span> <spanclass="preprocessor">#include <cstdlib></span></div><divclass="line"><aname="l00020"></a><spanclass="lineno"> 20</span> <spanclass="preprocessor">#include <limits></span></div><divclass="line"><aname="l00021"></a><spanclass="lineno"> 21</span> <spanclass="preprocessor">#include <memory></span></div><divclass="line"><aname="l00022"></a><spanclass="lineno"> 22</span> <spanclass="preprocessor">#include <string></span></div><divclass="line"><aname="l00023"></a><spanclass="lineno"> 23</span> </div><divclass="line"><aname="l00024"></a><spanclass="lineno"> 24</span> <spanclass="preprocessor">#include "absl/container/flat_hash_map.h"</span></div><divclass="line"><aname="l00025"></a><spanclass="lineno"> 25</span> <spanclass="preprocessor">#include "absl/memory/memory.h"</span></div><divclass="line"><aname="l00026"></a><spanclass="lineno"> 26</span> <spanclass="preprocessor">#include "absl/time/clock.h"</span></div><divclass="line"><aname="l00027"></a><spanclass="lineno"> 27</span> <spanclass="preprocessor">#include "ortools/base/commandlineflags.h"
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a4cb3517d59bf4642a85294267736af20"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a4cb3517d59bf4642a85294267736af20">operations_research::TimeLimit::ReadInstructionCounter</a></div><divclass="ttdeci">double ReadInstructionCounter()</div><divclass="ttdoc">Returns the number of instructions executed since the creation of this object.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00469">time_limit.h:469</a></div></div>
<divclass="ttc"id="classoperations__research_1_1NestedTimeLimit_html_af23d2dc1b291081b642a728cf0033987"><divclass="ttname"><ahref="classoperations__research_1_1NestedTimeLimit.html#af23d2dc1b291081b642a728cf0033987">operations_research::NestedTimeLimit::NestedTimeLimit</a></div><divclass="ttdeci">NestedTimeLimit(TimeLimit *base_time_limit, double limit_in_seconds, double deterministic_limit)</div><divclass="ttdoc">Creates the nested time limit.</div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_ac7e861414a70fc937d18bc7ca743fc98"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#ac7e861414a70fc937d18bc7ca743fc98">operations_research::TimeLimit::GetElapsedDeterministicTime</a></div><divclass="ttdeci">double GetElapsedDeterministicTime() const</div><divclass="ttdoc">Returns the elapsed deterministic time since the construction of this object.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00260">time_limit.h:260</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a0be73bea3d751ca2926c1cd616abb31e"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a0be73bea3d751ca2926c1cd616abb31e">operations_research::TimeLimit::GetInstructionsLeft</a></div><divclass="ttdeci">double GetInstructionsLeft()</div><divclass="ttdoc">Returns the number of instructions left to reach the limit.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00528">time_limit.h:528</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a810d5f7aaf80cc09cf5a094e20c1aaca"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a810d5f7aaf80cc09cf5a094e20c1aaca">operations_research::TimeLimit::LimitReached</a></div><divclass="ttdeci">bool LimitReached()</div><divclass="ttdoc">Returns true when the external limit is true, or the deterministic time is over the deterministic lim...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00479">time_limit.h:479</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a517ffd071860d7efd76134e25f6f03e1"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a517ffd071860d7efd76134e25f6f03e1">operations_research::TimeLimit::Infinite</a></div><divclass="ttdeci">static std::unique_ptr< TimeLimit > Infinite()</div><divclass="ttdoc">Creates a time limit object that uses infinite time for wall time, deterministic time and instruction...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00134">time_limit.h:134</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_ae3fe2e2b613455b49c6cc74dd3c7581e"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#ae3fe2e2b613455b49c6cc74dd3c7581e">operations_research::TimeLimit::GetElapsedTime</a></div><divclass="ttdeci">double GetElapsedTime() const</div><divclass="ttdoc">Returns the time elapsed in seconds since the construction of this object.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00251">time_limit.h:251</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a96f95e438ca7940b115c838c96c06d87"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a96f95e438ca7940b115c838c96c06d87">operations_research::TimeLimit::FromParameters</a></div><divclass="ttdeci">static std::unique_ptr< TimeLimit > FromParameters(const Parameters &parameters)</div><divclass="ttdoc">Creates a time limit object initialized from an object that provides methods max_time_in_seconds() an...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00159">time_limit.h:159</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a4273b83b06bfbf856393db6d0a9b8715"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a4273b83b06bfbf856393db6d0a9b8715">operations_research::TimeLimit::GetTimeLeft</a></div><divclass="ttdeci">double GetTimeLeft() const</div><divclass="ttdoc">Returns the time left on this limit, or 0 if the limit was reached (it never returns a negative value...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00517">time_limit.h:517</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a640ae7a07a6de8fe45a5526326f3b028"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a640ae7a07a6de8fe45a5526326f3b028">operations_research::TimeLimit::FromDeterministicTime</a></div><divclass="ttdeci">static std::unique_ptr< TimeLimit > FromDeterministicTime(double deterministic_limit)</div><divclass="ttdoc">Creates a time limit object that puts limit only on the deterministic time.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00144">time_limit.h:144</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_ad068edb54c705c548c20e4ba47b4e3a8"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#ad068edb54c705c548c20e4ba47b4e3a8">operations_research::TimeLimit::AdvanceDeterministicTime</a></div><divclass="ttdeci">void AdvanceDeterministicTime(double deterministic_duration, const char *counter_name)</div><divclass="ttdoc">Advances the deterministic time.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00240">time_limit.h:240</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a30ac580cb264bf8e92696890f212727e"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a30ac580cb264bf8e92696890f212727e">operations_research::TimeLimit::ExternalBooleanAsLimit</a></div><divclass="ttdeci">std::atomic< bool > * ExternalBooleanAsLimit() const</div><divclass="ttdoc">Returns the current external Boolean limit.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00282">time_limit.h:282</a></div></div>
<divclass="ttc"id="classoperations__research_1_1NestedTimeLimit_html_a7e35d44d642ce651a7b5c7264ed6cc9c"><divclass="ttname"><ahref="classoperations__research_1_1NestedTimeLimit.html#a7e35d44d642ce651a7b5c7264ed6cc9c">operations_research::NestedTimeLimit::GetTimeLimit</a></div><divclass="ttdeci">TimeLimit * GetTimeLimit()</div><divclass="ttdoc">Returns a time limit object that represents the combination of the overall time limit and the part-sp...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00404">time_limit.h:404</a></div></div>
<divclass="ttc"id="time__limit_8h_html_a05c25f55df53c30b07aa2585a8424921"><divclass="ttname"><ahref="time__limit_8h.html#a05c25f55df53c30b07aa2585a8424921">DECLARE_bool</a></div><divclass="ttdeci">DECLARE_bool(time_limit_use_usertime)</div><divclass="ttdoc">Enables changing the behavior of the TimeLimit class to use -b usertime instead of walltime.</div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a9d28f062361ac553f8bc1da250b205bd"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a9d28f062361ac553f8bc1da250b205bd">operations_research::TimeLimit::operator=</a></div><divclass="ttdeci">TimeLimit & operator=(const TimeLimit &)=delete</div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a43229b9a540c5b4c3751ebb13e73ace8"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a43229b9a540c5b4c3751ebb13e73ace8">operations_research::TimeLimit::SetInstructionLimit</a></div><divclass="ttdeci">void SetInstructionLimit(double instruction_limit)</div><divclass="ttdoc">Sets the instruction limit.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00171">time_limit.h:171</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html">operations_research::TimeLimit</a></div><divclass="ttdoc">A simple class to enforce both an elapsed time limit and a deterministic time limit in the same threa...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00105">time_limit.h:105</a></div></div>
<divclass="ttc"id="classoperations__research_1_1NestedTimeLimit_html"><divclass="ttname"><ahref="classoperations__research_1_1NestedTimeLimit.html">operations_research::NestedTimeLimit</a></div><divclass="ttdoc">Provides a way to nest time limits for algorithms where a certain part of the computation is bounded ...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00369">time_limit.h:369</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a312550ebabce586fb77c49e813c610f8"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a312550ebabce586fb77c49e813c610f8">operations_research::TimeLimit::ResetLimitFromParameters</a></div><divclass="ttdeci">void ResetLimitFromParameters(const Parameters &parameters)</div><divclass="ttdoc">Sets new time limits.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00452">time_limit.h:452</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_ac62fbbc5383a86a9fe334e3213f6244b"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#ac62fbbc5383a86a9fe334e3213f6244b">operations_research::TimeLimit::kHistorySize</a></div><divclass="ttdeci">static const int kHistorySize</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00108">time_limit.h:108</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a764be64f3029f8b8e23511061d8de355"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a764be64f3029f8b8e23511061d8de355">operations_research::TimeLimit::DebugString</a></div><divclass="ttdeci">std::string DebugString() const</div><divclass="ttdoc">Returns information about the time limit object in a human-readable form.</div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_af90cfd1fc238433fc303ee28c5914eb9"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#af90cfd1fc238433fc303ee28c5914eb9">operations_research::TimeLimit::AdvanceDeterministicTime</a></div><divclass="ttdeci">void AdvanceDeterministicTime(double deterministic_duration)</div><divclass="ttdoc">Advances the deterministic time.</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00226">time_limit.h:226</a></div></div>
<divclass="ttc"id="classoperations__research_1_1NestedTimeLimit_html_a3b7596f291aadf69b593164aca3505ef"><divclass="ttname"><ahref="classoperations__research_1_1NestedTimeLimit.html#a3b7596f291aadf69b593164aca3505ef">operations_research::NestedTimeLimit::FromBaseTimeLimitAndParameters</a></div><divclass="ttdeci">static std::unique_ptr< NestedTimeLimit > FromBaseTimeLimitAndParameters(TimeLimit *time_limit, const Parameters &parameters)</div><divclass="ttdoc">Creates a time limit object initialized from a base time limit and an object that provides methods ma...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00391">time_limit.h:391</a></div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a362a88bfe50d83c028154a62ef53e780"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a362a88bfe50d83c028154a62ef53e780">operations_research::TimeLimit::GetDeterministicTimeLeft</a></div><divclass="ttdeci">double GetDeterministicTimeLeft() const</div><divclass="ttdoc">Returns the remaining deterministic time before LimitReached() returns true due to the deterministic ...</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00212">time_limit.h:212</a></div></div>
<divclass="ttc"id="classoperations__research_1_1NestedTimeLimit_html_acc74615391497a1874ffb69d751f80af"><divclass="ttname"><ahref="classoperations__research_1_1NestedTimeLimit.html#acc74615391497a1874ffb69d751f80af">operations_research::NestedTimeLimit::~NestedTimeLimit</a></div><divclass="ttdeci">~NestedTimeLimit()</div><divclass="ttdoc">Updates elapsed deterministic time in the base time limit object.</div></div>
<divclass="ttc"id="classoperations__research_1_1TimeLimit_html_a4c1bbdcb2a449b42a788178d2c3d2477"><divclass="ttname"><ahref="classoperations__research_1_1TimeLimit.html#a4c1bbdcb2a449b42a788178d2c3d2477">operations_research::TimeLimit::ParallelTimeLimit</a></div><divclass="ttdeci">friend class ParallelTimeLimit</div><divclass="ttdef"><b>Definition:</b><ahref="time__limit_8h_source.html#l00336">time_limit.h:336</a></div></div>