Commit 9b0d5a25 authored by Thierry Martinez's avatar Thierry Martinez

Influence with forces

parent 5fe362d4
...@@ -3,6 +3,7 @@ MODULES=$(shell sed -n -E 's/^[+-] (.*\.pl)$$/\1/p' toc.org) \ ...@@ -3,6 +3,7 @@ MODULES=$(shell sed -n -E 's/^[+-] (.*\.pl)$$/\1/p' toc.org) \
$(ADDITIONAL_MODULES) $(ADDITIONAL_MODULES)
# load_test_files/1 should make this useless, but I cannot find how to use it # load_test_files/1 should make this useless, but I cannot find how to use it
TEST_MODULES=$(wildcard $(MODULES:.pl=.plt)) TEST_MODULES=$(wildcard $(MODULES:.pl=.plt))
VERSION=4.0.$(shell date +%Y%m%d)
$(foreach var, CC PLBASE PLCFLAGS PLLDFLAGS PLLIB, \ $(foreach var, CC PLBASE PLCFLAGS PLLDFLAGS PLLIB, \
$(eval \ $(eval \
...@@ -99,6 +100,7 @@ biocham-src.tar.gz: $(MODULES) $(TEST_MODULES) toc.org Makefile ...@@ -99,6 +100,7 @@ biocham-src.tar.gz: $(MODULES) $(TEST_MODULES) toc.org Makefile
cp modules/sbml/sbml_swiprolog.c tmp/biocham/modules/sbml/ cp modules/sbml/sbml_swiprolog.c tmp/biocham/modules/sbml/
cp modules/sbml/sbml_swiprolog.h tmp/biocham/modules/sbml/ cp modules/sbml/sbml_swiprolog.h tmp/biocham/modules/sbml/
cp modules/sbml/sbml_utils.pl tmp/biocham/modules/sbml/ cp modules/sbml/sbml_utils.pl tmp/biocham/modules/sbml/
cp modules/sbml/Makefile tmp/biocham/modules/sbml/
mkdir tmp/biocham/modules/sbml/examples/ mkdir tmp/biocham/modules/sbml/examples/
cp modules/sbml/examples/* tmp/biocham/modules/sbml/examples/ cp modules/sbml/examples/* tmp/biocham/modules/sbml/examples/
tar -czf biocham-src.tar.gz -C tmp/ biocham/ tar -czf biocham-src.tar.gz -C tmp/ biocham/
...@@ -109,3 +111,6 @@ test-biocham-src: biocham-src.tar.gz ...@@ -109,3 +111,6 @@ test-biocham-src: biocham-src.tar.gz
tar -xf biocham-src.tar.gz -C tmp/ tar -xf biocham-src.tar.gz -C tmp/
make -C tmp/biocham/ make -C tmp/biocham/
rm -rf tmp/ rm -rf tmp/
distribute: biocham-src.tar.gz
./distribute.sh "$(VERSION)"
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
is_influence_model/0, is_influence_model/0,
check_influence_model/0, check_influence_model/0,
list_model_influences/0, list_model_influences/0,
influence/5 influence/6
] ]
). ).
...@@ -89,14 +89,28 @@ prolog:error_message(not_an_influence_model) --> ...@@ -89,14 +89,28 @@ prolog:error_message(not_an_influence_model) -->
['Not an influence model']. ['Not an influence model'].
influence(InfluenceRule, PositiveInputs, NegativeInputs, Sign, Output) :- influence(InfluenceRule, Force, PositiveInputs, NegativeInputs, Sign, Output) :-
devdoc('builds or decomposes an influence rule.' devdoc(
), 'builds or decomposes an influence rule.'
),
once((
Force = 1,
(
var(InfluenceRule)
->
true
;
InfluenceRule \= (_ for _)
),
BasicInfluenceRule = InfluenceRule
;
InfluenceRule = (Force for BasicInfluenceRule)
)),
once(( once((
InfluenceRule = (Inputs -> Output), BasicInfluenceRule = (Inputs -> Output),
Sign = + Sign = +
; ;
InfluenceRule = (Inputs -< Output), BasicInfluenceRule = (Inputs -< Output),
Sign = - Sign = -
)), )),
inputs(Inputs, PositiveInputs, NegativeInputs). inputs(Inputs, PositiveInputs, NegativeInputs).
......
...@@ -24,57 +24,57 @@ test( ...@@ -24,57 +24,57 @@ test(
test( test(
'influence builds', 'influence builds',
[Influence == (a, b \ c -> d)] [Influence == (2 for a, b \ c -> d)]
) :- ) :-
influence(Influence, [a, b], [c], +, d). influence(Influence, 2, [a, b], [c], +, d).
test( test(
'influence builds with positive inputs', 'influence builds with positive inputs',
[Influence == (b -< c)] [Influence == (b -< c)]
) :- ) :-
influence(Influence, [b], [], -, c). influence(Influence, 1, [b], [], -, c).
test( test(
'influence builds with negative inputs', 'influence builds with negative inputs',
[Influence == (\ a -< a)] [Influence == (\ a -< a)]
) :- ) :-
influence(Influence, [], [a], -, a). influence(Influence, 1, [], [a], -, a).
test( test(
'influence builds with no inputs', 'influence builds with no inputs',
[Influence == ('_' -> a)] [Influence == ('_' -> a)]
) :- ) :-
influence(Influence, [], [], +, a). influence(Influence, 1, [], [], +, a).
test( test(
'influence destructs', 'influence destructs',
[ [
result(PositiveInputs, NegativeInputs, Sign, Output) result(Force, PositiveInputs, NegativeInputs, Sign, Output)
== ==
result([a, b], [c], +, d) result(2, [a, b], [c], +, d)
] ]
) :- ) :-
influence((a, b \ c -> d), PositiveInputs, NegativeInputs, Sign, Output). influence((2 for a, b \ c -> d), Force, PositiveInputs, NegativeInputs, Sign, Output).
test( test(
'influence destructs with positive inputs', 'influence destructs with positive inputs',
[ [
result(PositiveInputs, NegativeInputs, Sign, Output) result(Force, PositiveInputs, NegativeInputs, Sign, Output)
== ==
result([b], [], -, c) result(1, [b], [], -, c)
] ]
) :- ) :-
influence((b -< c), PositiveInputs, NegativeInputs, Sign, Output). influence((b -< c), Force, PositiveInputs, NegativeInputs, Sign, Output).
test( test(
'influence destructs with negative inputs', 'influence destructs with negative inputs',
[ [
result(PositiveInputs, NegativeInputs, Sign, Output) result(Force, PositiveInputs, NegativeInputs, Sign, Output)
== ==
result([], [a], -, a) result(1, [], [a], -, a)
] ]
) :- ) :-
influence((\ a -< a), PositiveInputs, NegativeInputs, Sign, Output). influence((\ a -< a), Force, PositiveInputs, NegativeInputs, Sign, Output).
:- end_tests(influence_editor). :- end_tests(influence_editor).
...@@ -3,6 +3,7 @@ ...@@ -3,6 +3,7 @@
[ [
influence_predicate/1, influence_predicate/1,
influence/1, influence/1,
basic_influence/1,
inputs/1, inputs/1,
enumeration/1, enumeration/1,
op(1050, xfx, (->)), op(1050, xfx, (->)),
...@@ -13,6 +14,9 @@ ...@@ -13,6 +14,9 @@
). ).
influence_predicate(_ for Reaction) :-
influence_predicate(Reaction).
influence_predicate(_ -> _). influence_predicate(_ -> _).
influence_predicate(_ -< _). influence_predicate(_ -< _).
...@@ -21,12 +25,23 @@ influence_predicate(_ -< _). ...@@ -21,12 +25,23 @@ influence_predicate(_ -< _).
:- grammar(influence). :- grammar(influence).
influence(Inputs -> Output) :- influence(Force for BasicInfluence) :-
arithmetic_expression(Force),
basic_influence(BasicInfluence).
influence(BasicInfluence) :-
basic_influence(BasicInfluence).
:- grammar(basic_influence).
basic_influence(Inputs -> Output) :-
inputs(Inputs), inputs(Inputs),
object(Output). object(Output).
influence(Inputs -< Output) :- basic_influence(Inputs -< Output) :-
inputs(Inputs), inputs(Inputs),
object(Output). object(Output).
......
...@@ -8,7 +8,7 @@ ...@@ -8,7 +8,7 @@
patch_solution/2, patch_solution/2,
kinetics/1, kinetics/1,
arithmetic_expression/1, arithmetic_expression/1,
op(800, xfx, for), op(1100, xfx, for),
op(700, xfx, <=), op(700, xfx, <=),
op(750, xfx, =>), op(750, xfx, =>),
op(750, xfx, <=>), op(750, xfx, <=>),
...@@ -18,7 +18,8 @@ ...@@ -18,7 +18,8 @@
). ).
reaction_predicate(_ for _). reaction_predicate(_ for Reaction) :-
reaction_predicate(Reaction).
reaction_predicate(_ => _). reaction_predicate(_ => _).
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment