# $ echo "$d_txted" "'""$d_Qndfs""MindCode/code develop/MindCode basics develop.txt""'" | xargs -0 sh -c & www.BillHowell.ca 21Mar2020 initial # view this file in a text editor, with [constant width font, tab = 3 spaces] /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/code develop/MindCode basics develop.txt ******** 03Apr2020 Old code %nowFireL := cull sortup nowFireL ; % probably does nothing ... ; ELSEIF (isinteger histPatNowL@netID) THEN histPatL@netID := link (solitary histPatNowL@netID) (front histPatL@netID) ; #] view_MindCode IS - view the netMindCode state # (actually, just columns as roster dB) at any time, use [all, some] of # will need specialised net_views as output depends on [netMindCode, focus at time of work, etc] # This example was used for 'MindCode [arith, trgr] tests.ndf' # 14Mar2020 need to add log file output once code is working # 3Mar2020 - this table is too big, even for a small net!!! use simpler structures view_MindCode IS { table_write 'IDL' 'nameL' 'IDsubL' 'inNmIDL' 'outL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'trgrTypL' 'trgrPatL' 'fireL' 'fireStdL' 'OKL' ; } $ mvar="fireStdL" $ find "$d_PROJECTS""Qnial/MY_NDFS/MindCode" -type f -name "*.ndf" | tr \\n \\0 | xargs -0 -ILINE grep --with-filename "$mvar" LINE /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/globals initialize.ndf:{ NONLOCAL cycle_max epigenL fireL fireStdL histPatL histPatNowL IDL IDsubL inL inNmIDL modL nameL /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/globals initialize.ndf: fireStdL := null ; % input, ; /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/globals initialize.ndf: table_write 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/globals initialize.ndf: nameL IDsubL typeL opL ToffL TwaitL modL paramL epigenL fireL fireStdL trgrTypL inNmIDL trgrPatNmIDL /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/globals initialize.ndf: IDL typeL opL ToffL TwaitL modL paramL epigenL trgrTypL trgrPatL fireL fireStdL ResCalcL OKL /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/code test/fire tests.ndf: NONLOCAL cycle_max IDL nameL IDsubL inL trgrPatL histPatL TwaitL fireStdL fireL ; /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/code test/fire tests.ndf: OKres := (fireStdL EACHBOTH = fireL) ; /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/code test/fire tests.ndf: write EACH (gage shape) IDL nameL IDsubL inL trgrPatL histPatDat histPatL TwaitL fireStdL fireL OKRes ; /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/code test/fire tests.ndf: table_write 'IDL' 'nameL' 'IDsubL' 'inL' 'trgrPatL' 'histPatDat' 'histPatL' 'TwaitL' 'fireStdL' 'fireL' 'OKRes' ; /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/arith, trig examples.ndf: 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'numberL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/arith, trig examples.ndf: 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'numberL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/arith, trig examples.ndf: 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'numberL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/arith, trig examples.ndf: 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'numberL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/arith, trig examples.ndf: 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'numberL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' /home/bill/PROJECTS/Qnial/MY_NDFS/MindCode/arith, trig examples.ndf: 'nameL' 'IDsubL' 'typeL' 'opL' 'ToffL' 'TwaitL' 'modL' 'paramL' 'epigenL' 'numberL' 'fireL' 'fireStdL' 'trgrTypL' 'inNmIDL' 'trgrPatNmIDL' >> I can't see where the error occurs >> fireStdL doesn't appear in 'MindCode basics.ndf' >> there aren't double columns of fireStdL in 'arith, trig examples.ndf' ******** 30Mar2020 post global-symbol changes To search for variables : $ mvar="IDsubL" $ find "$d_PROJECTS""Qnial/MY_NDFS/MindCode" -type f -name "*.ndf" | tr \\n \\0 | xargs -0 -ILINE grep --with-filename "$mvar" LINE >> stdInOutTrig was missing, must have dropped it when moving operators between files change "trig" to "trgr" in symbol names >> nah! I'm too lazy Tests : # bits_to_intg_test examples : >> most results are wrong ********** 29Mar2020 write 'loading : *** nmID_to_stdID' #] nmID_to_stdID IS - find the stdID for a [name, subID] combination nmID_to_stdID IS OP name ID { LOCAL i ; NONLOCAL stdNmXrefL stdIDXrefL ; i := find_Howell name stdNmXrefL ; (ID EACHRIGHT = stdIDXrefL@i) sublist stdNetIDXrefL@i } ******** 29Mar2020 #] primitive ops write 'loading : primitive ops' #] sign_it IS OP spikeTrain - converts a "sign" spike of a train to [+-] sign_it IS OP signSpike { IF (= l signSpike) THEN -1 ELSE 1 ENDIF } #] [spikes_to_net, fire_net] - depend on the netID "type", as checked in data setup # reminder - only stdIDL are defined by data, pstNets are derived # Nets "scale" - to [networks, hierarchies] # 25Feb2020 needs upgrade to account for [refractory, inhibited, sustain_period, faults, etc] inNets # how to account for "0" integers may become an issue? # 28Feb2020 - nyet?!! The OUTPUT spikes are available, but for spikes INTERNAL to the net something is needed #] spikes_to_net IS OP netID - return current output spikes of netID spikes_to_net IS OP netID { NONLOCAL fireL stdIDL ; %fireL#(stdIDL#(stdInNmIDL@netID)) ; fireL#(stdInNmIDL@netID) } # tests # stdIDL - ALL stdIDL must be <= shape stdIDL!!! eg OR ((link stdIDL) < (gage shape stdIDL)) # stdIDL := (1 2 3) (solitary 4) (solitary 5) (6 7 8) (solitary 9) (solitary 1) (solitary 2) (solitary 3) (solitary 6) (solitary 2) # fireL := (oooooooo oooooool oooooolo) (solitary oooooooo) (solitary oooooool) (oolooooo oloooooo llllllll) (solitary oooooloo) (solitary oooolooo) (solitary oooloooo) (solitary oolooooo) (solitary oloooooo) (solitary llllllll) # shape fireL@0 # shape fireL@1 # fireL#(stdIDL#(stdIDL@3)) - OK, this works (# = at all indexing) ******** 25Mar2020 remove special "con" nets operators & data conInOutNets FOR conName WITH (cull sortup conNameL) DO conIDs := (= conName conSubIDL) sublist conSubIDL ; % I could do this in "local_to_global_cols" or something ; netIDs := (= conName stdIDL ) sublist netIDL ; i_netID := -1 ; FOR conID WITH conIDs DO i_netID := i_netID + 1 ; IF (= conID netIDs@i_netID) THEN conNetIDL@(netIDs@i_netID) := netIDs@i_netID ; ELSE outNetL@i := link outNetL@i netID ; ENDIF ; ENDFOR ; ENDFOR ; } # write 'loading : intg00_cnst' intg00_cnst IS { NONLOCAL subTemp ; subTemp := 'conNameL' 'conSubIDL' 'conStdL' 'conSpikeL' "intg00_con 0 0 (intg_to_spikes 0) "intg00_con 1 1 (intg_to_spikes 1) "intg00_con 2 77 (intg_to_spikes 77) "intg00_con 3 100 (intg_to_spikes 100) "intg00_con 4 3 (intg_to_spikes 3) "intg00_con 5 -129 (intg_to_spikes -129) ; cnstNet_build ; } write 'loading : real00 - [example, test] real network setup' # write 'loading : real00_cnst' real00_cnst IS { NONLOCAL subTemp ; subTemp := 'conNameL' 'conSubIDL' 'conStdL' 'conSpikeL' "real00_con 0 0 (real_to_spikes 0. ) "real00_con 1 1 (real_to_spikes 1. ) "real00_con 2 126.2 (real_to_spikes 126.2) "real00_con 3 2965.7 (real_to_spikes 2965.7) "real00_con 4 0 (real_to_spikes 0. ) "real00_con 5 -2965.7 (real_to_spikes -2965.7) ; cnstNet_build ; } conIDL := tell con_rows ; conSpikeL := reshape con_rows (solitary null) ; %conOut ; % 25Mar2020 no longer used, build netIDs from all Sensory subNets -> constant firing of the netIDs identified ; intg00_cnst ; real00_cnst ; #] cnstNet_build IS - add n_cols of standard" stdNet data to corresponding globalCols of MindCode # WARNING - columns may become mal-adjusted if partial updates are done to columns cnstNet_build IS { LOCAL n_rows n_cols subCols titles ; NONLOCAL subTemp ; n_cols := 4 ; n_rows := floor ((gage shape subTemp) / n_cols) ; subTemp := n_rows n_cols reshape subTemp ; titles := subTemp|[0,] ; subCols := cols subTemp|[count (n_rows - 1),] ; titles EACHBOTH assign ((EACH execute titles) EACHBOTH link subCols) ; } #write 'loading : conOut ' # 25Mar2020 - is this a waste of time, and complexity for nothing? Skip it for now, just use _sns nets #] conOut IS - build conIDs for # constant firing of the netIDs identified # depends on netID-ordering of conSubIDL if two conID target the same stdID!!! # 25Mar2020 frequency of conID firing - what if these should be different? (address this later) conOut IS { LOCAL con_rows conName conIDs conID netIDs i_netID ; NONLOCAL conIDL conNameL conSubIDL conSpikeL stdNmXrefL stdIDXrefL stdNetIDXrefL stdIDL stdSubIDL stdOutL ; % ; % add to stdInL ; FOR conID WITH conIDL DO % there are >=1 stdInNmIDL@stdID in general ; FOR inNmID WITH stdInNmIDL@stdID DO i := find_Howell (first inNmID) stdNmXrefL ; ID := ((second inNmID) EACHRIGHT = stdIDXrefL@i) sublist stdNetIDXrefL@i ; stdInL@stdID := link stdInL@stdID ID ; ENDFOR ; ENDFOR ; } % ; con_rows := 0 ; conIDL := null ; conNameL := null ; conSubIDL := null ; conStdL := null ; conSpikeL := null ; conSpikeL := null ; con_rows := gage shape conSubIDL ; table_write 'conIDL' 'conNameL' 'conSubIDL' 'conStdL' 'conSpkL' conIDL conNameL conSubIDL conStdL conSpkL write 'loading : sensFire ' #] sensFire IS OP netID - fire constant-value sensory nets sensFire IS OP netID { LOCAL oprtr type ; NONLOCAL fireL histPatL stdInNmIDL stdOutL outFireNowL stdOffTL oprtL stdTypL trigPatL trigTypL stdWaitL ; IF (= 0 stdWaitL@netID) THEN fireL#netID := oprtL@netID EACHRIGHT apply fireL#(stdInNmIDL@netID) ; % ; % check stdInNmIDL of all nets for firing (this is BAD for efficiency, but easy to implement) ; % ; % check stdInNmIDL of all nets for firing (this is BAD for efficiency, but easy to implement) ; stdWaitL@netID := stdWaitL@netID + stdOffTL@netID ; nowFireL := link nowFireL netID ; ENDIF ; } #] net sensory (inputs) write 'loading : net sensory (inputs) ' #] inConstant IS OP inConstantL - initial input of constant exogenous inputs # 04Mar2020 for now, just consider systmem for which ALL inConstants are input on the same periodic time basis (eg every 10 timeSteps) # also - use the simple expression below directly in MindCode_cycle inConstant IS OP inConstantL { EACH apply inConstantL ; } #] inSeries IS OP inputIDL envInputL - check exogenous inputs - these are pre-set, and are NOT affected by net activity (eg some time series) ; # can be [absolute, relative, event] time basis # 04Mar2020 - obviously NOT implemented yet inSeries IS OP inputIDL envInputL { null } #] inFeedback IS OP inputIDL envInputL - add [envrnmt, sensory] inputs [affected, controlled] by net # 04Mar2020 - obviously NOT implemented yet inFeedback IS OP inputIDL envInputL { null } #] envInput IS OP inputID spikesIn - inject [environmental, sensory] inputs to net # can be [absolute, relative, event] time dependent # 04Mar2020 - obviously NOT implemented yet envInput IS OP netID spikesIn { NONLOCAL fireL nowFireL ; nowFireL := append nowFireL netID ; fireL@netID := spikesIn ; } ******** 24Mar2020 stdInOutNets # { LOCAL con_rows stdName stdIDs stdID netIDs i_netID ; NONLOCAL netIDL stdNameL stdIDL outNetL ; FOR stdName WITH (cull sortup stdNameL) DO stdIDs := (= stdName stdNameL) sublist stdIDL ; % I could do this in "local_to_global_cols" or something ; netIDs := (= stdIDs stdIDL ) sublist netIDL ; i_netID := -1 ; FOR stdID WITH stdIDs DO i_netID := i_netID + 1 ; IF (= stdID netIDs@i_netID) THEN constNetIDL@(netIDs@i_netID) := netIDs@i_netID ; ELSE outNetL@i := link outNetL@i netID ; ENDIF ; ENDFOR ; ENDFOR ; } FOR name WITH names@netID DO IF (~= null name) THEN subID := (= name stdNameL) sublist netIDL ; % I could do this in "local_to_global_cols" or something ; netID := (= subID netIDs ) sublist netIDs ; % maybe use search? ; outNetL@ID := link outNetL@ID netID ; ENDIF ; ENDFOR ; FOR name WITH names DO names subIDs := EACH [first, second] inNmIDL ; THEN := (= name stdNameL) sublist netIDL ; inNetL@netID := link inNetL@netID subID := (= name names) sublist subIDs ; THEN name ID := [first, second] inNmID ; nameIDs := (= name stdNameL) sublist netIDL ; IDIDs := (= ID stdIDL ) sublist netIDL ; % maybe use search? ; nameIDs EACHLEFT in IDIDs ; outNetL@ID := link outNetL@ID netID ; ENDIF ; % ; % build outNetL ; FOR netID WITH netIDL DO FOR inNmID WITH inNmIDL@netID DO IF (~= null inNmID) THEN IDnetIDs := stdNetIDXrefL@(find_Howell (first inNmID) stdNmXrefL) ; % there are >=1 IDnetIDs in general ; FOR i WITH (tell gage shape IDnetIDs) DO inNetL@netID := link inNetL@netID IDnetIDs@i ; ENDFOR ; ENDIF ; ENDFOR ; ENDFOR ; FOR stdName WITH (cull sortup stdNameL) DO stdIDs := (= stdName stdNameL) sublist stdIDL ; % I could do this in "local_to_global_cols" or something ; netIDs := (= stdIDs stdIDL ) sublist netIDL ; i_netID := -1 ; FOR stdID WITH stdIDs DO i_netID := i_netID + 1 ; IF (= stdID netIDs@i_netID) THEN constNetIDL@(netIDs@i_netID) := netIDs@i_netID ; ELSE outNetL@i := link outNetL@i netID ; ENDIF ; ENDFOR ; ENDFOR ; ********** 21Mar2020 remove "leftovers" # Don't use this - it's useless, each subNet file loads itself? write 'loading : sub_add ' #] sub_add IS OP p_sub - ontogeny!!, initialize the sub, including weights for some subs # 14Mar2020 MindCode currently is capable of running only ONE instance per QNial session # p_subMindCode - is a "file path" that defines only a single Mincode (of sub-nets) as # - all columns of a net are global variables (roster database arrangement) # - for ease of [view, work]ing, netMindCodes load data in parts : # [sub_struct, sub_morphFlip, sub_triggers, sub_results] # ~06Mar2020 netMindCode would probably be hand-coded for simple nets # need constructors for larger nets # need serious [DNA, RNA, epi, molecular, neuro-transmitter, etc] capabilities for MindCode # initialise ['waitTL', 'modL', 'wght'] randomly or whatever sub_add IS OP p_sub { loaddefs p_sub ; subStruct ; % subNameL subIDL outTypL optrL offTL waitTL inNetL modL paramL epigenL trigTypL trigPatL fireL StdL ResL OKL ; subSensory ; % [initial, ongoing] cart [input, fire] of the appropriate environmental inputs (eg [i2s, r2s]) ; } #] MindCode_cycle IS - fire appropriate neurons, then update the net # old code nowFireL := null ; THEN oldFireL := nowFireL ; nowFireL := null ; % ; % histPatoryL := inTimeL EACHBOTH link (EACH rest histPatoryL) ; % Now : (AND (inNetID@netID EACHLEFT in nowFireL) (gage shape histPatory@netID = 1 (list)) ; % Cumulative : (AND (inNetID@netID EACHLEFT in (link histPatory@netID) ; % build inNetL for all netIDs based on ; inNetL := cull sortup link outNetL???????????#[cull sortup oldFireL] ; % ; % sort & cull [oldFireL, outNetL] (sort makes cull [fast, reliable]) ; inNetL := cull sortup link outNetL???????????#[cull sortup oldFireL] ; # enddoc