ncase / loopy

A tool for thinking in systems
http://ncase.me/loopy/
Creative Commons Zero v1.0 Universal
1.62k stars 211 forks source link

Conditional Pass-through, Filters #7

Open ghost opened 7 years ago

ghost commented 7 years ago

This is an awesome tool, thank you!

I have a suspicion, that with one addition this could be turing-complete (I don't have proof, just gut feeling). Also, this feature would help people to mirror and demonstrate simple natural networks like prototypical neural networks or simple gene-regulatory networks.

The idea, simply, is to allow nodes to 'decide' whether to pass through, or consume, an arrow. The two most useful 'functions' I can imagine are to simply filter arrows by polarity (e.g., nodes that can consume but not pass-through negative arrows, but pass-through positive arrows), and to pass-through only if the node is fuller than a certain threshold, or less-full than a threshold.

For neurons, for example, you could then mimic threshold-firing behaviour using a pattern like:

(input)--->(threshold 0.9)---(filter(positive))--->(output)
                ^   |
                |   V
(feed-back emits positive *and* negative)

So, when input pushes threshold over fullness 0.9, it starts to pass-through, and the next input triggers a cascade of positive and negative arrows (more negative than positive, though). The positives are allowed through by the filter, and hit output. The negatives pull the neuron back below its threshold, and the cycle begins again.

This is a bit of a big ask, so I'd understand if it's overcomplicated for what loopy's designed to do.

I do feel that these thresholds would improve some of the example simulations, though; for example, in the automation/job scenario, you can use these to model how social unrest only starts to cause political upheaval above a certain threshold, or how tax income only increases until unemployment hits a certain threshold, and then may start to crash as consumer spending halts.

ghost commented 7 years ago

Come to think of it, combined with feedback loops, both of the above might be possible to model with just one behaviour: an option to have nodes consume arrows until either full or empty, and then "overflow" in either case.

So, an overflow-enabled node that receives enough negative input would start permitting negative arrows when it's empty. Or, if it receives enough positive arrows, it would start overflowing and allow positives to pass-through. Combined with a simple feedback loop it could then act like a threshold or "emit once, then reset" node. If allowed to just overflow in one direction, it would act a bit like a filter.

ncase commented 7 years ago

I like this idea! In general, I just like the idea of making something "technically Turing-complete".

Would it still work if it was the relationships that had the asymmetric logic? For example, an arms race. US getting more nukes means USSR will get more nukes, and vice versa. Positive feedback loop. But the converse is NOT true. US reducing their nukes will not (by itself) lead to the USSR reducing their nukes, nor vice versa. So, if arrows/relationships could specify that they'd only take positive or only negative arrows –– would that be sufficient to model a gene-reg network?

GalHorowitz commented 7 years ago

@ncase I actualy think so. But not in the way he describes - it could still benefit the user in many things, it's just getting to the functionally that @cathalgarvey describes using this system would take LOTS of nodes, which because of no zomming/more space than canvas size is not possible.

1000i100 commented 4 years ago

Filter edge -> done in #20 overflow-enabled node -> done in #20 you can try it here : https://1000i100.github.io/loopy/v1.1/ and import your system (not breaking any compatibility)

ghost commented 4 years ago

Really cool to hear, thanks! :)

ghost commented 4 years ago

Kinda have a neural system going here now: accepts four inputs before triggering, then feeds back to reset. :)

1000i100 commented 4 years ago

I'm happy to please you ! :)

1000i100 commented 4 years ago

I've breaked it with my work since the last month, (and save to link is actually broken in my version, but export to json is usable)... But, there is many new features and you can play with it and talk me about them !