Skip to content

Commit

Permalink
changes for seqpaz
Browse files Browse the repository at this point in the history
  • Loading branch information
jrising committed Nov 10, 2013
1 parent 67e2fa7 commit ded556b
Show file tree
Hide file tree
Showing 25 changed files with 493 additions and 464 deletions.
30 changes: 14 additions & 16 deletions DataTemple/DataTemple/Codeland/Coderack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,7 @@
using PluggerBase.FastSerializer;
using DataTemple.Codeland.SearchTree;
using InOutTools;
using ExamineTools;

namespace DataTemple.Codeland
{
Expand Down Expand Up @@ -118,16 +119,11 @@ public void setReceiver(IMessageReceiver receiver) {
/// Execute the coderack for a given amount of time
/// </summary>
public virtual void Execute(int time, bool debugMode) {
//int origtime = time;
//Profiler profiler = new Profiler();

while (time > 0 && CountTop > 0) {
// && (profiler.GetTime() / 1000 < origtime)) {
bool done = ExecuteOne(debugMode);
if (!done) {
// This shouldn't happen-- we're out of executable codelets
break;
}
int origtime = time;
Profiler profiler = new Profiler();

while (time > 0 && CountTop > 0 && (profiler.GetTime() / 1000 < origtime)) {
time -= ExecuteOne(debugMode);
}

// Check if we're taking the time we say we are
Expand All @@ -147,19 +143,21 @@ public virtual void Execute(int time, bool debugMode) {
else
receiver.Receive("Time Limit Reached.", this);
}

public virtual bool ExecuteOne(bool debugMode)

// return codelet's time
public virtual int ExecuteOne(bool debugMode)
{
Codelet codelet = SelectSalientCodelet();
if (codelet == null)
return false; // nothing to do!
return 1; // nothing to do!

if (!codelet.NeedsEvaluation)
{
// Skip it!
return true;
return 1;
}


int time = codelet.time;
watching = codelet.watched;
bool done = false;

Expand Down Expand Up @@ -197,7 +195,7 @@ public virtual bool ExecuteOne(bool debugMode)

watching = false;

return done;
return time;
}

/// <summary>
Expand Down
28 changes: 19 additions & 9 deletions DataTemple/DataTemple/Codeland/ZippyCoderack.cs
Original file line number Diff line number Diff line change
Expand Up @@ -24,13 +24,20 @@ public class ZippyCoderack : Coderack
/// <summary>
/// Create a new coderack
/// </summary>
public ZippyCoderack(IMessageReceiver receiver, int space)
public ZippyCoderack(IMessageReceiver receiver)
: base()
{
codelets = new SalienceList<Codelet>();
this.receiver = receiver;
}


/// Deserialization constructor
public ZippyCoderack()
: base() {
codelets = new SalienceList<Codelet>();
this.receiver = new StandaloneReceiver(false);
}

/// <summary>
/// Execute the coderack for a given amount of time
/// </summary>
Expand Down Expand Up @@ -74,7 +81,8 @@ public override void Execute(int time, bool debugMode)
time -= 1;
continue;
}


int codetime = codelet.time;
watching = codelet.watched;

// Console.WriteLine("=(" + CountPrime.ToString + "/" + codelets.Count.ToString + ")=> " + codelet.ToString())
Expand Down Expand Up @@ -111,6 +119,7 @@ public override void Execute(int time, bool debugMode)
}

watching = false;
time -= codetime;

// Move back two
values = values.Previous;
Expand Down Expand Up @@ -143,15 +152,15 @@ public override void Execute(int time, bool debugMode)
receiver.Receive("Time Limit Reached.", this);
}

public override bool ExecuteOne(bool debugMode)
public override int ExecuteOne(bool debugMode)
{
SalienceList<Codelet> codelist = (SalienceList<Codelet>)codelets;

// start from the end and move backwards, since new are added to end
LinkedListNode<double> keys = codelist.LinkedKeys.Last;
LinkedListNode<Codelet> values = codelist.LinkedValues.Last;
if (values == null)
return true; // nothing to do!
return 1; // nothing to do!

Codelet codelet = values.Value;
if (values.Previous != null)
Expand All @@ -162,14 +171,15 @@ public override bool ExecuteOne(bool debugMode)
}

if (codelet == null)
return true; // nothing to do!
return 1; // nothing to do!

if (!codelet.NeedsEvaluation)
{
// Skip it!
return true;
return 1;
}


int time = codelet.time;
watching = codelet.watched;
bool done = false;

Expand Down Expand Up @@ -205,7 +215,7 @@ public override bool ExecuteOne(bool debugMode)
keys = keys.Previous;
}

return done;
return time;
}
#endregion
}
Expand Down
12 changes: 5 additions & 7 deletions DataTemple/DataTemple/DataTemple.csproj
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="utf-8"?>
<Project DefaultTargets="Build" ToolsVersion="4.0" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<Project DefaultTargets="Build" ToolsVersion="3.5" xmlns="http://schemas.microsoft.com/developer/msbuild/2003">
<PropertyGroup>
<Configuration Condition=" '$(Configuration)' == '' ">Debug</Configuration>
<Platform Condition=" '$(Platform)' == '' ">x86</Platform>
Expand Down Expand Up @@ -92,7 +92,6 @@
<Compile Include="AgentEvaluate\CallAgentWrapper.cs" />
<Compile Include="AgentEvaluate\Interpreter.cs" />
<Compile Include="Variables\OutputVariables.cs" />
<Compile Include="Matching\BestScore.cs" />
<Compile Include="Matching\Concept.cs" />
<Compile Include="Matching\ConceptTranslator.cs" />
<Compile Include="Matching\Datum.cs" />
Expand All @@ -102,7 +101,6 @@
<Compile Include="Matching\MatchProduceAgent.cs" />
<Compile Include="Matching\Memory.cs" />
<Compile Include="Matching\PatternTemplateSource.cs" />
<Compile Include="Matching\ProbableStrength.cs" />
<Compile Include="Matching\Relations.cs" />
<Compile Include="Matching\StarEater.cs" />
<Compile Include="Matching\StarUtilities.cs" />
Expand All @@ -122,14 +120,14 @@
</ItemGroup>
<Import Project="$(MSBuildBinPath)\Microsoft.CSharp.targets" />
<ItemGroup>
<ProjectReference Include="..\..\Grammarian\Grammarian.csproj">
<Project>{5B36F670-EB0A-41AC-A6F5-F2E2B53DF732}</Project>
<Name>Grammarian</Name>
</ProjectReference>
<ProjectReference Include="..\..\PluggerBase\PluggerBase\PluggerBase.csproj">
<Project>{4D2297C0-FE51-4056-80CD-A72469075B10}</Project>
<Name>PluggerBase</Name>
</ProjectReference>
<ProjectReference Include="..\..\Grammarian\Grammarian.csproj">
<Project>{5B36F670-EB0A-41AC-A6F5-F2E2B53DF732}</Project>
<Name>Grammarian</Name>
</ProjectReference>
<ProjectReference Include="..\..\GenericTools\GenericTools.csproj">
<Project>{7AEB4A15-8603-4675-B636-98DA6292291A}</Project>
<Name>GenericTools</Name>
Expand Down
4 changes: 2 additions & 2 deletions DataTemple/DataTemple/Main.cs
Original file line number Diff line number Diff line change
Expand Up @@ -213,7 +213,7 @@ public static void Main(string[] args)
break;
}
}

if (dicta.Count != 0)
main.DoMatching(dicta, input);
else if (!acted)
Expand All @@ -240,7 +240,7 @@ public void Initialize(string config) {
tagger = new POSTagger(plugenv);
parser = new GrammarParser(plugenv);

coderack = new ZippyCoderack(this, 10000000);
coderack = new ZippyCoderack(this);
memory = new Memory();

basectx = new Context(coderack);
Expand Down
Loading

0 comments on commit ded556b

Please sign in to comment.