fathom 0.3.7 → 0.5.0
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/.autotest +7 -5
- data/.document +2 -2
- data/Gemfile +9 -10
- data/{LICENSE → LICENSE.txt} +1 -1
- data/README.md +29 -90
- data/Rakefile +34 -32
- data/VERSION +1 -1
- data/fathom.gemspec +105 -0
- data/features/fathom.feature +26 -0
- data/features/step_definitions/fathom_steps.rb +23 -0
- data/features/support/env.rb +13 -0
- data/lib/ext/array.rb +6 -2
- data/lib/ext/string.rb +86 -7
- data/lib/fathom.rb +51 -88
- data/lib/fathom/behaviors/attribute_system.rb +91 -0
- data/lib/fathom/behaviors/context_behavior.rb +28 -0
- data/lib/fathom/behaviors/plugins.rb +16 -0
- data/lib/fathom/contexts/network_population.rb +47 -0
- data/lib/fathom/contexts/network_traversal.rb +4 -0
- data/lib/fathom/data/adjacency_matrix.rb +27 -0
- data/lib/fathom/data/definition.rb +22 -0
- data/lib/fathom/data/edge.rb +58 -0
- data/lib/fathom/data/network.rb +35 -0
- data/lib/fathom/data/outcome.rb +30 -0
- data/lib/fathom/data/property.rb +31 -0
- data/lib/fathom/data/variable.rb +59 -0
- data/lib/fathom/roles/general_graph_tools.rb +87 -0
- data/lib/fathom/roles/network_builder.rb +61 -0
- data/spec/fathom/behaviors/attribute_system_spec.rb +141 -0
- data/spec/fathom/behaviors/context_behavior_spec.rb +15 -0
- data/spec/fathom/behaviors/plugins_spec.rb +80 -0
- data/spec/fathom/contexts/network_population_spec.rb +55 -0
- data/spec/fathom/contexts/network_traversal_spec.rb +11 -0
- data/spec/fathom/data/adjacency_matrix_spec.rb +42 -0
- data/spec/fathom/data/definition_spec.rb +19 -0
- data/spec/fathom/data/edge_spec.rb +77 -0
- data/spec/fathom/data/network_spec.rb +72 -0
- data/spec/fathom/data/outcome_spec.rb +17 -0
- data/spec/fathom/data/property_spec.rb +17 -0
- data/spec/fathom/data/variable_spec.rb +101 -0
- data/spec/fathom/ext/array_spec.rb +17 -0
- data/spec/fathom/ext/string_spec.rb +90 -0
- data/spec/fathom/roles/general_graph_tools_spec.rb +95 -0
- data/spec/fathom/roles/network_builder_spec.rb +90 -0
- data/spec/fathom_spec.rb +28 -49
- data/spec/spec_helper.rb +7 -11
- data/spec/support/context_behavior.rb +14 -0
- data/spec/support/custom_matchers.rb +12 -0
- data/spec/support/files.rb +8 -0
- data/spec/support/network.yml +42 -0
- metadata +133 -174
- data/.bundle/config +0 -2
- data/.gitignore +0 -6
- data/Gemfile.lock +0 -42
- data/TODO.md +0 -127
- data/autotest/discover.rb +0 -1
- data/lib/ext/faster_csv.rb +0 -1
- data/lib/ext/open_struct.rb +0 -17
- data/lib/fathom/agent.rb +0 -48
- data/lib/fathom/agent/agent_cluster.rb +0 -23
- data/lib/fathom/agent/properties.rb +0 -48
- data/lib/fathom/archive/causal_graph.rb +0 -12
- data/lib/fathom/archive/concept.rb +0 -83
- data/lib/fathom/archive/conditional_probability_matrix.rb +0 -119
- data/lib/fathom/archive/inverter.rb +0 -20
- data/lib/fathom/archive/n2.rb +0 -198
- data/lib/fathom/archive/n3.rb +0 -119
- data/lib/fathom/archive/node.rb +0 -97
- data/lib/fathom/archive/noodle.rb +0 -136
- data/lib/fathom/archive/scratch.rb +0 -45
- data/lib/fathom/distributions.rb +0 -8
- data/lib/fathom/distributions/discrete_gaussian.rb +0 -44
- data/lib/fathom/distributions/discrete_uniform.rb +0 -25
- data/lib/fathom/distributions/gaussian.rb +0 -46
- data/lib/fathom/distributions/uniform.rb +0 -35
- data/lib/fathom/import.rb +0 -85
- data/lib/fathom/import/csv_import.rb +0 -59
- data/lib/fathom/import/import_node.rb +0 -17
- data/lib/fathom/import/yaml_import.rb +0 -74
- data/lib/fathom/knowledge_base.rb +0 -46
- data/lib/fathom/knowledge_base/search.rb +0 -19
- data/lib/fathom/monte_carlo_set.rb +0 -152
- data/lib/fathom/node.rb +0 -139
- data/lib/fathom/node/belief_node.rb +0 -121
- data/lib/fathom/node/cpm_node.rb +0 -100
- data/lib/fathom/node/data_collection.rb +0 -97
- data/lib/fathom/node/data_node.rb +0 -22
- data/lib/fathom/node/decision.rb +0 -11
- data/lib/fathom/node/discrete_node.rb +0 -41
- data/lib/fathom/node/fact.rb +0 -24
- data/lib/fathom/node/mc_node.rb +0 -70
- data/lib/fathom/node/node_extensions/enforced_name.rb +0 -12
- data/lib/fathom/node/node_extensions/numeric_methods.rb +0 -68
- data/lib/fathom/node/plausible_range.rb +0 -98
- data/lib/fathom/simulation.rb +0 -59
- data/lib/fathom/simulation/tick_methods.rb +0 -25
- data/lib/fathom/simulation/tick_simulation.rb +0 -12
- data/lib/fathom/value_description.rb +0 -79
- data/lib/options_hash.rb +0 -186
- data/spec/ext/array_spec.rb +0 -10
- data/spec/ext/faster_csv_spec.rb +0 -10
- data/spec/ext/open_struct_spec.rb +0 -20
- data/spec/ext/string_spec.rb +0 -7
- data/spec/fathom/agent/agent_cluster_spec.rb +0 -17
- data/spec/fathom/agent_spec.rb +0 -51
- data/spec/fathom/distributions/discrete_gaussian_spec.rb +0 -64
- data/spec/fathom/distributions/discrete_uniform_spec.rb +0 -0
- data/spec/fathom/distributions/gaussian_spec.rb +0 -64
- data/spec/fathom/distributions/uniform_spec.rb +0 -0
- data/spec/fathom/import/csv_import_spec.rb +0 -52
- data/spec/fathom/import/import_node_spec.rb +0 -10
- data/spec/fathom/import/yaml_import_spec.rb +0 -73
- data/spec/fathom/import_spec.rb +0 -36
- data/spec/fathom/knowledge_base_spec.rb +0 -20
- data/spec/fathom/monte_carlo_set_spec.rb +0 -149
- data/spec/fathom/node/belief_node_spec.rb +0 -180
- data/spec/fathom/node/cpm_node_spec.rb +0 -144
- data/spec/fathom/node/data_collection_spec.rb +0 -26
- data/spec/fathom/node/data_node_spec.rb +0 -102
- data/spec/fathom/node/decision_spec.rb +0 -15
- data/spec/fathom/node/discrete_node_spec.rb +0 -56
- data/spec/fathom/node/fact_spec.rb +0 -33
- data/spec/fathom/node/mc_node_spec.rb +0 -66
- data/spec/fathom/node/node_extensions/enforced_name_spec.rb +0 -15
- data/spec/fathom/node/node_extensions/numeric_methods_spec.rb +0 -124
- data/spec/fathom/node/plausible_range_spec.rb +0 -151
- data/spec/fathom/node_spec.rb +0 -172
- data/spec/fathom/simulation/tick_simulation_spec.rb +0 -32
- data/spec/fathom/simulation_spec.rb +0 -24
- data/spec/fathom/value_description_spec.rb +0 -70
- data/spec/support/demo.yml +0 -17
- data/spec/support/demo_agent.rb +0 -8
- data/spec/support/dummy_numeric_node.rb +0 -8
- data/spec/support/fact.yml +0 -11
|
@@ -1,32 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../../spec_helper')
|
|
2
|
-
|
|
3
|
-
include Fathom
|
|
4
|
-
|
|
5
|
-
describe TickSimulation do
|
|
6
|
-
|
|
7
|
-
before do
|
|
8
|
-
@da = DemoAgent.new
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should process with n ticks" do
|
|
12
|
-
@da.should_receive(:on_tick).exactly(3).times.and_return(true)
|
|
13
|
-
s = TickSimulation.new(@da)
|
|
14
|
-
s.process(3)
|
|
15
|
-
end
|
|
16
|
-
|
|
17
|
-
it "should expose the number of ticks designed and executed after processing" do
|
|
18
|
-
s = TickSimulation.new(@da)
|
|
19
|
-
s.process(4)
|
|
20
|
-
s.ticks_designed.should eql(4)
|
|
21
|
-
s.ticks_executed.should eql(4)
|
|
22
|
-
end
|
|
23
|
-
|
|
24
|
-
# Any calls coming top down (from the simulator or the agent cluster), will need a standard signature to
|
|
25
|
-
# make things interchangeable. We use the simulator itself, which is a bit fat, but will work for the short
|
|
26
|
-
# term.
|
|
27
|
-
it "should pass the simulator on tick" do
|
|
28
|
-
s = TickSimulation.new(@da)
|
|
29
|
-
@da.should_receive(:on_tick).with(s)
|
|
30
|
-
s.process(1)
|
|
31
|
-
end
|
|
32
|
-
end
|
|
@@ -1,24 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
-
|
|
3
|
-
include Fathom
|
|
4
|
-
|
|
5
|
-
describe Simulation do
|
|
6
|
-
before do
|
|
7
|
-
@da = DemoAgent.new
|
|
8
|
-
@s = Simulation.new(@da)
|
|
9
|
-
end
|
|
10
|
-
|
|
11
|
-
it "should initialize with a list of agents" do
|
|
12
|
-
s = Simulation.new(1,2,3)
|
|
13
|
-
s.agents.should eql([1,2,3])
|
|
14
|
-
end
|
|
15
|
-
|
|
16
|
-
it "should register agent callbacks for simpler execution" do
|
|
17
|
-
@da.should_receive(:on_tick).and_return(true)
|
|
18
|
-
@s.tick
|
|
19
|
-
end
|
|
20
|
-
|
|
21
|
-
it "should publish agent subscription to various callbacks to facilitate agent-to-agent communication" do
|
|
22
|
-
@s.agents_using_tick.should eql([@da])
|
|
23
|
-
end
|
|
24
|
-
end
|
|
@@ -1,70 +0,0 @@
|
|
|
1
|
-
require File.expand_path(File.dirname(__FILE__) + '/../spec_helper')
|
|
2
|
-
|
|
3
|
-
include Fathom
|
|
4
|
-
|
|
5
|
-
describe ValueDescription do
|
|
6
|
-
|
|
7
|
-
before(:all) do
|
|
8
|
-
@r1 = PlausibleRange.new(:min => 1, :max => 3, :name => 'r1')
|
|
9
|
-
@r2 = PlausibleRange.new(:min => 1, :max => 3, :name => 'r2')
|
|
10
|
-
@r3 = PlausibleRange.new(:min => 1, :max => 3, :name => 'r3')
|
|
11
|
-
@r4 = PlausibleRange.new(:min => 1, :max => 3, :name => 'r4')
|
|
12
|
-
end
|
|
13
|
-
|
|
14
|
-
before do
|
|
15
|
-
@vd = ValueDescription.new
|
|
16
|
-
end
|
|
17
|
-
|
|
18
|
-
it "should be able to initialize with no nodes" do
|
|
19
|
-
@vd.nodes.should be_empty
|
|
20
|
-
end
|
|
21
|
-
|
|
22
|
-
it "should be able to take a set of nodes to work with" do
|
|
23
|
-
vd = ValueDescription.new @r1, @r2, @r3, @r4
|
|
24
|
-
vd.nodes.should eql([@r1, @r2, @r3, @r4])
|
|
25
|
-
end
|
|
26
|
-
|
|
27
|
-
it "should respond to the names of the nodes being added" do
|
|
28
|
-
vd = ValueDescription.new @r1, @r2
|
|
29
|
-
vd.r1.should be_a(Float)
|
|
30
|
-
vd.r2.should be_a(Float)
|
|
31
|
-
end
|
|
32
|
-
|
|
33
|
-
it "should be able to add a node with add_node" do
|
|
34
|
-
@vd.add_node(@r3)
|
|
35
|
-
@vd.r3.should be_a(Float)
|
|
36
|
-
end
|
|
37
|
-
|
|
38
|
-
it "should be able to add a node with an alternative value method" do
|
|
39
|
-
@vd.add_node(@r3, :name)
|
|
40
|
-
@vd.r3.should eql('r3')
|
|
41
|
-
end
|
|
42
|
-
|
|
43
|
-
it "should be able to initialize with a hash, to define the value methods" do
|
|
44
|
-
vd = ValueDescription.new @r1 => :rand, @r2 => :name
|
|
45
|
-
vd.r1.should be_a(Float)
|
|
46
|
-
vd.r2.should eql('r2')
|
|
47
|
-
end
|
|
48
|
-
|
|
49
|
-
it "should convert node names to lower case, underscore values" do
|
|
50
|
-
pr = PlausibleRange.new(:min => 1, :max => 3, :name => 'Test Node')
|
|
51
|
-
vd = ValueDescription.new pr => :name
|
|
52
|
-
vd.test_node.should eql('Test Node')
|
|
53
|
-
end
|
|
54
|
-
|
|
55
|
-
it "should respond to process, which by default just adds up the values of the nodes" do
|
|
56
|
-
vd = ValueDescription.new @r1, @r2
|
|
57
|
-
output = vd.process
|
|
58
|
-
sum = vd.last_process.values.inject(0.0) {|s, e| s += e}
|
|
59
|
-
output.should eql(sum)
|
|
60
|
-
end
|
|
61
|
-
|
|
62
|
-
it "should be able to take an optional block at initialization" do
|
|
63
|
-
vd = ValueDescription.new(@r1 => :name) {|obj|
|
|
64
|
-
obj.r1
|
|
65
|
-
}
|
|
66
|
-
output = vd.process
|
|
67
|
-
output.should eql('r1')
|
|
68
|
-
end
|
|
69
|
-
|
|
70
|
-
end
|
data/spec/support/demo.yml
DELETED
data/spec/support/demo_agent.rb
DELETED