@@ -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,43 @@ 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
731+ (push! (activators, ex), inhibitors)
732+ else
733+ (activators, push! (inhibitors, ex))
734+ end
735+ :: Int => (activators, inhibitors)
736+ Expr (:call , :(- ), child) =>
737+ classify_activators_inhibitors (child, - sign, activators, inhibitors)
738+ Expr (:call , :(- ), left_child, right_child) => begin
739+ (activators, inhibitors) = classify_activators_inhibitors (
740+ left_child,
741+ sign,
742+ activators,
743+ inhibitors,
744+ )
745+ (activators, inhibitors) = classify_activators_inhibitors (
746+ right_child,
747+ - sign,
748+ activators,
749+ inhibitors,
750+ )
751+ (activators, inhibitors)
752+ end
753+ Expr (:call , f, children... ) => begin
754+ for child in children
755+ (activators, inhibitors) = classify_activators_inhibitors (
756+ child,
757+ sign,
758+ activators,
759+ inhibitors,
760+ )
742761 end
743- _ => (activators, inhibitors)
762+ (activators, inhibitors)
763+ end
764+ Expr (expr_type, _... ) => error (" Can't classify expression of type $expr_type " )
744765 end
745766
746767 return activators, inhibitors
775796
776797function is_default_function (ex, lower_bound, upper_bound)
777798 @match ex begin
799+ # no inputs
800+ - 1 => true
778801 # single activator
779802 :(var ($ id)) => true
780803
@@ -795,8 +818,8 @@ function is_default_function(ex, lower_bound, upper_bound)
795818 if bound == lower_bound
796819 end
797820 ) =>
798- is_default_function (@show ( act) , lower_bound, upper_bound) &&
799- is_default_function (@show ( inh) , lower_bound, upper_bound)
821+ is_default_function (act, lower_bound, upper_bound) &&
822+ is_default_function (inh, lower_bound, upper_bound)
800823 _ => false
801824 end
802825end
@@ -909,8 +932,8 @@ function create_target_function(
909932
910933 if isnothing (formula) # default target function
911934 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)
935+ @warn " $(name (variable)) has no inputs, defaulting formula to -1 "
936+ return - 1
914937 else
915938 activators = [
916939 Symbol (" $(name) _$id " ) for
0 commit comments