Skip to content

Commit

Permalink
Fix examples to use the new interfaces
Browse files Browse the repository at this point in the history
  • Loading branch information
linas committed Oct 3, 2013
1 parent 75d3dba commit 6c0bba4
Show file tree
Hide file tree
Showing 5 changed files with 22 additions and 22 deletions.
20 changes: 7 additions & 13 deletions examples/hopfield/HopfieldServer.cc
Original file line number Diff line number Diff line change
Expand Up @@ -229,8 +229,6 @@ HopfieldServer::HopfieldServer()
HopfieldServer::~HopfieldServer()
{
unloadModule("libattention.so");
//delete importUpdateAgent;
//delete hebUpdateAgent;
delete rng;
}

Expand All @@ -239,25 +237,21 @@ void HopfieldServer::init(int width, int height, int numLinks)
loadModule("libattention.so");

//CogServer& cogserver = static_cast<CogServer&>(server());
importUpdateAgent = static_cast<ImportanceUpdatingAgent*>(
this->createAgent(ImportanceUpdatingAgent::info().id, true));
importUpdateAgent = createAgent<ImportanceUpdatingAgent>(true);
if (options->updateMethod == HopfieldOptions::CONJUNCTION) {
hebUpdateAgent = static_cast<HebbianUpdatingAgent*>(
this->createAgent(HebbianUpdatingAgent::info().id, true));
hebUpdateAgent = createAgent<HebbianUpdatingAgent>(true);
} else {
storkeyAgent = new StorkeyAgent(*this);
storkeyAgent = std::make_shared<StorkeyAgent>(*this);
}
imprintAgent = new ImprintAgent(*this);
imprintAgent = std::make_shared<ImprintAgent>(*this);
startAgent(imprintAgent);
diffuseAgent = static_cast<ImportanceDiffusionAgent*>(
this->createAgent(ImportanceDiffusionAgent::info().id, true));
diffuseAgent = createAgent<ImportanceDiffusionAgent>(true);
diffuseAgent->setDiffusionThreshold(options->diffusionThreshold);
diffuseAgent->setMaxSpreadPercentage(options->maxSpreadPercentage);
diffuseAgent->setSpreadDecider(ImportanceDiffusionAgent::HYPERBOLIC,
options->deciderFunctionShape);
// spreadAgent = static_cast<ImportanceSpreadingAgent*>(this->createAgent(ImportanceSpreadingAgent::info().id, true));
forgetAgent = static_cast<ForgettingAgent*>(
this->createAgent(ForgettingAgent::info().id, true));
// spreadAgent = createAgent<ImportanceSpreadingAgent>(true);
forgetAgent = createAgent<ForgettingAgent>(true);

if (options->verboseLevel) {
importUpdateAgent->getLogger()->setPrintToStdoutFlag (true);
Expand Down
14 changes: 7 additions & 7 deletions examples/hopfield/HopfieldServer.h
Original file line number Diff line number Diff line change
Expand Up @@ -93,13 +93,13 @@ class HopfieldServer : public CogServer
//! Amount of stimulus to apply across a pattern
stim_t patternStimulus;

ForgettingAgent *forgetAgent;
HebbianUpdatingAgent *hebUpdateAgent;
StorkeyAgent *storkeyAgent;
ImprintAgent *imprintAgent;
ImportanceDiffusionAgent *diffuseAgent;
ImportanceSpreadingAgent *spreadAgent;
ImportanceUpdatingAgent *importUpdateAgent;
ForgettingAgentPtr forgetAgent;
HebbianUpdatingAgentPtr hebUpdateAgent;
StorkeyAgentPtr storkeyAgent;
ImprintAgentPtr imprintAgent;
ImportanceDiffusionAgentPtr diffuseAgent;
ImportanceSpreadingAgentPtr spreadAgent;
ImportanceUpdatingAgentPtr importUpdateAgent;
HopfieldOptions *options;

int width, height, links;
Expand Down
6 changes: 4 additions & 2 deletions examples/hopfield/ImprintAgent.cc
Original file line number Diff line number Diff line change
Expand Up @@ -71,7 +71,9 @@ Logger* ImprintAgent::getLogger()
}

void ImprintAgent::setPattern(Pattern _epsilon)
{ epsilon = _epsilon; }
{
epsilon = _epsilon;
}

void ImprintAgent::run()
{
Expand All @@ -82,7 +84,7 @@ void ImprintAgent::run()
assert(n == epsilon.size());
stim_t stimulusAmount = 1;
if (epsilon.activity() > 0) {
stimulusAmount = a.getAttentionBank().getSTI(this) / epsilon.activity();
stimulusAmount = a.getAttentionBank().getSTI(shared_from_this()) / epsilon.activity();
if (stimulusAmount == 0) stimulusAmount++;
}
for (int i = 0; i < n; i++) {
Expand Down
2 changes: 2 additions & 0 deletions examples/hopfield/ImprintAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -83,6 +83,8 @@ class ImprintAgent : public Agent

}; // class

typedef std::shared_ptr<ImprintAgent> ImprintAgentPtr;

} // namespace

#endif // _OPENCOG_IMPRINT_AGENT_H
2 changes: 2 additions & 0 deletions examples/hopfield/StorkeyAgent.h
Original file line number Diff line number Diff line change
Expand Up @@ -105,6 +105,8 @@ class StorkeyAgent : public Agent

}; // class

typedef std::shared_ptr<StorkeyAgent> StorkeyAgentPtr;

} // namespace

#endif // _OPENCOG_STORKEY_AGENT_H

0 comments on commit 6c0bba4

Please sign in to comment.