Skip to content
GitLab
Projects
Groups
Snippets
/
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Lifeware
biocham
Commits
c016a0a5
Commit
c016a0a5
authored
Jan 16, 2020
by
HEMERY Mathieu
Browse files
Add the naming convention during compilation
parent
a27ff232
Changes
1
Hide whitespace changes
Inline
Side-by-side
gpac.pl
View file @
c016a0a5
...
...
@@ -97,7 +97,9 @@ compile_from_expression(Expr, Input, Output) :-
'Switch between a brutal or a lazy negation'
),
expression_to_PIVP
(
Expr
,
PIVP
),
main_compiler
(
PIVP
,
Input
,
Output
).
PIVP
=
[
N
,
_PODE
,
_IC
],
abstract_names
(
N
,
Output
,
Name_list
),
main_compiler
(
PIVP
,
Name_list
,
Input
).
:-
doc
(
'
\\begin{example} Compilation of the expression 4+time^2:\n
...
...
@@ -313,8 +315,9 @@ compile_from_pivp(PIVP, Input, Output) :-
_Reduction
,
'Determine if the binomial reduction has to be performed'
),
format_pivp
(
PIVP
,
P
,
Name_list
),
main_compiler
(
P
,
Name_list
,
Input
,
Output
).
sort_output
(
PIVP
,
Output
,
PIVP_sorted
),
format_pivp
(
PIVP_sorted
,
P
,
Name_list
),
main_compiler
(
P
,
Name_list
,
Input
).
:-
devdoc
(
'\\begin{todo} Compilation of the cosine function as a function of time defined as the solution of a PIVP)\n
\\texttt{
...
...
@@ -339,7 +342,7 @@ compile_from_pivp(PIVP, Input, Output) :-
'
).
%! main_compiler(+PIVP_list, +Name_list, +Input
, +Output
)
%! main_compiler(+PIVP_list, +Name_list, +Input)
%
% Compile a PIVP_list, this predicate dispatch the various options of compilation
% it first check if the PIVP should be reduce to a binomial form
...
...
@@ -347,7 +350,7 @@ compile_from_pivp(PIVP, Input, Output) :-
% when Input is not time it then call g_to_c_PIVP/3.
% and finally make a call to compile_to_biocham_model to make the final implementation
main_compiler
(
PIVP_input
,
Name_list_raw
,
Input
,
Output
):-
main_compiler
(
PIVP_input
,
Name_list_raw
,
Input
):-
clear_model
,
get_option
(
fast_rate
,
Fast
),
get_option
(
lazy_negatives
,
Lazyness
),
...
...
@@ -359,7 +362,7 @@ main_compiler(PIVP_input, Name_list_raw, Input, Output):-
Name_list_non_bin
=
Name_list_raw
;
g_to_c_PIVP
(
PIVP_input
,
PIVP_non_bin
,
1.0
),
append
(
Name_list_
non_
raw
,
[
Input
],
Name_list_non_bin
)
append
(
Name_list_raw
,
[
Input
],
Name_list_non_bin
)
),
(
Reduction
=
yes
...
...
@@ -369,7 +372,6 @@ main_compiler(PIVP_input, Name_list_raw, Input, Output):-
PIVP_unsigned
=
PIVP_non_bin
,
Name_list_unsigned
=
Name_list_non_bin
),
PIVP_unsigned
=
[
N
,
_PODE
,
_IV
],
get_option
(
lazy_negatives
,
Lazyness
),
(
Lazyness
=
yes
...
...
@@ -378,7 +380,8 @@ main_compiler(PIVP_input, Name_list_raw, Input, Output):-
;
lng
:
rewrite_PIVP_all_negated
(
PIVP_unsigned
,
PIVP
,
VarNeg
)
),
affect_name
(
N
,
Output
,
Input
,
VarNeg
,
Species_names
),
sort
(
VarNeg
,
VarNegSort
),
negate_name
(
Name_list_unsigned
,
VarNegSort
,
Species_names
),
(
\
+
(
VarNeg
=
[])
->
...
...
@@ -783,7 +786,7 @@ compose_multivar_vector([P|PV], PL, [Q|QV]) :-
%
% Reduce a given PIVP to a new one which only need binomial
reduce_to_binomial
([
N
,
PODE
,
IV
],[
NewN
,
NewPODE
,
NewIV
])
:-
reduce_to_binomial
([
N
,
PODE
,
IV
],
Name_list
,
[
NewN
,
NewPODE
,
NewIV
]
,
Modified_Names
)
:-
scan_order_multivarvector
(
PODE
,
Order
),
(
Order
>
2
...
...
@@ -1117,7 +1120,7 @@ generate_names(_Name_list, [], []) :- !.
generate_names
(
Name_list
,
[
Var
|
TailVar
],
[
Name
|
TailName
])
:-
write_new_name
(
Name_list
,
Var
,
Name_as_list
),
atomic
s_to_string
(
Name_as_list
,
Name
),
atomic
_list_concat
(
Name_as_list
,
Name
),
generate_names
(
Name_list
,
TailVar
,
TailName
).
...
...
@@ -1574,42 +1577,26 @@ exponant_to_solution([Exp|Tail_exp], [Name|Tail_name], Sol, Kin) :-
).
%!
affect
_name(+N
,+Output,+Input,
+Varneg,-Name_list)
%!
negate
_name(+N
ame_list_raw,
+Varneg,
-Name_list)
%
%
Create the name of the sp
ec
i
es
%
Add _p and _m to the name of variables if n
eces
sary
affect
_name
(
N
,
Output
,
Input
,
Varneg
,
Name_list
)
:-
affect_name
(
N
,
0
,
Output
,
Input
,
Varneg
,
Name_list
).
negate
_name
(
N
LR
,
VN
,
NL
)
:-
negate_name
(
NLR
,
1
,
VN
,
NL
).
affect_name
(
N
,
N
,
_Output
,
_Input
,
_Varneg
,
[])
:-
!.
negate_name
([],
_N
,
[],
[])
:-
!.
affect_name
(
N
,
Nc
,
Output
,
Input
,
Varneg
,
Name_list
)
:-
get_option
(
lazy_negatives
,
Lazyness
),
Nxt
is
Nc
+
1
,
(
Nxt
=
1
->
Name
=
Output
;
Lazyness
=
no
,
Nxt
=
N
->
Name
=
Input
;
Nchar
is
Nxt
+
63
,
char_code
(
Name
,
Nchar
)
),
(
member
(
Nxt
,
Varneg
)
->
name_p_m
(
Name
,
Name_p
,
Name_m
),
add_reaction
(
fast
*
Name_p
*
Name_m
for
Name_p
+
Name_m
=>
_
),
Head
=
[
Name_p
,
Name_m
]
;
Head
=
[
Name
]
),
affect_name
(
N
,
Nxt
,
Output
,
Input
,
Varneg
,
Tail
),
append
(
Head
,
Tail
,
Name_list
).
negate_name
([
Name
|
TailName
],
N
,
[
N
|
TailNeg
],
[
Name_p
,
Name_m
|
TailNewName
])
:-
!,
name_p_m
(
Name
,
Name_p
,
Name_m
),
add_reaction
(
fast
*
Name_p
*
Name_m
for
Name_p
+
Name_m
=>
_
),
NN
is
N
+
1
,
negate_name
(
TailName
,
NN
,
TailNeg
,
TailNewName
).
negate_name
([
Name
|
TailName
],
N
,
VarNeg
,
[
Name
|
TailNewName
])
:-
!,
NN
is
N
+
1
,
negate_name
(
TailName
,
NN
,
VarNeg
,
TailNewName
).
%! name_p_m(+Name,-Positive_name,-Negative_name)
...
...
@@ -1693,3 +1680,31 @@ expression_to_PIVP(E / F, PIVP) :-
expression_to_PIVP
(
E
,
_
)
:-
throw
(
error
(
illegal_expression
(
E
),
expression_to_PIVP
)).
%! abstract_names(+N, +Output, -Name_list)
abstract_names
(
N
,
Output
,
[
Output
|
RTail
])
:-
Nm
is
N
-
1
,
abstract_names
(
Nm
,
Tail
),
reverse
(
Tail
,
RTail
).
abstract_names
(
0
,
[])
:-
!.
abstract_names
(
N
,
[
Head
|
Tail
])
:-
Nm
is
N
-
1
,
divmod
(
Nm
,
26
,
R
,
C
),
Code
is
C
+
65
,
Rep
is
R
+
1
,
char_code
(
Letter
,
Code
),
stutter
(
Rep
,
Letter
,
Head
),
abstract_names
(
Nm
,
Tail
).
%! stutter(N,In,Out)
stutter
(
1
,
In
,
In
)
:-
!.
stutter
(
N
,
In
,
Out
)
:-
Nm
is
N
-
1
,
stutter
(
Nm
,
p
,
Tempo
),
atom_concat
(
In
,
Tempo
,
Out
).
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment