Menu

#480 Request for: abs, min, max and switch widgets.

Cantillon
closed
nobody
None
4normal
2016-02-10
2015-08-03
No

I have been trying to simulate neuron activity in Minsky and I would find abs, min and max widgets very useful. Such widgets would also be useful in an economics model - for instance if you want to take into account minimum wage.

Actually if you assume your data never exceeds some large value then, when the data widget is fixed, you could use it to emulate max(x,0) and min(x,0) and then use the identities:
max(x,y) = max(x - y, 0) + y,
min(x,y) = min(x - y, 0) + y, and:
abs(x) = max(x,0) + max(-x,0),
to emulate the the functions fully. However this seems very messy and inefficient and it would be better to expose the functions in the math libraries.

A "pure" switch widget would be one that takes two data inputs, x and y, and a control input, c, connects the output to x or y depending upon whether c>0 (or some other specified level) or not. Such a widget would be useful if, for instance, you wanted to change the behaviour of your model when the debt to GDP ratio reached a particular level.

Unfortunately I doubt that a widget that works like this is feasible: I haven't looked at Runge-Kutta since way back when I was an undergraduate, but I don't think it can deal with jump discontinuities, but an an approximation behaviour to this can be made, when the data widget works, by constructing a function t using the data file:

.001 1
-0.001 0
=========
and using:
x.t(c) + y.(1-t(c))

But doing it like this seems messy inefficient and inflexible and it strikes me that it would be better done by a custom widget.

Discussion

  • Bernard Hurley

    Bernard Hurley - 2015-08-03

    I have no idea why the text suddenly got big!

     
    • High Performance Coder

      Joys of markdown, I suppose.

       
  • High Performance Coder

    Funny you should raise this. I just implemented abs, heaviside step function and a switch block in last week's sprint. Check out Minsky.1.40.D14 for a beta release with that functionality. As you say, you can implement max(x,0) using the heaviside step function Θ, via max(x,0)=xΘ(x), and min(x,0) via xΘ(-x). But an explicit n-ary max/min operations will be a useful addition. Similarly, I'm planning on adding binary step functions, which I will call < and >. Ie x<y = Θ(y-x) and x>y = Θ(x-y). Or maybe just make the existing heaviside function into a binary wth a label like '>'.

    I'm not worried about integrating these functions - integrating piecwise continuous should cause problems for excplicit methods, but might for implicit methods. Further testing is required to know whether I should throw an error if an implicit method is attempted on a non-differentiable system.

     

    Last edit: High Performance Coder 2015-08-03
  • High Performance Coder

     
  • Bernard Hurley

    Bernard Hurley - 2015-08-03

    I will have a look at Minsky.1.40.D14, thanks.

     
  • High Performance Coder

    • status: open --> closed
     
  • High Performance Coder

    • priority: 5 --> 4normal
     

Anonymous
Anonymous

Add attachments
Cancel