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) \
$(ADDITIONAL_MODULES)
# load_test_files/1 should make this useless, but I cannot find how to use it
TEST_MODULES=$(wildcard $(MODULES:.pl=.plt))
VERSION=4.0.$(shell date +%Y%m%d)
$(foreach var, CC PLBASE PLCFLAGS PLLDFLAGS PLLIB, \
$(eval \
......@@ -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.h 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/
cp modules/sbml/examples/* tmp/biocham/modules/sbml/examples/
tar -czf biocham-src.tar.gz -C tmp/ biocham/
......@@ -109,3 +111,6 @@ test-biocham-src: biocham-src.tar.gz
tar -xf biocham-src.tar.gz -C tmp/
make -C tmp/biocham/
rm -rf tmp/
distribute: biocham-src.tar.gz
./distribute.sh "$(VERSION)"
......@@ -8,7 +8,7 @@
is_influence_model/0,
check_influence_model/0,
list_model_influences/0,
influence/5
influence/6
]
).
......@@ -89,14 +89,28 @@ prolog:error_message(not_an_influence_model) -->
['Not an influence model'].
influence(InfluenceRule, PositiveInputs, NegativeInputs, Sign, Output) :-
devdoc('builds or decomposes an influence rule.'
),
influence(InfluenceRule, Force, PositiveInputs, NegativeInputs, Sign, Output) :-
devdoc(
'builds or decomposes an influence rule.'
),
once((
Force = 1,
(
var(InfluenceRule)
->
true
;
InfluenceRule \= (_ for _)
),
BasicInfluenceRule = InfluenceRule
;
InfluenceRule = (Force for BasicInfluenceRule)
)),
once((
InfluenceRule = (Inputs -> Output),
BasicInfluenceRule = (Inputs -> Output),
Sign = +
;
InfluenceRule = (Inputs -< Output),
BasicInfluenceRule = (Inputs -< Output),
Sign = -
)),
inputs(Inputs, PositiveInputs, NegativeInputs).
......
......@@ -24,57 +24,57 @@ test(
test(
'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(
'influence builds with positive inputs',
[Influence == (b -< c)]
) :-
influence(Influence, [b], [], -, c).
influence(Influence, 1, [b], [], -, c).
test(
'influence builds with negative inputs',
[Influence == (\ a -< a)]
) :-
influence(Influence, [], [a], -, a).
influence(Influence, 1, [], [a], -, a).
test(
'influence builds with no inputs',
[Influence == ('_' -> a)]
) :-
influence(Influence, [], [], +, a).
influence(Influence, 1, [], [], +, a).
test(
'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(
'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(
'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).
......@@ -3,6 +3,7 @@
[
influence_predicate/1,
influence/1,
basic_influence/1,
inputs/1,
enumeration/1,
op(1050, xfx, (->)),
......@@ -13,6 +14,9 @@
).
influence_predicate(_ for Reaction) :-
influence_predicate(Reaction).
influence_predicate(_ -> _).
influence_predicate(_ -< _).
......@@ -21,12 +25,23 @@ influence_predicate(_ -< _).
:- 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),
object(Output).
influence(Inputs -< Output) :-
basic_influence(Inputs -< Output) :-
inputs(Inputs),
object(Output).
......
......@@ -8,7 +8,7 @@
patch_solution/2,
kinetics/1,
arithmetic_expression/1,
op(800, xfx, for),
op(1100, xfx, for),
op(700, xfx, <=),
op(750, xfx, =>),
op(750, xfx, <=>),
......@@ -18,7 +18,8 @@
).
reaction_predicate(_ for _).
reaction_predicate(_ for Reaction) :-
reaction_predicate(Reaction).
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