dlvhex
2.5.0
|
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 #ifndef FIXTUREONLINEMB_HPP_INCLUDED__24092010 00032 #define FIXTUREONLINEMB_HPP_INCLUDED__24092010 00033 00034 #include "fixtureE1.h" 00035 #include "fixtureE2.h" 00036 #include "fixtureEx1.h" 00037 00038 #include "dlvhex2/OnlineModelBuilder.h" 00039 #include "dlvhex2/Logger.h" 00040 00041 #include <boost/test/unit_test.hpp> 00042 00043 00044 // fixture for testing online model building with some underlying eval graph fixture 00045 // for that we add a final unit depending on all other units 00046 // and we setup model generator factories 00047 template<typename EvalGraphBaseFixtureT> 00048 struct OnlineModelBuilderTFixture: 00049 public EvalGraphBaseFixtureT 00050 { 00051 typedef EvalGraphBaseFixtureT Base; 00052 typedef dlvhex::OnlineModelBuilder<TestEvalGraph> ModelBuilder; 00053 typedef ModelBuilder::OptionalModel OptionalModel; 00054 00055 dlvhex::ModelBuilderConfig<TestEvalGraph> cfg; 00056 ModelBuilder omb; 00057 EvalUnit ufinal; 00058 00059 OnlineModelBuilderTFixture(): 00060 EvalGraphBaseFixtureT(), 00061 cfg(Base::eg), 00062 omb(cfg) 00063 { 00064 LOG_SCOPE(INFO,"OnlineModelBuilderTFixture<...>", true); 00065 typedef TestEvalUnitPropertyBase UnitCfg; 00066 typedef TestEvalGraph::EvalUnitDepPropertyBundle UnitDepCfg; 00067 TestEvalGraph& eg = Base::eg; 00068 00069 // setup final unit 00070 BOOST_TEST_MESSAGE("adding ufinal"); 00071 LOG(INFO,"ufinal = " << ufinal); 00072 ufinal = eg.addUnit(UnitCfg()); 00073 00074 TestEvalGraph::EvalUnitIterator it, itend; 00075 boost::tie(it, itend) = eg.getEvalUnits(); 00076 for(; it != itend && *it != ufinal; ++it) 00077 { 00078 LOG(INFO,"setting up TestModelGeneratorFactory on unit " << *it); 00079 eg.propsOf(*it).mgf.reset( 00080 new TestModelGeneratorFactory(eg.propsOf(*it).ctx)); 00081 00082 LOG(INFO,"adding dependency from ufinal to unit " << *it << " join order " << *it); 00083 // we can do this because we know that eval units (= vertices of a vecS adjacency list) are unsigned integers 00084 eg.addDependency(ufinal, *it, UnitDepCfg(*it)); 00085 } 00086 } 00087 00088 ~OnlineModelBuilderTFixture() {} 00089 }; 00090 00091 // create one E1 model building fixture 00092 typedef OnlineModelBuilderTFixture<EvalGraphE1Fixture> 00093 OnlineModelBuilderE1Fixture; 00094 00095 // create one normal E2 model building fixture 00096 typedef OnlineModelBuilderTFixture<EvalGraphE2Fixture> 00097 OnlineModelBuilderE2Fixture; 00098 00099 // create one E2 model building fixture with mirrored join order u2/u3 00100 typedef OnlineModelBuilderTFixture<EvalGraphE2MirroredFixture> 00101 OnlineModelBuilderE2MirroredFixture; 00102 00103 // create one Ex1 model building fixture 00104 typedef OnlineModelBuilderTFixture<EvalGraphEx1Fixture> 00105 OnlineModelBuilderEx1Fixture; 00106 00107 #endif // FIXTUREONLINEMB_HPP_INCLUDED__24092010