@@ -419,12 +419,12 @@ from(r::JSONRelationship) = r.from
419419to (r:: JSONRelationship ) = r. to
420420type (r:: JSONRelationship ) = r. type
421421
422- StructUtils. @tags struct JSONEntity
422+ StructUtils. @defaults struct JSONEntity
423423 target_function:: Any & (json = (name = " formula" ,),)
424424 id:: Int & (json = (name = " id" ,),)
425425 range_from:: Int & (json = (name = " rangefrom" ,),)
426426 range_to:: Int & (json = (name = " rangeto" ,),)
427- name:: String & (json = (name = " name" ,),)
427+ name:: String = " " & (json = (name = " name" ,),)
428428end
429429id (e:: JSONEntity ) = e. id
430430target_function (e:: JSONEntity ) = e. target_function
@@ -725,22 +725,23 @@ Classify all symbols in `ex` as activators or inhibitors.
725725
726726
727727"""
728- function classify_activators_inhibitors (ex, activators = [], inhibitors = [])
728+ function classify_activators_inhibitors (ex, sign = 1 , activators = [], inhibitors = [])
729729 (activators, inhibitors) = @match ex begin
730- :($ e) && if e isa Symbol
731- end => (union (activators, [e]), inhibitors)
732- (:($ e + $ other) || :($ other + $ e)) && if e isa Symbol
733- end => classify_activators_inhibitors (other, union (activators, [e]), inhibitors)
734- :(- $ e) && if e isa Symbol
735- end => (activators, union (inhibitors, [e]))
736- :($ other - $ e) && if e isa Symbol
737- end => classify_activators_inhibitors (other, activators, union (inhibitors, [e]))
738- :($ fn ($ (args... ))) =>
739- let a_i_pairs =
740- classify_activators_inhibitors .(args, (activators,), (inhibitors,))
741- (union (first .(a_i_pairs)... ), union (last .(a_i_pairs)... ))
730+ :: Symbol => if sign == 1 (push! (activators, ex), inhibitors) else (activators, push! (inhibitors, ex)) end
731+ :: Int => (activators, inhibitors)
732+ Expr (:call , :(- ), child) => classify_activators_inhibitors (child, - sign, activators, inhibitors)
733+ Expr (:call , :(- ), left_child, right_child) => begin
734+ (activators, inhibitors) = classify_activators_inhibitors (left_child, sign, activators, inhibitors)
735+ (activators, inhibitors) = classify_activators_inhibitors (right_child, - sign, activators, inhibitors)
736+ (activators, inhibitors)
737+ end
738+ Expr (:call , f, children... ) => begin
739+ for child in children
740+ (activators, inhibitors) = classify_activators_inhibitors (child, sign, activators, inhibitors)
742741 end
743- _ => (activators, inhibitors)
742+ (activators, inhibitors)
743+ end
744+ Expr (expr_type, _... ) => error (" Can't classify expression of type $expr_type " )
744745 end
745746
746747 return activators, inhibitors
775776
776777function is_default_function (ex, lower_bound, upper_bound)
777778 @match ex begin
779+ # no inputs
780+ - 1 => true
778781 # single activator
779782 :(var ($ id)) => true
780783
@@ -795,8 +798,8 @@ function is_default_function(ex, lower_bound, upper_bound)
795798 if bound == lower_bound
796799 end
797800 ) =>
798- is_default_function (@show ( act) , lower_bound, upper_bound) &&
799- is_default_function (@show ( inh) , lower_bound, upper_bound)
801+ is_default_function (act, lower_bound, upper_bound) &&
802+ is_default_function (inh, lower_bound, upper_bound)
800803 _ => false
801804 end
802805end
@@ -909,8 +912,8 @@ function create_target_function(
909912
910913 if isnothing (formula) # default target function
911914 if length (in_neighbor_ids) == 0
912- @warn " $(name (variable)) has no inputs, defaulting formula to lowest value ( $( range_from (variable)) ). "
913- return range_from (variable)
915+ @warn " $(name (variable)) has no inputs, defaulting formula to -1 "
916+ return - 1
914917 else
915918 activators = [
916919 Symbol (" $(name) _$id " ) for
0 commit comments