Main Page | Class Hierarchy | Class List | Directories | File List | Class Members | File Members

buildpropositions.cpp

Go to the documentation of this file.
00001 /*
00002  Modular Psi - A graph tracker of the Parapsychologcal scientific development
00003  Copyright (C) 2005 Leonardo Stern
00004 
00005  This program is free software; you can redistribute it and/or modify it under
00006  the terms of the Common Public License Version 1.0 or (at your option) any later version.
00007 
00008  This program is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY;
00009  without even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
00010  See the Common Public License for more details.
00011 
00012  You should have received a copy of the Common Public License along with this program;
00013 */
00014 
00015 #include <qptrstack.h>
00016 #include "buildpropositions.hpp"
00017 #include "../core/edgelist.hpp"
00018 
00019 BuildPropositions::BuildPropositions(Principal * cl , PropositionGraph* G)
00020 {
00021     EdgeList::iterator ix = G->edges->begin();
00022     while ( ix != G->edges->end()) {
00023          (*ix) -> processBends();
00024          (*ix) -> show();
00025           ++ix;
00026      }
00027 
00028     QDictIterator<Proposition> it ( *G );
00029     for( ; it.current(); ++it )          {
00030         it.current()->show();
00031         it.current()->setTrust((float)-1);
00032     }
00033  
00034         G->operator[]("P1")->setTrust((float)1.0);
00035         calculeTrust(G->operator[]("P1"));
00036 }
00037 
00038 BuildPropositions::calculeTrust(Proposition *p)
00039 {
00040     EdgeList::iterator ix = p->outgoing->begin();
00041     QPtrStack <Proposition> stack;
00042     while ( ix != p->outgoing->end()) {
00043         stack.push((Proposition*)(*ix)->target());
00044         // if trust < 0 (not set), set trust as -1 (not set)
00045         if ((p->trust() < 0) || ((*ix)->trust() < 0))
00046                 (*ix)->setCombinedTrust((float)-1);
00047         else
00048                 (*ix)->setCombinedTrust((float)p->trust() * (*ix)->trust());
00049         if ( (*ix)->combinedTrust() > stack.top()->trust() )
00050                 stack.top()->setTrust((*ix)->combinedTrust());
00051                 ix++;
00052     }
00053     
00054     while (!stack.isEmpty())
00055     {
00056         calculeTrust(stack.top());
00057         stack.pop();
00058     }
00059         
00060 }
00061       
00062 BuildPropositions::~BuildPropositions()
00063 {
00064     //Noop
00065 }
Untitled Document Pesquisa Psi SourceForge.net Logo