dlvhex  2.5.0
testsuite/TestOfflineModelBuilder.cpp
Go to the documentation of this file.
00001 /* dlvhex -- Answer-Set Programming with external interfaces.
00002  * Copyright (C) 2005, 2006, 2007 Roman Schindlauer
00003  * Copyright (C) 2006, 2007, 2008, 2009, 2010 Thomas Krennwallner
00004  * Copyright (C) 2009, 2010 Peter Schüller
00005  * 
00006  * This file is part of dlvhex.
00007  *
00008  * dlvhex is free software; you can redistribute it and/or modify it
00009  * under the terms of the GNU Lesser General Public License as
00010  * published by the Free Software Foundation; either version 2.1 of
00011  * the License, or (at your option) any later version.
00012  *
00013  * dlvhex is distributed in the hope that it will be useful, but
00014  * WITHOUT ANY WARRANTY; without even the implied warranty of
00015  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00016  * Lesser General Public License for more details.
00017  *
00018  * You should have received a copy of the GNU Lesser General Public
00019  * License along with dlvhex; if not, write to the Free Software
00020  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00021  * 02110-1301 USA.
00022  */
00023 
00031 #ifdef HAVE_CONFIG_H
00032 #include "config.h"
00033 #endif // HAVE_CONFIG_H
00034 
00035 #include <iostream>
00036 #include <set>
00037 #include <list>
00038 #include <string>
00039 #include <vector>
00040 #include <cassert>
00041 
00042 #include <boost/foreach.hpp>
00043 //#include <boost/type_traits/remove_const.hpp>
00044 #include <boost/graph/graph_traits.hpp>
00045 #include <boost/graph/adjacency_list.hpp>
00046 #include <boost/property_map/vector_property_map.hpp>
00047 #include <boost/concept/assert.hpp>
00048 #include <boost/concept_check.hpp>
00049 #define BOOST_TEST_MODULE __FILE__
00050 #include <boost/test/unit_test.hpp>
00051 
00052 #include "dlvhex2/Logger.h"
00053 #include "dlvhex2/EvalGraph.h"
00054 #include "dlvhex2/ModelGraph.h"
00055 #include "dlvhex2/ModelGenerator.h"
00056 #include "dlvhex2/OfflineModelBuilder.h"
00057 
00058 #include "fixtureOfflineMB.h"
00059 
00060 LOG_INIT(Logger::ERROR | Logger::WARNING)
00061 
00062 using dlvhex::MT_IN;
00063 using dlvhex::MT_OUT;
00064 
00065 template<typename ModelGraphT>
00066 void verifyModels(
00067     const ModelGraphT& mg,
00068     const typename ModelGraphT::ModelList& models,
00069     const std::set< std::set<std::string> >& refints)
00070 {
00071   std::set< std::set<std::string> > ints;
00072   for(typename ModelGraphT::ModelList::const_iterator itm = models.begin();
00073       itm != models.end(); ++itm)
00074   {
00075     BOOST_REQUIRE(mg.propsOf(*itm).interpretation != NULL);
00076     TestInterpretation& ti = *(mg.propsOf(*itm).interpretation);
00077     ints.insert(ti.getAtoms());
00078   }
00079   LOG(INFO,"checking equality of set of models:");
00080   BOOST_FOREACH(const std::set<std::string>& pset, refints)
00081     { LOG(INFO,"reference " << printset(pset)); }
00082   BOOST_FOREACH(const std::set<std::string>& pset, ints)
00083     { LOG(INFO,"returned  " << printset(pset)); }
00084   BOOST_CHECK(ints == refints);
00085 }
00086 
00087 BOOST_AUTO_TEST_SUITE(root_TestOfflineModelBuilder)
00088 
00089 BOOST_FIXTURE_TEST_CASE(offline_model_building_e1_u1_input, OfflineModelBuilderE1Fixture)
00090 {
00091   unsigned mcount = omb.buildIModels(u1);
00092   BOOST_REQUIRE_EQUAL(mcount,1);
00093   {
00094     typedef ModelBuilder::MyModelGraph MyModelGraph;
00095     MyModelGraph& mg = omb.getModelGraph();
00096     const MyModelGraph::ModelList& models = mg.modelsAt(u1, MT_IN);
00097     BOOST_REQUIRE_EQUAL(models.size(), 1);
00098     MyModelGraph::Model m = models.front();
00099     BOOST_CHECK_EQUAL(mg.propsOf(m).dummy, true);
00100     BOOST_CHECK(mg.propsOf(m).interpretation == NULL);
00101   }
00102 }
00103 
00104 BOOST_FIXTURE_TEST_CASE(offline_model_building_e1_u1_output, OfflineModelBuilderE1Fixture)
00105 {
00106   unsigned imcount1 = omb.buildIModels(u1);
00107   BOOST_REQUIRE_EQUAL(imcount1,1U);
00108 
00109   unsigned mcount = omb.buildOModels(u1);
00110   BOOST_REQUIRE_EQUAL(mcount,4U);
00111   {
00112     typedef ModelBuilder::MyModelGraph MyModelGraph;
00113     MyModelGraph& mg = omb.getModelGraph();
00114     const MyModelGraph::ModelList& models = mg.modelsAt(u1, MT_OUT);
00115     BOOST_REQUIRE_EQUAL(models.size(),4U);
00116 
00117     std::set< std::set<std::string> > refints;
00118     {
00119       // create reference models in refints
00120       std::set<std::string> refint_m1, refint_m2, refint_m3, refint_m4;
00121       refint_m1.insert("plan(a)");
00122       refint_m1.insert("use(c)");
00123       refint_m2.insert("plan(a)");
00124       refint_m2.insert("use(d)");
00125       refint_m3.insert("plan(b)");
00126       refint_m3.insert("use(e)");
00127       refint_m4.insert("plan(b)");
00128       refint_m4.insert("use(f)");
00129       refints.insert(refint_m1);
00130       refints.insert(refint_m2);
00131       refints.insert(refint_m3);
00132       refints.insert(refint_m4);
00133     }
00134     verifyModels(mg, models, refints);
00135   }
00136 }
00137 
00138 BOOST_FIXTURE_TEST_CASE(offline_model_building_e1_u2_input, OfflineModelBuilderE1Fixture)
00139 {
00140   unsigned imcount1 = omb.buildIModels(u1);
00141   BOOST_REQUIRE_EQUAL(imcount1,1U);
00142 
00143   unsigned omcount1 = omb.buildOModels(u1);
00144   BOOST_REQUIRE_EQUAL(omcount1,4U);
00145 
00146   unsigned mcount = omb.buildIModels(u2);
00147   BOOST_REQUIRE_EQUAL(mcount,4U);
00148   {
00149     typedef ModelBuilder::MyModelGraph MyModelGraph;
00150     MyModelGraph& mg = omb.getModelGraph();
00151     const MyModelGraph::ModelList& models = mg.modelsAt(u2, MT_IN);
00152     BOOST_REQUIRE_EQUAL(models.size(),4U);
00153 
00154     std::set< std::set<std::string> > refints;
00155     {
00156       // create reference models in refints
00157       std::set<std::string> refint_m1, refint_m2, refint_m3, refint_m4;
00158       refint_m1.insert("plan(a)");
00159       refint_m1.insert("use(c)");
00160       refint_m2.insert("plan(a)");
00161       refint_m2.insert("use(d)");
00162       refint_m3.insert("plan(b)");
00163       refint_m3.insert("use(e)");
00164       refint_m4.insert("plan(b)");
00165       refint_m4.insert("use(f)");
00166       refints.insert(refint_m1);
00167       refints.insert(refint_m2);
00168       refints.insert(refint_m3);
00169       refints.insert(refint_m4);
00170     }
00171     verifyModels(mg, models, refints);
00172   }
00173 }
00174 
00175 BOOST_FIXTURE_TEST_CASE(offline_model_building_e1_u2_output, OfflineModelBuilderE1Fixture)
00176 {
00177   unsigned imcount1 = omb.buildIModels(u1);
00178   BOOST_REQUIRE_EQUAL(imcount1,1U);
00179 
00180   unsigned omcount1 = omb.buildOModels(u1);
00181   BOOST_REQUIRE_EQUAL(omcount1,4U);
00182 
00183   unsigned imcount2 = omb.buildIModels(u2);
00184   BOOST_REQUIRE_EQUAL(imcount2,4U);
00185 
00186   unsigned mcount = omb.buildOModels(u2);
00187   BOOST_REQUIRE_EQUAL(mcount,4U);
00188   {
00189     typedef ModelBuilder::MyModelGraph MyModelGraph;
00190     MyModelGraph& mg = omb.getModelGraph();
00191     const MyModelGraph::ModelList& models = mg.modelsAt(u2, MT_OUT);
00192     BOOST_REQUIRE_EQUAL(models.size(),4U);
00193 
00194     std::set< std::set<std::string> > refints;
00195     {
00196       // create reference models in refints
00197       std::set<std::string> refint_m1, refint_m2, refint_m3, refint_m4;
00198       refint_m1.insert("need(p,money)");
00199       refint_m1.insert("need(u,time)");
00200       refint_m2.insert("need(p,money)"); // should collapse with above!
00201       refint_m2.insert("need(u,time)");  // should collapse with above!
00202       refint_m3.insert("need(p,time)");
00203       refint_m3.insert("need(u,time)");
00204       refint_m4.insert("need(p,time)");
00205       refint_m4.insert("need(u,money)");
00206       refints.insert(refint_m1);
00207       refints.insert(refint_m2);
00208       refints.insert(refint_m3);
00209       refints.insert(refint_m4);
00210     }
00211     verifyModels(mg, models, refints);
00212   }
00213 }
00214 
00215 BOOST_FIXTURE_TEST_CASE(offline_model_building_e1_u3_input, OfflineModelBuilderE1Fixture)
00216 {
00217   unsigned imcount1 = omb.buildIModels(u1);
00218   BOOST_REQUIRE_EQUAL(imcount1,1U);
00219 
00220   unsigned omcount1 = omb.buildOModels(u1);
00221   BOOST_REQUIRE_EQUAL(omcount1,4U);
00222 
00223   unsigned imcount2 = omb.buildIModels(u2);
00224   BOOST_REQUIRE_EQUAL(imcount2,4U);
00225 
00226   unsigned omcount2 = omb.buildOModels(u2);
00227   BOOST_REQUIRE_EQUAL(omcount2,4U);
00228 
00229   unsigned mcount = omb.buildIModels(u3);
00230   BOOST_REQUIRE_EQUAL(mcount,4U);
00231   {
00232     typedef ModelBuilder::MyModelGraph MyModelGraph;
00233     MyModelGraph& mg = omb.getModelGraph();
00234     const MyModelGraph::ModelList& models = mg.modelsAt(u3, MT_IN);
00235     BOOST_REQUIRE_EQUAL(models.size(),4U);
00236 
00237     std::set< std::set<std::string> > refints;
00238     {
00239       // create reference models in refints
00240       std::set<std::string> refint_m1, refint_m2, refint_m3, refint_m4;
00241       refint_m1.insert("need(p,money)");
00242       refint_m1.insert("need(u,time)");
00243       refint_m2.insert("need(p,money)"); // should collapse with above!
00244       refint_m2.insert("need(u,time)");  // should collapse with above!
00245       refint_m3.insert("need(p,time)");
00246       refint_m3.insert("need(u,time)");
00247       refint_m4.insert("need(p,time)");
00248       refint_m4.insert("need(u,money)");
00249       refints.insert(refint_m1);
00250       refints.insert(refint_m2);
00251       refints.insert(refint_m3);
00252       refints.insert(refint_m4);
00253     }
00254     verifyModels(mg, models, refints);
00255   }
00256 }
00257 
00258 BOOST_FIXTURE_TEST_CASE(offline_model_building_e1_u3_output, OfflineModelBuilderE1Fixture)
00259 {
00260   unsigned imcount1 = omb.buildIModels(u1);
00261   BOOST_REQUIRE_EQUAL(imcount1,1U);
00262 
00263   unsigned omcount1 = omb.buildOModels(u1);
00264   BOOST_REQUIRE_EQUAL(omcount1,4U);
00265 
00266   unsigned imcount2 = omb.buildIModels(u2);
00267   BOOST_REQUIRE_EQUAL(imcount2,4U);
00268 
00269   unsigned omcount2 = omb.buildOModels(u2);
00270   BOOST_REQUIRE_EQUAL(omcount2,4U);
00271 
00272   unsigned imcount3 = omb.buildIModels(u3);
00273   BOOST_REQUIRE_EQUAL(imcount3,4U);
00274 
00275   unsigned mcount = omb.buildOModels(u3);
00276   BOOST_REQUIRE_EQUAL(mcount,1U);
00277   {
00278     typedef ModelBuilder::MyModelGraph MyModelGraph;
00279     MyModelGraph& mg = omb.getModelGraph();
00280     const MyModelGraph::ModelList& models = mg.modelsAt(u3, MT_OUT);
00281     BOOST_REQUIRE_EQUAL(models.size(),1U);
00282 
00283     std::set< std::set<std::string> > refints;
00284     {
00285       // create reference models in refints
00286       std::set<std::string> refint_m1;
00287       refints.insert(refint_m1);
00288     }
00289     verifyModels(mg, models, refints);
00290   }
00291 }
00292 
00293 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u1_output, OfflineModelBuilderE2Fixture)
00294 {
00295   unsigned imcount1 = omb.buildIModels(u1);
00296   BOOST_REQUIRE_EQUAL(imcount1,1U);
00297   
00298   unsigned mcount = omb.buildOModels(u1);
00299   BOOST_REQUIRE_EQUAL(mcount,2U);
00300   {
00301     typedef ModelBuilder::MyModelGraph MyModelGraph;
00302     MyModelGraph& mg = omb.getModelGraph();
00303     const MyModelGraph::ModelList& models = mg.modelsAt(u1, MT_OUT);
00304     BOOST_REQUIRE_EQUAL(models.size(),2U);
00305 
00306     std::set< std::set<std::string> > refints;
00307     {
00308       // create reference models in refints
00309       std::set<std::string> refint_m1, refint_m2;
00310       refint_m1.insert("plan(a)");
00311       refint_m2.insert("plan(b)");
00312       refints.insert(refint_m1);
00313       refints.insert(refint_m2);
00314     }
00315     verifyModels(mg, models, refints);
00316   }
00317 }
00318 
00319 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u2_input, OfflineModelBuilderE2Fixture)
00320 {
00321   unsigned imcount1 = omb.buildIModels(u1);
00322   BOOST_REQUIRE_EQUAL(imcount1,1U);
00323   
00324   unsigned omcount1 = omb.buildOModels(u1);
00325   BOOST_REQUIRE_EQUAL(omcount1,2U);
00326 
00327   unsigned mcount = omb.buildIModels(u2);
00328   BOOST_REQUIRE_EQUAL(mcount,2U);
00329   {
00330     typedef ModelBuilder::MyModelGraph MyModelGraph;
00331     MyModelGraph& mg = omb.getModelGraph();
00332     const MyModelGraph::ModelList& models = mg.modelsAt(u2, MT_IN);
00333     BOOST_REQUIRE_EQUAL(models.size(),2U);
00334 
00335     std::set< std::set<std::string> > refints;
00336     {
00337       // create reference models in refints
00338       std::set<std::string> refint_m1, refint_m2;
00339       refint_m1.insert("plan(a)");
00340       refint_m2.insert("plan(b)");
00341       refints.insert(refint_m1);
00342       refints.insert(refint_m2);
00343     }
00344     verifyModels(mg, models, refints);
00345   }
00346 }
00347 
00348 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u2u3_input, OfflineModelBuilderE2Fixture)
00349 {
00350   unsigned imcount1 = omb.buildIModels(u1);
00351   BOOST_REQUIRE_EQUAL(imcount1,1U);
00352   
00353   unsigned omcount1 = omb.buildOModels(u1);
00354   BOOST_REQUIRE_EQUAL(omcount1,2U);
00355 
00356   unsigned imcount2 = omb.buildIModels(u2);
00357   BOOST_REQUIRE_EQUAL(imcount2,2U);
00358 
00359   unsigned mcount = omb.buildIModels(u3);
00360   BOOST_REQUIRE_EQUAL(mcount,2U);
00361   {
00362     typedef ModelBuilder::MyModelGraph MyModelGraph;
00363     MyModelGraph& mg = omb.getModelGraph();
00364     const MyModelGraph::ModelList& models = mg.modelsAt(u3, MT_IN);
00365     BOOST_REQUIRE_EQUAL(models.size(),2U);
00366 
00367     std::set< std::set<std::string> > refints;
00368     {
00369       // create reference models in refints
00370       std::set<std::string> refint_m1, refint_m2;
00371       refint_m1.insert("plan(a)");
00372       refint_m2.insert("plan(b)");
00373       refints.insert(refint_m1);
00374       refints.insert(refint_m2);
00375     }
00376     verifyModels(mg, models, refints);
00377   }
00378 }
00379 
00380 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u2_output, OfflineModelBuilderE2Fixture)
00381 {
00382   unsigned imcount1 = omb.buildIModels(u1);
00383   BOOST_REQUIRE_EQUAL(imcount1,1U);
00384   
00385   unsigned omcount1 = omb.buildOModels(u1);
00386   BOOST_REQUIRE_EQUAL(omcount1,2U);
00387 
00388   unsigned imcount2 = omb.buildIModels(u2);
00389   BOOST_REQUIRE_EQUAL(imcount2,2U);
00390 
00391   unsigned mcount = omb.buildOModels(u2);
00392   BOOST_REQUIRE_EQUAL(mcount,1U);
00393   {
00394     typedef ModelBuilder::MyModelGraph MyModelGraph;
00395     MyModelGraph& mg = omb.getModelGraph();
00396     const MyModelGraph::ModelList& models = mg.modelsAt(u2, MT_OUT);
00397     BOOST_REQUIRE_EQUAL(models.size(),1U);
00398 
00399     std::set< std::set<std::string> > refints;
00400     {
00401       // create reference models in refints
00402       std::set<std::string> refint_m1;
00403       refint_m1.insert("need(p,time)");
00404       refints.insert(refint_m1);
00405     }
00406     verifyModels(mg, models, refints);
00407   }
00408 }
00409 
00410 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u2u3_output, OfflineModelBuilderE2Fixture)
00411 {
00412   unsigned imcount1 = omb.buildIModels(u1);
00413   BOOST_REQUIRE_EQUAL(imcount1,1U);
00414   
00415   unsigned omcount1 = omb.buildOModels(u1);
00416   BOOST_REQUIRE_EQUAL(omcount1,2U);
00417 
00418   unsigned imcount2 = omb.buildIModels(u2);
00419   BOOST_REQUIRE_EQUAL(imcount2,2U);
00420 
00421   unsigned omcount2 = omb.buildOModels(u2);
00422   BOOST_REQUIRE_EQUAL(omcount2,1U);
00423 
00424   unsigned imcount3 = omb.buildIModels(u3);
00425   BOOST_REQUIRE_EQUAL(imcount3,2U);
00426   
00427   unsigned mcount = omb.buildOModels(u3);
00428   BOOST_REQUIRE_EQUAL(mcount,4U);
00429   {
00430     typedef ModelBuilder::MyModelGraph MyModelGraph;
00431     MyModelGraph& mg = omb.getModelGraph();
00432     const MyModelGraph::ModelList& models = mg.modelsAt(u3, MT_OUT);
00433     BOOST_REQUIRE_EQUAL(models.size(),4U);
00434 
00435     std::set< std::set<std::string> > refints;
00436     {
00437       // create reference models in refints
00438       std::set<std::string> refint_m1, refint_m2, refint_m3, refint_m4;
00439       refint_m1.insert("use(c)");
00440       refint_m2.insert("use(d)");
00441       refint_m3.insert("use(e)");
00442       refint_m4.insert("use(f)");
00443       refints.insert(refint_m1);
00444       refints.insert(refint_m2);
00445       refints.insert(refint_m3);
00446       refints.insert(refint_m4);
00447     }
00448     verifyModels(mg, models, refints);
00449   }
00450 }
00451 
00452 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u4_input, OfflineModelBuilderE2Fixture)
00453 {
00454   unsigned imcount1 = omb.buildIModels(u1);
00455   BOOST_REQUIRE_EQUAL(imcount1,1U);
00456   
00457   unsigned omcount1 = omb.buildOModels(u1);
00458   BOOST_REQUIRE_EQUAL(omcount1,2U);
00459 
00460   // this order is intentionally shuffled a bit
00461   unsigned imcount2 = omb.buildIModels(u2);
00462   BOOST_REQUIRE_EQUAL(imcount2,2U);
00463 
00464   unsigned imcount3 = omb.buildIModels(u3);
00465   BOOST_REQUIRE_EQUAL(imcount3,2U);
00466   
00467   unsigned omcount3 = omb.buildOModels(u3);
00468   BOOST_REQUIRE_EQUAL(omcount3,4U);
00469 
00470   unsigned omcount2 = omb.buildOModels(u2);
00471   BOOST_REQUIRE_EQUAL(omcount2,1U);
00472 
00473   unsigned mcount = omb.buildIModels(u4);
00474   BOOST_REQUIRE_EQUAL(mcount,2U);
00475   {
00476     typedef ModelBuilder::MyModelGraph MyModelGraph;
00477     MyModelGraph& mg = omb.getModelGraph();
00478     const MyModelGraph::ModelList& models = mg.modelsAt(u4, MT_IN);
00479     BOOST_REQUIRE_EQUAL(models.size(),2U);
00480 
00481     std::set< std::set<std::string> > refints;
00482     {
00483       // create reference models in refints
00484       std::set<std::string> refint_m1, refint_m2;
00485       refint_m1.insert("need(p,time)");
00486       refint_m1.insert("use(e)");
00487       refint_m2.insert("need(p,time)");
00488       refint_m2.insert("use(f)");
00489       refints.insert(refint_m1);
00490       refints.insert(refint_m2);
00491     }
00492     verifyModels(mg, models, refints);
00493   }
00494 }
00495 
00496 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u4_output, OfflineModelBuilderE2Fixture)
00497 {
00498   unsigned imcount1 = omb.buildIModels(u1);
00499   BOOST_REQUIRE_EQUAL(imcount1,1U);
00500   
00501   unsigned omcount1 = omb.buildOModels(u1);
00502   BOOST_REQUIRE_EQUAL(omcount1,2U);
00503 
00504   unsigned imcount2 = omb.buildIModels(u2);
00505   BOOST_REQUIRE_EQUAL(imcount2,2U);
00506 
00507   unsigned omcount2 = omb.buildOModels(u2);
00508   BOOST_REQUIRE_EQUAL(omcount2,1U);
00509 
00510   unsigned imcount3 = omb.buildIModels(u3);
00511   BOOST_REQUIRE_EQUAL(imcount3,2U);
00512   
00513   unsigned omcount3 = omb.buildOModels(u3);
00514   BOOST_REQUIRE_EQUAL(omcount3,4U);
00515 
00516   unsigned imcount4 = omb.buildIModels(u4);
00517   BOOST_REQUIRE_EQUAL(imcount4,2U);
00518 
00519   unsigned mcount = omb.buildOModels(u4);
00520   BOOST_REQUIRE_EQUAL(mcount,1U);
00521   {
00522     typedef ModelBuilder::MyModelGraph MyModelGraph;
00523     MyModelGraph& mg = omb.getModelGraph();
00524     const MyModelGraph::ModelList& models = mg.modelsAt(u4, MT_OUT);
00525     BOOST_REQUIRE_EQUAL(models.size(),1U);
00526 
00527     std::set< std::set<std::string> > refints;
00528     {
00529       // create reference models in refints
00530       std::set<std::string> refint_m1;
00531       refint_m1.insert("need(u,time)");
00532       refints.insert(refint_m1);
00533     }
00534     verifyModels(mg, models, refints);
00535   }
00536 }
00537 
00538 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u4_input_recursively, OfflineModelBuilderE2Fixture)
00539 {
00540   unsigned mcount = omb.buildIModelsRecursively(u4);
00541   BOOST_REQUIRE_EQUAL(mcount,2U);
00542   {
00543     typedef ModelBuilder::MyModelGraph MyModelGraph;
00544     MyModelGraph& mg = omb.getModelGraph();
00545     const MyModelGraph::ModelList& models = mg.modelsAt(u4, MT_IN);
00546     BOOST_REQUIRE_EQUAL(models.size(),2U);
00547 
00548     std::set< std::set<std::string> > refints;
00549     {
00550       // create reference models in refints
00551       std::set<std::string> refint_m1, refint_m2;
00552       refint_m1.insert("need(p,time)");
00553       refint_m1.insert("use(e)");
00554       refint_m2.insert("need(p,time)");
00555       refint_m2.insert("use(f)");
00556       refints.insert(refint_m1);
00557       refints.insert(refint_m2);
00558     }
00559     verifyModels(mg, models, refints);
00560   }
00561 }
00562 
00563 BOOST_FIXTURE_TEST_CASE(offline_model_building_e2_u4_output_recursively, OfflineModelBuilderE2Fixture)
00564 {
00565   unsigned omcount4 = omb.buildOModelsRecursively(u4);
00566   BOOST_REQUIRE_EQUAL(omcount4,1U);
00567   {
00568     typedef ModelBuilder::MyModelGraph MyModelGraph;
00569     MyModelGraph& mg = omb.getModelGraph();
00570     const MyModelGraph::ModelList& models = mg.modelsAt(u4, MT_OUT);
00571     BOOST_REQUIRE_EQUAL(models.size(),1U);
00572 
00573     std::set< std::set<std::string> > refints;
00574     {
00575       // create reference models in refints
00576       std::set<std::string> refint_m1;
00577       refint_m1.insert("need(u,time)");
00578       refints.insert(refint_m1);
00579     }
00580     verifyModels(mg, models, refints);
00581   }
00582 }
00583 
00584 BOOST_FIXTURE_TEST_CASE(offline_model_building_ex1_u11_output_recursively, OfflineModelBuilderEx1Fixture)
00585 {
00586   unsigned omcount11 = omb.buildOModelsRecursively(u11);
00587   omb.printEvalGraphModelGraph(std::cerr);
00588   BOOST_REQUIRE(omcount11 > 0U);
00589   {
00590     typedef ModelBuilder::MyModelGraph MyModelGraph;
00591     MyModelGraph& mg = omb.getModelGraph();
00592     const MyModelGraph::ModelList& models = mg.modelsAt(u11, MT_OUT);
00593     BOOST_REQUIRE_EQUAL(models.size(),omcount11);
00594   }
00595 }
00596 
00597 BOOST_FIXTURE_TEST_CASE(offline_model_building_ex1_ufinal_input_recursively, OfflineModelBuilderEx1Fixture)
00598 {
00599   unsigned imcountfinal = omb.buildIModelsRecursively(ufinal);
00600   omb.printEvalGraphModelGraph(std::cerr);
00601   BOOST_REQUIRE_EQUAL(imcountfinal,6U);
00602   {
00603     typedef ModelBuilder::MyModelGraph MyModelGraph;
00604     MyModelGraph& mg = omb.getModelGraph();
00605     const MyModelGraph::ModelList& models = mg.modelsAt(ufinal, MT_IN);
00606     BOOST_REQUIRE_EQUAL(models.size(),6U);
00607 
00608     std::set< std::set<std::string> > refints;
00609     {
00610       // create reference models in refints
00611       { // {b, d, m, f, h, i, j, k, o}
00612         std::set<std::string> refint;
00613         refint.insert("b");
00614         refint.insert("d");
00615         refint.insert("m");
00616         refint.insert("f");
00617         refint.insert("h");
00618         refint.insert("i");
00619         refint.insert("j");
00620         refint.insert("k");
00621         refint.insert("o");
00622         refints.insert(refint);
00623       }
00624       { // {b, d, n, f, h, i, j, k}
00625         std::set<std::string> refint;
00626         refint.insert("b");
00627         refint.insert("d");
00628         refint.insert("n");
00629         refint.insert("f");
00630         refint.insert("h");
00631         refint.insert("i");
00632         refint.insert("j");
00633         refint.insert("k");
00634         refints.insert(refint);
00635       }
00636       { // {a, c, n, l}
00637         std::set<std::string> refint;
00638         refint.insert("a");
00639         refint.insert("c");
00640         refint.insert("n");
00641         refint.insert("l");
00642         refints.insert(refint);
00643       }
00644       { // {a, c, m, l}
00645         std::set<std::string> refint;
00646         refint.insert("a");
00647         refint.insert("c");
00648         refint.insert("m");
00649         refint.insert("l");
00650         refints.insert(refint);
00651       }
00652       { // {a, d, n, j, l}
00653         std::set<std::string> refint;
00654         refint.insert("a");
00655         refint.insert("d");
00656         refint.insert("n");
00657         refint.insert("j");
00658         refint.insert("l");
00659         refints.insert(refint);
00660       }
00661       { // {a, d, m, j, l}
00662         std::set<std::string> refint;
00663         refint.insert("a");
00664         refint.insert("d");
00665         refint.insert("m");
00666         refint.insert("j");
00667         refint.insert("l");
00668         refints.insert(refint);
00669       }
00670     }
00671     verifyModels(mg, models, refints);
00672   }
00673 }
00674 
00675 BOOST_AUTO_TEST_SUITE_END()