dlvhex  2.5.0
testsuite/fixtureE2.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 "fixtureE2.h"
00036 
00037 #include <boost/test/unit_test.hpp>
00038 
00039 EvalGraphE2Fixture::EvalGraphE2Fixture(bool mirrored)
00040 {
00041   LOG_SCOPE(INFO,"EvalGraphE2Fixture", true);
00042   typedef TestEvalUnitPropertyBase UnitCfg;
00043   typedef TestEvalGraph::EvalUnitDepPropertyBundle UnitDepCfg;
00044 
00045   BOOST_TEST_MESSAGE("adding u1");
00046   u1 = eg.addUnit(UnitCfg("plan(a) v plan(b)."));
00047   LOG(INFO,"u1 = " << u1);
00048   BOOST_TEST_MESSAGE("adding u2");
00049   u2 = eg.addUnit(UnitCfg("need(p,C) :- &cost[plan](C). :- need(_,money).")); 
00050   LOG(INFO,"u2 = " << u2);
00051   BOOST_TEST_MESSAGE("adding u3");
00052   // u3: EDB will NOT be part of this in the real system, but here it is useful to know what's going on
00053   u3 = eg.addUnit(UnitCfg("use(X) v use(Y) :- plan(P), choose(P,X,Y). choose(a,c,d). choose(b,e,f)."));
00054   LOG(INFO,"u3 = " << u3);
00055   BOOST_TEST_MESSAGE("adding u4");
00056   u4 = eg.addUnit(UnitCfg("need(u,C) :- &cost[use](C). :- need(_,money)."));
00057   LOG(INFO,"u4 = " << u4);
00058   BOOST_TEST_MESSAGE("adding e21");
00059   e21 = eg.addDependency(u2, u1, UnitDepCfg(0));
00060   BOOST_TEST_MESSAGE("adding e31");
00061   e31 = eg.addDependency(u3, u1, UnitDepCfg(0));
00062   LOG(INFO,"mirrored = " << mirrored);
00063   if( mirrored )
00064   {
00065     BOOST_TEST_MESSAGE("adding e43");
00066     e43 = eg.addDependency(u4, u3, UnitDepCfg(0));
00067     BOOST_TEST_MESSAGE("adding e42");
00068     e42 = eg.addDependency(u4, u2, UnitDepCfg(1));
00069   }
00070   else
00071   {
00072     BOOST_TEST_MESSAGE("adding e42");
00073     e42 = eg.addDependency(u4, u2, UnitDepCfg(0));
00074     BOOST_TEST_MESSAGE("adding e43");
00075     e43 = eg.addDependency(u4, u3, UnitDepCfg(1));
00076   }
00077 }
00078