OpenCog Framework  Branch: master, revision 6f0b7fc776b08468cf1b74aa9db028f387b4f0c0
 All Classes Namespaces Files Functions Variables Typedefs Enumerations Enumerator Properties Friends Macros Groups Pages
TruthValue.cc
Go to the documentation of this file.
1 /*
2  * opencog/atomspace/TruthValue.cc
3  *
4  * Copyright (C) 2002-2007 Novamente LLC
5  * All Rights Reserved
6  *
7  * Written by Welter Silva <welter@vettalabs.com>
8  * Guilherme Lamacie
9  *
10  * This program is free software; you can redistribute it and/or modify
11  * it under the terms of the GNU Affero General Public License v3 as
12  * published by the Free Software Foundation and including the exceptions
13  * at http://opencog.org/wiki/Licenses
14  *
15  * This program is distributed in the hope that it will be useful,
16  * but WITHOUT ANY WARRANTY; without even the implied warranty of
17  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
18  * GNU General Public License for more details.
19  *
20  * You should have received a copy of the GNU Affero General Public License
21  * along with this program; if not, write to:
22  * Free Software Foundation, Inc.,
23  * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
24  */
25 
26 #include <typeinfo>
27 
28 #include <stdio.h>
29 #include <stdlib.h>
30 
37 #include <opencog/util/platform.h>
38 
39 //#define DPRINTF printf
40 #define DPRINTF(...)
41 
42 using namespace opencog;
43 
44 const strength_t MAX_TRUTH = 1.0f;
45 
47 {
48  static TruthValuePtr instance(std::make_shared<NullTruthValue>());
49  return instance;
50 }
51 
53 {
54  // True, but no confidence.
55  static TruthValuePtr instance(std::make_shared<SimpleTruthValue>(MAX_TRUTH, 0.0));
56  return instance;
57 }
58 
60 {
61  // True, with maximum confidence.
62  static TruthValuePtr instance(std::make_shared<SimpleTruthValue>(MAX_TRUTH, 1.0e35));
63  return instance;
64 }
65 
67 {
68  // False, with maximum confidence.
69  static TruthValuePtr instance(std::make_shared<SimpleTruthValue>(0.0f, 1.0e35));
70  return instance;
71 }
72 
74 {
75  // False, with no confidence.
76  static TruthValuePtr instance(std::make_shared<SimpleTruthValue>(0.0, 0.0));
77  return instance;
78 }
79 
81 {
82  return false;
83 }
84 
86 {
87  TruthValuePtr dtv = DEFAULT_TV();
88  if (dtv.get() == this) return true;
89  if (getType() == dtv->getType() and
90  getMean() == dtv->getMean() and
91  getCount() == dtv->getCount())
92  {
93  return true;
94  }
95  return false;
96 }
const strength_t MAX_TRUTH
Definition: TruthValue.cc:44
virtual bool isDefaultTV() const
Definition: TruthValue.cc:85
virtual count_t getCount() const =0
virtual TruthValueType getType() const =0
static TruthValuePtr TRUE_TV()
Definition: TruthValue.cc:59
std::shared_ptr< TruthValue > TruthValuePtr
Definition: TruthValue.h:85
float strength_t
static TruthValuePtr NULL_TV()
Definition: TruthValue.cc:46
static TruthValuePtr TRIVIAL_TV()
Definition: TruthValue.cc:73
static TruthValuePtr DEFAULT_TV()
Definition: TruthValue.cc:52
static TruthValuePtr FALSE_TV()
Definition: TruthValue.cc:66
virtual bool isNullTv() const
Definition: TruthValue.cc:80
virtual strength_t getMean() const =0