1 /** 2 * 3 * Copyright (c) 2005-2021 by Pierre-Henri WUILLEMIN(_at_LIP6) & Christophe GONZALES(_at_AMU) 4 * info_at_agrum_dot_org 5 * 6 * This library is free software: you can redistribute it and/or modify 7 * it under the terms of the GNU Lesser General Public License as published by 8 * the Free Software Foundation, either version 3 of the License, or 9 * (at your option) any later version. 10 * 11 * This library is distributed in the hope that it will be useful, 12 * but WITHOUT ANY WARRANTY; without even the implied warranty of 13 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 14 * GNU Lesser General Public License for more details. 15 * 16 * You should have received a copy of the GNU Lesser General Public License 17 * along with this library. If not, see <http://www.gnu.org/licenses/>. 18 * 19 */ 20 21 22 #ifndef GUM_UTILS_PRM_H 23 #define GUM_UTILS_PRM_H 24 25 #include <string> 26 #include <vector> 27 28 #include <agrum/agrum.h> 29 30 #include <agrum/tools/multidim/ICIModels/multiDimNoisyORCompound.h> 31 #include <agrum/tools/multidim/ICIModels/multiDimNoisyORNet.h> 32 #include <agrum/tools/multidim/aggregators/multiDimAggregator.h> 33 #include <agrum/tools/multidim/implementations/multiDimBijArray.h> 34 #include <agrum/tools/multidim/implementations/multiDimBucket.h> 35 #include <agrum/tools/multidim/implementations/multiDimSparse.h> 36 #include <agrum/tools/multidim/potential.h> 37 #include <agrum/tools/multidim/utils/operators/multiDimCombinationDefault.h> 38 #include <agrum/tools/multidim/utils/operators/projections4MultiDim.h> 39 40 #include <agrum/PRM/elements/PRMObject.h> 41 42 namespace gum { 43 namespace prm { 44 45 /// PRMType for real numbers 46 typedef float prm_float; 47 48 /// Decompose a string in a vector of strings using "." as separators. 49 void decomposePath(const std::string& path, std::vector< std::string >& v); 50 51 /** 52 * @brief Returns a copy of a Potential after applying a bijection over the 53 *variables in source. 54 * This copies the Potential source in a new Potential by permuting all 55 *variables in source with respect to bij. 56 * 57 * @warning This method in most case creates the new Potential using a 58 *gum::MultiDimBijArray, this means that the created Potential holds a 59 *reference over source, so do not delete source if you still need the created 60 *potential. 61 * 62 * @param bij A Bijection of DiscreteVariable where firsts are variables in 63 *source and seconds variables added in the returned Potential. 64 * @param source The copied Potential. 65 * @return a pointer over a Potential which is a copy of source. 66 * @throw FatalError raised if an unknown MultiDimImplementation is 67 *encountered. 68 */ 69 template < typename GUM_SCALAR > 70 Potential< GUM_SCALAR >* 71 copyPotential(const Bijection< const DiscreteVariable*, const DiscreteVariable* >& bij, 72 const Potential< GUM_SCALAR >& source); 73 74 template < typename GUM_SCALAR > 75 Potential< GUM_SCALAR >* multPotential(const Potential< GUM_SCALAR >& t1, 76 const Potential< GUM_SCALAR >& t2); 77 /** 78 * @brief Proceeds with the elimination of var in pool. 79 * @param var The variable eliminated from every potentials in pool. 80 * @param pool A pool of potentials in which the elimination of var is done. 81 * @param trash All create potentials are inserted in this set, useful to 82 * delete later. 83 */ 84 template < typename GUM_SCALAR > 85 void eliminateNode(const DiscreteVariable* var, 86 Set< Potential< GUM_SCALAR >* >& pool, 87 Set< Potential< GUM_SCALAR >* >& trash); 88 89 template < typename GUM_SCALAR > 90 void eliminateNodes(const std::vector< const DiscreteVariable* >& elim_order, 91 Set< Potential< GUM_SCALAR >* >& pool, 92 Set< Potential< GUM_SCALAR >* >& trash); 93 94 /** 95 * @brief Returns the next value of an unique counter for PRM's node id. 96 * @return Returns the next value of an unique counter for PRM's node id. 97 */ 98 NodeId nextNodeId(); 99 100 } /* namespace prm */ 101 } /* namespace gum */ 102 103 #include <agrum/PRM/utils_prm_tpl.h> 104 105 #endif // GUM_UTILS_PRM_H 106