OverviewFilesCommitsIssuesDocsReleasesPeers

opencog-ure commits / 492638b

Move to here from AtomSpace
492638b76a43cd0b9deeabccb318fb580b18fc8d
by Linas Vepštas <linasvepstas@gmail.com> · 2025-01-24T06:39:34.000Z

Changed files (2) +39 -0

opencog/ure/ActionSelection.cc +28 -0
……@@ -77,4 +77,32 @@ std::string oc_to_string(const HandleTVMap& h2tv, const std::string& indent)
7777 return ss.str();
7878}
7979
80std::string oc_to_string(const HandleCounter& hc, const std::string& indent)
81{
82 std::stringstream ss;
83 ss << indent << "size = " << hc.size();
84 size_t i = 0;
85 for (const auto& el : hc) {
86 ss << std::endl << indent << "atom[" << i << "]:" << std::endl
87 << oc_to_string(el.first, indent + OC_TO_STRING_INDENT)
88 << indent << "num[" << i << "]:" << el.second << std::endl;
89 i++;
90 }
91 return ss.str();
92}
93
94std::string oc_to_string(const HandleUCounter& huc, const std::string& indent)
95{
96 std::stringstream ss;
97 ss << indent << "size = " << huc.size();
98 size_t i = 0;
99 for (const auto& el : huc) {
100 ss << std::endl << indent << "atom[" << i << "]:" << std::endl
101 << oc_to_string(el.first, indent + OC_TO_STRING_INDENT)
102 << indent << "num[" << i << "]:" << el.second << std::endl;
103 i++;
104 }
105 return ss.str();
106}
107
80108} // ~namespace opencog
opencog/ure/ActionSelection.h +11 -0
……@@ -24,6 +24,7 @@
2424#define _OPENCOG_ACTIONSELECTION_H_
2525
2626#include <opencog/util/empty_string.h>
27#include <opencog/util/Counter.h>
2728#include <opencog/atoms/base/Handle.h>
2829#include <opencog/atoms/truthvalue/TruthValue.h>
2930
……@@ -35,6 +36,12 @@ namespace opencog
3536//! a map from handles to truth values
3637typedef std::map<Handle, TruthValuePtr> HandleTVMap;
3738
39//! a map from handle to double
40typedef Counter<Handle, double> HandleCounter;
41
42//! a map from handle to unsigned
43typedef Counter<Handle, unsigned> HandleUCounter;
44
3845/**
3946 * Class containing methods to calculate distribution over actions
4047 * given the TruthValue that each action fulfills the objective of
……@@ -97,6 +104,10 @@ std::string oc_to_string(const ActionSelection& asel,
97104 const std::string& indent=empty_string);
98105std::string oc_to_string(const HandleTVMap& h2tv,
99106 const std::string& indent=empty_string);
107std::string oc_to_string(const HandleCounter& hc,
108 const std::string& indent=empty_string);
109std::string oc_to_string(const HandleUCounter& huc,
110 const std::string& indent=empty_string);
100111
101112} // namespace opencog
102113