<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/> <title>CVC3: xchaff_dbase.cpp Source File</title> <link href="tabs.css" rel="stylesheet" type="text/css"/> <link href="doxygen.css" rel="stylesheet" type="text/css"/> </head> <body> <!-- Generated by Doxygen 1.7.4 --> <div id="top"> <div id="titlearea"> <table cellspacing="0" cellpadding="0"> <tbody> <tr style="height: 56px;"> <td style="padding-left: 0.5em;"> <div id="projectname">CVC3 <span id="projectnumber">2.4.1</span></div> </td> </tr> </tbody> </table> </div> <div id="navrow1" class="tabs"> <ul class="tablist"> <li><a href="index.html"><span>Main Page</span></a></li> <li><a href="pages.html"><span>Related Pages</span></a></li> <li><a href="modules.html"><span>Modules</span></a></li> <li><a href="namespaces.html"><span>Namespaces</span></a></li> <li><a href="annotated.html"><span>Classes</span></a></li> <li class="current"><a href="files.html"><span>Files</span></a></li> </ul> </div> <div id="navrow2" class="tabs2"> <ul class="tablist"> <li><a href="files.html"><span>File List</span></a></li> <li><a href="globals.html"><span>File Members</span></a></li> </ul> </div> <div class="header"> <div class="headertitle"> <div class="title">xchaff_dbase.cpp</div> </div> </div> <div class="contents"> <a href="xchaff__dbase_8cpp.html">Go to the documentation of this file.</a><div class="fragment"><pre class="fragment"><a name="l00001"></a>00001 <span class="comment">/* =========FOR INTERNAL USE ONLY. NO DISTRIBUTION PLEASE ========== */</span> <a name="l00002"></a>00002 <a name="l00003"></a>00003 <span class="comment">/*********************************************************************</span> <a name="l00004"></a>00004 <span class="comment"> Copyright 2000-2001, Princeton University. All rights reserved.</span> <a name="l00005"></a>00005 <span class="comment"> By using this software the USER indicates that he or she has read,</span> <a name="l00006"></a>00006 <span class="comment"> understood and will comply with the following:</span> <a name="l00007"></a>00007 <span class="comment"></span> <a name="l00008"></a>00008 <span class="comment"> --- Princeton University hereby grants USER nonexclusive permission</span> <a name="l00009"></a>00009 <span class="comment"> to use, copy and/or modify this software for internal, noncommercial,</span> <a name="l00010"></a>00010 <span class="comment"> research purposes only. Any distribution, including commercial sale</span> <a name="l00011"></a>00011 <span class="comment"> or license, of this software, copies of the software, its associated</span> <a name="l00012"></a>00012 <span class="comment"> documentation and/or modifications of either is strictly prohibited</span> <a name="l00013"></a>00013 <span class="comment"> without the prior consent of Princeton University. Title to copyright</span> <a name="l00014"></a>00014 <span class="comment"> to this software and its associated documentation shall at all times</span> <a name="l00015"></a>00015 <span class="comment"> remain with Princeton University. Appropriate copyright notice shall</span> <a name="l00016"></a>00016 <span class="comment"> be placed on all software copies, and a complete copy of this notice</span> <a name="l00017"></a>00017 <span class="comment"> shall be included in all copies of the associated documentation.</span> <a name="l00018"></a>00018 <span class="comment"> No right is granted to use in advertising, publicity or otherwise</span> <a name="l00019"></a>00019 <span class="comment"> any trademark, service mark, or the name of Princeton University.</span> <a name="l00020"></a>00020 <span class="comment"></span> <a name="l00021"></a>00021 <span class="comment"></span> <a name="l00022"></a>00022 <span class="comment"> --- This software and any associated documentation is provided "as is"</span> <a name="l00023"></a>00023 <span class="comment"></span> <a name="l00024"></a>00024 <span class="comment"> PRINCETON UNIVERSITY MAKES NO REPRESENTATIONS OR WARRANTIES, EXPRESS</span> <a name="l00025"></a>00025 <span class="comment"> OR IMPLIED, INCLUDING THOSE OF MERCHANTABILITY OR FITNESS FOR A</span> <a name="l00026"></a>00026 <span class="comment"> PARTICULAR PURPOSE, OR THAT USE OF THE SOFTWARE, MODIFICATIONS, OR</span> <a name="l00027"></a>00027 <span class="comment"> ASSOCIATED DOCUMENTATION WILL NOT INFRINGE ANY PATENTS, COPYRIGHTS,</span> <a name="l00028"></a>00028 <span class="comment"> TRADEMARKS OR OTHER INTELLECTUAL PROPERTY RIGHTS OF A THIRD PARTY.</span> <a name="l00029"></a>00029 <span class="comment"></span> <a name="l00030"></a>00030 <span class="comment"> Princeton University shall not be liable under any circumstances for</span> <a name="l00031"></a>00031 <span class="comment"> any direct, indirect, special, incidental, or consequential damages</span> <a name="l00032"></a>00032 <span class="comment"> with respect to any claim by USER or any third party on account of</span> <a name="l00033"></a>00033 <span class="comment"> or arising from the use, or inability to use, this software or its</span> <a name="l00034"></a>00034 <span class="comment"> associated documentation, even if Princeton University has been advised</span> <a name="l00035"></a>00035 <span class="comment"> of the possibility of those damages.</span> <a name="l00036"></a>00036 <span class="comment">*********************************************************************/</span> <a name="l00037"></a>00037 <a name="l00038"></a>00038 <span class="preprocessor">#include "<a class="code" href="xchaff__utils_8h.html">xchaff_utils.h</a>"</span> <a name="l00039"></a>00039 <span class="preprocessor">#include "<a class="code" href="xchaff__dbase_8h.html">xchaff_dbase.h</a>"</span> <a name="l00040"></a>00040 <a name="l00041"></a><a class="code" href="classCDatabase.html#a3959a40851f6fcb985542d1d43ff75dc">00041</a> <a class="code" href="classCDatabase.html#a3959a40851f6fcb985542d1d43ff75dc">CDatabase::CDatabase</a>() : _variables(1) <a name="l00042"></a>00042 { <a name="l00043"></a>00043 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#a5bb3efabbedc5d63b78084c42b705846">mem_used_up_counts</a> = 0; <a name="l00044"></a>00044 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#ab317cc5ad2da6a68cdec37e71fd80f4f">mem_used_up</a> = <span class="keyword">false</span>; <a name="l00045"></a>00045 <a name="l00046"></a>00046 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#a7dcec2874be271fdfcf7c7f735a65f89">init_num_clauses</a> = 0; <a name="l00047"></a>00047 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#a0823584d04f40c7a47e0b54fe3ccec71">init_num_literals</a> = 0; <a name="l00048"></a>00048 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#a2350a97ea7c7333870732c83772fb1f9">num_added_clauses</a> = 0; <a name="l00049"></a>00049 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#ad7baf06bf924ed8d6d9b9f73d734ef74">num_added_literals</a> = 0; <a name="l00050"></a>00050 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#a04f908144a2e96ebcec3432be9d811e4">num_deleted_clauses</a> = 0; <a name="l00051"></a>00051 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#ae312d9b4f60acc3df8292394d8bac743">num_deleted_literals</a> = 0; <a name="l00052"></a>00052 <a name="l00053"></a>00053 <a class="code" href="classCDatabase.html#a9a30273cdd0b1f4814f470950cd90a77">_lit_pool_start</a> = <span class="keyword">new</span> <a class="code" href="classCLitPoolElement.html">CLitPoolElement</a>[<a class="code" href="xchaff__dbase_8h.html#a093b08011b38f7046d26007d652f0d84">STARTUP_LIT_POOL_SIZE</a>]; <a name="l00054"></a>00054 <a class="code" href="classCDatabase.html#a970c8066adfcb3875af1f78f1c4029ff">_lit_pool_finish</a> = <a class="code" href="classCDatabase.html#a9a30273cdd0b1f4814f470950cd90a77">_lit_pool_start</a>; <a name="l00055"></a>00055 <a class="code" href="classCDatabase.html#a3a4e4403ef1f9cb15c219bfe52b1d935">_lit_pool_end_storage</a> = <a class="code" href="classCDatabase.html#a9a30273cdd0b1f4814f470950cd90a77">_lit_pool_start</a> + <a class="code" href="xchaff__dbase_8h.html#a093b08011b38f7046d26007d652f0d84">STARTUP_LIT_POOL_SIZE</a>; <a name="l00056"></a>00056 <a class="code" href="classCDatabase.html#a7fa3358fa63aa02cae8055c0dfe832b7">lit_pool_push_back</a>(0); <span class="comment">//set the first element as a spacing element</span> <a name="l00057"></a>00057 <a name="l00058"></a>00058 <a class="code" href="classCDatabase.html#a5f8cf11f16f22e1ffd47a8d0146a584f">_mem_limit</a> = 1024*1024*512; <span class="comment">//that's 0.5 G</span> <a name="l00059"></a>00059 } <a name="l00060"></a>00060 <a name="l00061"></a>00061 <a name="l00062"></a><a class="code" href="classCDatabase.html#a81a2e3d63658a6aa21bda0b8660ee15f">00062</a> <span class="keywordtype">void</span> <a class="code" href="classCDatabase.html#a81a2e3d63658a6aa21bda0b8660ee15f">CDatabase::compact_lit_pool</a>(<span class="keywordtype">void</span>) <a name="l00063"></a>00063 { <a name="l00064"></a>00064 <a class="code" href="xchaff__utils_8h.html#a763ffd798508592c5092ac77daa5a659">CHECK</a>(cout << <span class="stringliteral">"Begin Compaction "</span> << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>;); <a name="l00065"></a>00065 <span class="keywordtype">int</span> new_index = 1; <a name="l00066"></a>00066 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=1; i< <a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>(); ++i){ <span class="comment">//begin with 1 because 0 position is always 0</span> <a name="l00067"></a>00067 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#a253daa80c6f47528feb0b69e1a5c4623">val</a>()<=0 && <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i-1).<a class="code" href="classCLitPoolElement.html#a253daa80c6f47528feb0b69e1a5c4623">val</a>()<=0) <a name="l00068"></a>00068 <span class="keywordflow">continue</span>; <a name="l00069"></a>00069 <span class="keywordflow">else</span> { <a name="l00070"></a>00070 <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(new_index) = <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i); <a name="l00071"></a>00071 ++new_index; <a name="l00072"></a>00072 } <a name="l00073"></a>00073 } <a name="l00074"></a>00074 <a class="code" href="classCDatabase.html#a970c8066adfcb3875af1f78f1c4029ff">_lit_pool_finish</a> = <a class="code" href="classCDatabase.html#a2e6aeb6e495ae18667311b79982a5e6d">lit_pool_begin</a>() + new_index; <a name="l00075"></a>00075 <span class="comment">//update all the pointers of the clauses;</span> <a name="l00076"></a>00076 <span class="comment">//1. clean up the pt pointers from variables</span> <a name="l00077"></a>00077 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=1; i<<a class="code" href="classCDatabase.html#af4388cf12d2984898332c519b220d67b">variables</a>().size(); ++i) { <a name="l00078"></a>00078 <a class="code" href="classCDatabase.html#af421024d0ade14743332069684aba162">variable</a>(i).<a class="code" href="classCVariable.html#aef0698f402345545601284fa7682e6f5">ht_ptr</a>(0).clear(); <a name="l00079"></a>00079 <a class="code" href="classCDatabase.html#af421024d0ade14743332069684aba162">variable</a>(i).<a class="code" href="classCVariable.html#aef0698f402345545601284fa7682e6f5">ht_ptr</a>(1).clear(); <a name="l00080"></a>00080 } <a name="l00081"></a>00081 <span class="comment">//2. reinsert the ht_pointers</span> <a name="l00082"></a>00082 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=1; i< <a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>(); ++i) { <a name="l00083"></a>00083 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#a253daa80c6f47528feb0b69e1a5c4623">val</a>() > 0 && <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#aeaa93c7cfdbbe94aed9b9b6f07458a00">is_ht</a>()) { <a name="l00084"></a>00084 <span class="keywordtype">int</span> var_idx = <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#a98d4a07830b749d83c74943efdf9669b">var_index</a>(); <a name="l00085"></a>00085 <span class="keywordtype">int</span> sign = <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#add6c6301567da71e72923b3c372081cd">var_sign</a>(); <a name="l00086"></a>00086 <a class="code" href="classCDatabase.html#af421024d0ade14743332069684aba162">variable</a>(var_idx).<a class="code" href="classCVariable.html#aef0698f402345545601284fa7682e6f5">ht_ptr</a>(sign).push_back(& <a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i)); <a name="l00087"></a>00087 } <a name="l00088"></a>00088 } <a name="l00089"></a>00089 <span class="comment">//3. update the clauses' first literal pointer</span> <a name="l00090"></a>00090 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> i=1; i< <a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>(); ++i) { <a name="l00091"></a>00091 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#a253daa80c6f47528feb0b69e1a5c4623">val</a>() <= 0) { <a name="l00092"></a>00092 <span class="keywordtype">int</span> cls_idx = -<a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i).<a class="code" href="classCLitPoolElement.html#a253daa80c6f47528feb0b69e1a5c4623">val</a>(); <a name="l00093"></a>00093 <a class="code" href="classCDatabase.html#a5af3586dfcd579ab14d37c6b6cf75e18">clause</a>(cls_idx).<a class="code" href="classCClause.html#a08b669c2f239c65df9cae46603cab85f">first_lit</a>() = &<a class="code" href="classCDatabase.html#a338b044147d1e34dfbed7cc8663725ae">lit_pool</a>(i) - <a class="code" href="classCDatabase.html#a5af3586dfcd579ab14d37c6b6cf75e18">clause</a>(cls_idx).<a class="code" href="classCClause.html#ae4f9f5a951b75aab530b5b05a3232082">num_lits</a>(); <a name="l00094"></a>00094 } <a name="l00095"></a>00095 } <a name="l00096"></a>00096 <a class="code" href="xchaff__utils_8h.html#a763ffd798508592c5092ac77daa5a659">CHECK</a>(<a class="code" href="classCDatabase.html#a0a1c2417b7ef79f11d50add3d49625f7">output_lit_pool_state</a>(); <a name="l00097"></a>00097 cout << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a> << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>;); <a name="l00098"></a>00098 } <a name="l00099"></a>00099 <a name="l00100"></a><a class="code" href="classCDatabase.html#ae121408a92221766e9139e7cf40ab7de">00100</a> <span class="keywordtype">bool</span> <a class="code" href="classCDatabase.html#ae121408a92221766e9139e7cf40ab7de">CDatabase::enlarge_lit_pool</a>(<span class="keywordtype">void</span>) <span class="comment">//will return true if successful, otherwise false.</span> <a name="l00101"></a>00101 { <a name="l00102"></a>00102 <a class="code" href="xchaff__utils_8h.html#a763ffd798508592c5092ac77daa5a659">CHECK</a> (<a class="code" href="classCDatabase.html#a0a1c2417b7ef79f11d50add3d49625f7">output_lit_pool_state</a>()); <a name="l00103"></a>00103 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>() - <a class="code" href="classCDatabase.html#a1ea198396d083b323c22cd49cc2be36c">num_clauses</a>() > <a class="code" href="classCDatabase.html#a93f69dacd75d1cf2d4a006b961f3b7b6">num_literals</a>() * 2) { <a name="l00104"></a>00104 <span class="comment">//memory fragmented. ratio of efficiency < 0.5</span> <a name="l00105"></a>00105 <span class="comment">//minus num_clauses() is because of spacing for</span> <a name="l00106"></a>00106 <span class="comment">//each clause in lit_pool</span> <a name="l00107"></a>00107 <a class="code" href="classCDatabase.html#a81a2e3d63658a6aa21bda0b8660ee15f">compact_lit_pool</a>(); <a name="l00108"></a>00108 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00109"></a>00109 } <a name="l00110"></a>00110 <a class="code" href="xchaff__utils_8h.html#a763ffd798508592c5092ac77daa5a659">CHECK</a>(cout << <span class="stringliteral">"Begin Enlarge Lit Pool"</span> << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>;); <a name="l00111"></a>00111 <a name="l00112"></a>00112 <span class="comment">//otherwise we have to enlarge it.</span> <a name="l00113"></a>00113 <span class="comment">//first, check if memory is running out</span> <a name="l00114"></a>00114 <span class="keywordtype">int</span> current_mem = <a class="code" href="classCDatabase.html#a358ccda3851e0469ef0f2a6f3cf55726">estimate_mem_usage</a>(); <a name="l00115"></a>00115 <span class="keywordtype">float</span> grow_ratio; <a name="l00116"></a>00116 <span class="keywordflow">if</span> (current_mem < <a class="code" href="classCDatabase.html#a5f8cf11f16f22e1ffd47a8d0146a584f">_mem_limit</a> /2 ) { <a name="l00117"></a>00117 grow_ratio = 2; <a name="l00118"></a>00118 } <a name="l00119"></a>00119 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (current_mem < <a class="code" href="classCDatabase.html#a5f8cf11f16f22e1ffd47a8d0146a584f">_mem_limit</a> * 0.8) { <a name="l00120"></a>00120 grow_ratio = 1.2; <a name="l00121"></a>00121 } <a name="l00122"></a>00122 <span class="keywordflow">else</span> { <a name="l00123"></a>00123 <a class="code" href="classCDatabase.html#abb17b94a5d63adc740acbe28adb537dd">_stats</a>.<a class="code" href="structCDatabaseStats.html#ab317cc5ad2da6a68cdec37e71fd80f4f">mem_used_up</a> = <span class="keyword">true</span>; <a name="l00124"></a>00124 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>() - <a class="code" href="classCDatabase.html#a1ea198396d083b323c22cd49cc2be36c">num_clauses</a>() > <a class="code" href="classCDatabase.html#a93f69dacd75d1cf2d4a006b961f3b7b6">num_literals</a>() * 1.1) { <a name="l00125"></a>00125 <a class="code" href="classCDatabase.html#a81a2e3d63658a6aa21bda0b8660ee15f">compact_lit_pool</a>(); <a name="l00126"></a>00126 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00127"></a>00127 } <a name="l00128"></a>00128 <span class="keywordflow">else</span> <a name="l00129"></a>00129 <span class="keywordflow">return</span> <span class="keyword">false</span>; <a name="l00130"></a>00130 } <a name="l00131"></a>00131 <span class="comment">//second, make room for new lit pool.</span> <a name="l00132"></a>00132 <a class="code" href="classCLitPoolElement.html">CLitPoolElement</a> * old_start = <a class="code" href="classCDatabase.html#a9a30273cdd0b1f4814f470950cd90a77">_lit_pool_start</a>; <a name="l00133"></a>00133 <a class="code" href="classCLitPoolElement.html">CLitPoolElement</a> * old_finish = <a class="code" href="classCDatabase.html#a970c8066adfcb3875af1f78f1c4029ff">_lit_pool_finish</a>; <a name="l00134"></a>00134 <span class="keywordtype">int</span> old_size = <a class="code" href="classCDatabase.html#a3a4e4403ef1f9cb15c219bfe52b1d935">_lit_pool_end_storage</a> - <a class="code" href="classCDatabase.html#a9a30273cdd0b1f4814f470950cd90a77">_lit_pool_start</a>; <a name="l00135"></a>00135 <span class="keywordtype">int</span> new_size = (int)(old_size * grow_ratio); <a name="l00136"></a>00136 _lit_pool_start = <span class="keyword">new</span> <a class="code" href="classCLitPoolElement.html">CLitPoolElement</a>[new_size]; <a name="l00137"></a>00137 <a class="code" href="classCDatabase.html#a970c8066adfcb3875af1f78f1c4029ff">_lit_pool_finish</a> = <a class="code" href="classCDatabase.html#a9a30273cdd0b1f4814f470950cd90a77">_lit_pool_start</a>; <a name="l00138"></a>00138 <a class="code" href="classCDatabase.html#a3a4e4403ef1f9cb15c219bfe52b1d935">_lit_pool_end_storage</a> = _lit_pool_start + new_size; <a name="l00139"></a>00139 <span class="comment">//copy the old content into new place</span> <a name="l00140"></a>00140 <span class="keywordflow">for</span> (<a class="code" href="classCLitPoolElement.html">CLitPoolElement</a> * ptr = old_start; ptr != old_finish; ++ptr) { <a name="l00141"></a>00141 *<a class="code" href="classCDatabase.html#a970c8066adfcb3875af1f78f1c4029ff">_lit_pool_finish</a> = *ptr; <a name="l00142"></a>00142 <a class="code" href="classCDatabase.html#a970c8066adfcb3875af1f78f1c4029ff">_lit_pool_finish</a> ++; <a name="l00143"></a>00143 } <a name="l00144"></a>00144 <span class="comment">//update all the pointers</span> <a name="l00145"></a>00145 <span class="keywordtype">long</span> displacement = _lit_pool_start - old_start; <a name="l00146"></a>00146 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i< <a class="code" href="classCDatabase.html#a0c2329a20ee0a2672475933c3edd888e">clauses</a>().size(); ++i) <a name="l00147"></a>00147 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#a5af3586dfcd579ab14d37c6b6cf75e18">clause</a>(i).<a class="code" href="classCClause.html#accc3ecb433cd7ba00affc3180b0911d4">in_use</a>()) <a name="l00148"></a>00148 <a class="code" href="classCDatabase.html#a5af3586dfcd579ab14d37c6b6cf75e18">clause</a>(i).<a class="code" href="classCClause.html#a08b669c2f239c65df9cae46603cab85f">first_lit</a>() += displacement; <a name="l00149"></a>00149 <a name="l00150"></a>00150 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> i=0; i< <a class="code" href="classCDatabase.html#af4388cf12d2984898332c519b220d67b">variables</a>().size(); ++i) { <a name="l00151"></a>00151 <a class="code" href="classCVariable.html">CVariable</a> & v = <a class="code" href="classCDatabase.html#af421024d0ade14743332069684aba162">variable</a>(i); <a name="l00152"></a>00152 <span class="keywordflow">for</span> (<span class="keywordtype">int</span> j=0; j< 2 ; ++j) { <a name="l00153"></a>00153 vector<CLitPoolElement *> & ht_ptr = v.<a class="code" href="classCVariable.html#aef0698f402345545601284fa7682e6f5">ht_ptr</a>(j); <a name="l00154"></a>00154 <span class="keywordflow">for</span> (<span class="keywordtype">unsigned</span> k=0; k< ht_ptr.size(); ++k) { <a name="l00155"></a>00155 ht_ptr[k] += displacement; <a name="l00156"></a>00156 } <a name="l00157"></a>00157 } <a name="l00158"></a>00158 } <a name="l00159"></a>00159 <span class="comment">//free old space</span> <a name="l00160"></a>00160 <span class="keyword">delete</span> [] old_start; <a name="l00161"></a>00161 <a class="code" href="xchaff__utils_8h.html#a763ffd798508592c5092ac77daa5a659">CHECK</a>(<a class="code" href="classCDatabase.html#a0a1c2417b7ef79f11d50add3d49625f7">output_lit_pool_state</a>()); <a name="l00162"></a>00162 <a class="code" href="xchaff__utils_8h.html#a763ffd798508592c5092ac77daa5a659">CHECK</a>(cout << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a> << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>); <a name="l00163"></a>00163 <span class="keywordflow">return</span> <span class="keyword">true</span>; <a name="l00164"></a>00164 } <a name="l00165"></a>00165 <a name="l00166"></a>00166 <a name="l00167"></a><a class="code" href="classCDatabase.html#a0a1c2417b7ef79f11d50add3d49625f7">00167</a> <span class="keywordtype">void</span> <a class="code" href="classCDatabase.html#a0a1c2417b7ef79f11d50add3d49625f7">CDatabase::output_lit_pool_state</a> (<span class="keywordtype">void</span>) <a name="l00168"></a>00168 { <a name="l00169"></a>00169 cout << <span class="stringliteral">"Lit_Pool Used "</span> << <a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>() << <span class="stringliteral">" Free "</span> << <a class="code" href="classCDatabase.html#ac66c5172be66fa260f8f6d5fd41ca295">lit_pool_free_space</a>() <a name="l00170"></a>00170 << <span class="stringliteral">" Total "</span> << <a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>() + <a class="code" href="classCDatabase.html#ac66c5172be66fa260f8f6d5fd41ca295">lit_pool_free_space</a>() <a name="l00171"></a>00171 << <span class="stringliteral">" Num. Cl "</span> << <a class="code" href="classCDatabase.html#a1ea198396d083b323c22cd49cc2be36c">num_clauses</a>() << <span class="stringliteral">" Num. Lit "</span> << <a class="code" href="classCDatabase.html#a93f69dacd75d1cf2d4a006b961f3b7b6">num_literals</a>(); <a name="l00172"></a>00172 cout << <span class="stringliteral">" Efficiency "</span> << (float)((<span class="keywordtype">float</span>)<a class="code" href="classCDatabase.html#a93f69dacd75d1cf2d4a006b961f3b7b6">num_literals</a>()) / (<span class="keywordtype">float</span>)((<a class="code" href="classCDatabase.html#ab6e49a71237bf7a6f060f79675bb39e7">lit_pool_size</a>() - <a class="code" href="classCDatabase.html#a1ea198396d083b323c22cd49cc2be36c">num_clauses</a>())) << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00173"></a>00173 } <a name="l00174"></a>00174 <a name="l00175"></a>00175 <a name="l00176"></a><a class="code" href="classCDatabase.html#a074d5b5a1fa285b8ae0e3c516a06a508">00176</a> <span class="keywordtype">void</span> <a class="code" href="classCDatabase.html#a074d5b5a1fa285b8ae0e3c516a06a508">CDatabase::detail_dump_cl</a>(<a class="code" href="xchaff__base_8h.html#a10b9683e115e9c10c0874794507db545">ClauseIdx</a> cl_idx, ostream & os) { <a name="l00177"></a>00177 os << <span class="stringliteral">"Clause : "</span> << cl_idx; <a name="l00178"></a>00178 <a class="code" href="classCClause.html">CClause</a> & cl = <a class="code" href="classCDatabase.html#a5af3586dfcd579ab14d37c6b6cf75e18">clause</a>(cl_idx); <a name="l00179"></a>00179 <span class="keywordflow">if</span> (!cl.<a class="code" href="classCClause.html#accc3ecb433cd7ba00affc3180b0911d4">in_use</a>()) <a name="l00180"></a>00180 os << <span class="stringliteral">"\t\t\t======removed====="</span>; <a name="l00181"></a>00181 <span class="keyword">const</span> <span class="keywordtype">char</span> * value; <a name="l00182"></a>00182 <span class="keywordtype">int</span> i, sz; <a name="l00183"></a>00183 sz = cl.<a class="code" href="classCClause.html#ae4f9f5a951b75aab530b5b05a3232082">num_lits</a>(); <a name="l00184"></a>00184 <span class="keywordflow">if</span> (cl.<a class="code" href="classCClause.html#ae4f9f5a951b75aab530b5b05a3232082">num_lits</a>() < 0) { <a name="l00185"></a>00185 os << <span class="stringliteral">">> "</span> ; <a name="l00186"></a>00186 sz = -sz; <a name="l00187"></a>00187 } <a name="l00188"></a>00188 <span class="keywordflow">for</span> (i=0; i<sz; ++i) { <a name="l00189"></a>00189 <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#ab0c8f1826cf8c92fc01943ab62d223df">literal_value</a>(cl.<a class="code" href="classCClause.html#a8254175660df4f73f485f9227becaf14">literals</a>()[i])==0) value = <span class="stringliteral">"0"</span>; <a name="l00190"></a>00190 <span class="keywordflow">else</span> <span class="keywordflow">if</span> (<a class="code" href="classCDatabase.html#ab0c8f1826cf8c92fc01943ab62d223df">literal_value</a>(cl.<a class="code" href="classCClause.html#a8254175660df4f73f485f9227becaf14">literals</a>()[i])==1) value = <span class="stringliteral">"1"</span>; <a name="l00191"></a>00191 <span class="keywordflow">else</span> value = <span class="stringliteral">"X"</span>; <a name="l00192"></a>00192 os << cl.<a class="code" href="classCClause.html#a8254175660df4f73f485f9227becaf14">literals</a>()[i] << <span class="stringliteral">"("</span> << value << <span class="stringliteral">"@"</span> << <a class="code" href="classCDatabase.html#af421024d0ade14743332069684aba162">variable</a>(cl.<a class="code" href="classCClause.html#aa9e91f96e80b94da2b28e3ab381b9acc">literal</a>(i).<a class="code" href="classCLitPoolElement.html#a98d4a07830b749d83c74943efdf9669b">var_index</a>()).dlevel()<< <span class="stringliteral">") "</span>; <a name="l00193"></a>00193 } <a name="l00194"></a>00194 os << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00195"></a>00195 } <a name="l00196"></a>00196 <a name="l00197"></a><a class="code" href="classCDatabase.html#a4ecc7a06a141221adf3aff50d3ac6cf6">00197</a> <span class="keywordtype">void</span> <a class="code" href="classCDatabase.html#a4ecc7a06a141221adf3aff50d3ac6cf6">CDatabase::dump</a>(ostream & os) { <a name="l00198"></a>00198 os << <span class="stringliteral">"Dump Database: "</span> << <a class="code" href="group__ExprStream__Manip.html#ga05b0ea7353ec24fa8e7e272d7a7875d8" title="Print the end-of-line.">endl</a>; <a name="l00199"></a>00199 <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> i=0; i<<a class="code" href="classCDatabase.html#a6adefe9983a5487fca8fc26cf8d9573f">_clauses</a>.size(); ++i) <a name="l00200"></a>00200 <a class="code" href="classCDatabase.html#a074d5b5a1fa285b8ae0e3c516a06a508">detail_dump_cl</a>(i); <a name="l00201"></a>00201 <span class="comment">// os << "Cl: " << i << " " << clause(i) << endl;</span> <a name="l00202"></a>00202 <span class="keywordflow">for</span>(<span class="keywordtype">unsigned</span> i=1; i<<a class="code" href="classCDatabase.html#a0bc13af9359ede872eefe8e1f44b3069">_variables</a>.size(); ++i) <a name="l00203"></a>00203 os << <span class="stringliteral">"VID: "</span> << i << <span class="stringliteral">"\t"</span> << <a class="code" href="classCDatabase.html#af421024d0ade14743332069684aba162">variable</a>(i); <a name="l00204"></a>00204 } <a name="l00205"></a>00205 <a name="l00206"></a>00206 <a name="l00207"></a>00207 <a name="l00208"></a>00208 <a name="l00209"></a>00209 <a name="l00210"></a>00210 <a name="l00211"></a>00211 <a name="l00212"></a>00212 <a name="l00213"></a>00213 <a name="l00214"></a>00214 <a name="l00215"></a>00215 <a name="l00216"></a>00216 <a name="l00217"></a>00217 <a name="l00218"></a>00218 <a name="l00219"></a>00219 <a name="l00220"></a>00220 <a name="l00221"></a>00221 <a name="l00222"></a>00222 <a name="l00223"></a>00223 <a name="l00224"></a>00224 </pre></div></div> </div> <hr class="footer"/><address class="footer"><small>Generated on Wed Sep 7 2011 for CVC3 by  <a href="http://www.doxygen.org/index.html"> <img class="footer" src="doxygen.png" alt="doxygen"/></a> 1.7.4 </small></address> </body> </html>