dlvhex  2.5.0
include/dlvhex2/GenuineWellfoundedModelGenerator.h
Go to the documentation of this file.
00001 /* dlvhex -- Answer-Set Programming with external interfaces.
00002  * Copyright (C) 2005-2007 Roman Schindlauer
00003  * Copyright (C) 2006-2015 Thomas Krennwallner
00004  * Copyright (C) 2009-2016 Peter Schüller
00005  * Copyright (C) 2011-2016 Christoph Redl
00006  * Copyright (C) 2015-2016 Tobias Kaminski
00007  * Copyright (C) 2015-2016 Antonius Weinzierl
00008  *
00009  * This file is part of dlvhex.
00010  *
00011  * dlvhex is free software; you can redistribute it and/or modify it
00012  * under the terms of the GNU Lesser General Public License as
00013  * published by the Free Software Foundation; either version 2.1 of
00014  * the License, or (at your option) any later version.
00015  *
00016  * dlvhex is distributed in the hope that it will be useful, but
00017  * WITHOUT ANY WARRANTY; without even the implied warranty of
00018  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
00019  * Lesser General Public License for more details.
00020  *
00021  * You should have received a copy of the GNU Lesser General Public
00022  * License along with dlvhex; if not, write to the Free Software
00023  * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA
00024  * 02110-1301 USA.
00025  */
00026 
00037 #ifndef GENUINEWELLFOUNDED_MODEL_GENERATOR_HPP_INCLUDED__09122011
00038 #define GENUINEWELLFOUNDED_MODEL_GENERATOR_HPP_INCLUDED__09122011
00039 
00040 #include "dlvhex2/PlatformDefinitions.h"
00041 #include "dlvhex2/fwd.h"
00042 #include "dlvhex2/ID.h"
00043 #include "dlvhex2/BaseModelGenerator.h"
00044 #include "dlvhex2/ComponentGraph.h"
00045 
00046 DLVHEX_NAMESPACE_BEGIN
00047 
00048 class GenuineWellfoundedModelGeneratorFactory;
00049 
00051 class GenuineWellfoundedModelGenerator:
00052 public BaseModelGenerator,
00053 public ostream_printable<GenuineWellfoundedModelGenerator>
00054 {
00055     // types
00056     public:
00057         typedef GenuineWellfoundedModelGeneratorFactory Factory;
00058 
00059         // storage
00060     protected:
00062         Factory& factory;
00063 
00065         ASPSolverManager::ResultsPtr currentResults;
00067         bool firstcall;
00068 
00069         // members
00070     public:
00076         GenuineWellfoundedModelGenerator(Factory& factory, InterpretationConstPtr input);
00078         virtual ~GenuineWellfoundedModelGenerator();
00079 
00080         // generate and return next model, return null after last model
00081         virtual InterpretationPtr generateNextModel();
00082 };
00083 
00085 class GenuineWellfoundedModelGeneratorFactory:
00086 public BaseModelGeneratorFactory,
00087 public ostream_printable<GenuineWellfoundedModelGeneratorFactory>
00088 {
00089     // types
00090     public:
00091         friend class GenuineWellfoundedModelGenerator;
00092         typedef ComponentGraph::ComponentInfo ComponentInfo;
00093 
00094         // storage
00095     protected:
00097         ASPSolverManager::SoftwareConfigurationPtr externalEvalConfig;
00099         ProgramCtx& ctx;
00101         ComponentInfo ci;        // should be a reference, but there is currently a bug in the copy constructor of ComponentGraph: it seems that the component info is shared between different copies of a component graph, hence it is deallocated when one of the copies dies.
00102 
00104         std::vector<ID> outerEatoms;
00106         std::vector<ID> innerEatoms;
00110         std::vector<ID> idb;
00114         std::vector<ID> xidb;
00115 
00117         std::vector<ID> deidbInnerEatoms;
00121         std::vector<ID> deidb;
00122 
00123         // methods
00124     public:
00131         GenuineWellfoundedModelGeneratorFactory(
00132             ProgramCtx& ctx, const ComponentInfo& ci,
00133             ASPSolverManager::SoftwareConfigurationPtr externalEvalConfig);
00135         virtual ~GenuineWellfoundedModelGeneratorFactory() {}
00136 
00142         virtual ModelGeneratorPtr createModelGenerator(
00143             InterpretationConstPtr input)
00144             { return ModelGeneratorPtr(new GenuineWellfoundedModelGenerator(*this, input)); }
00145 
00148         virtual std::ostream& print(std::ostream& o) const;
00149 };
00150 
00151 DLVHEX_NAMESPACE_END
00152 #endif                           // WELLFOUNDED_MODEL_GENERATOR_HPP_INCLUDED__09112010
00153 
00154 // vim:expandtab:ts=4:sw=4:
00155 // mode: C++
00156 // End: