Could someone please explain proper usage of the switch block. The example in the documentation seems to show three values (1, 2.5, and -1) based on the value of t. In psuedo code, this would be:
switch (t){
case X:
A;
case Y:
B;
case Z:
C;
else:
D;
}
The three values in the example the documentation gives seem to correspond to A, B, and C in the above example. But then how does one specify X, Y, and Z? The example seems to assume they are 0 <= t < 1, 1 <= t < 2, and t > 2 respectively. But what if the conditions are more complex than this?
Also, what happens in case none of the specified options is satisfied, as in the fourth case (D) above?
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On Mon, Aug 22, 2016 at 09:39:35PM +0000, marshf wrote:
Could someone please explain proper usage of the switch block. The example in the documentation seems to show three values (1, 2.5, and -1) based on the value of t. In psuedo code, this would be:
switch (t){
case X:
A;
case Y:
B;
case Z:
C;
else:
D;
}
The three values in the example the documentation gives seem to correspond to A, B, and C in the above example. But then how does one specify X, Y, and Z? The example seems to assume they are 0 <= t < 1, 1 <= t < 2, and t > 2 respectively. But what if the conditions are more complex than this?
Also, what happens in case none of the specified options is satisfied, as in the fourth case (D) above?
If the conditions are more complex, you need to apply a nonlinear
transformation to the input. For example, if you want X=1, Y=10,
Z=100, you would attach a log_10(x) function to the input port.
As for the else case, bear in mind that the first case is t<=0.5, and
the last case applies when t>2.5. So the last input applies to the
high portion of the else case, and the first input applies to the low
portion of the else case.
Calling it a switch statement is a somewhat poor analogy, even though
fundamentally equivalent. A better analogy is the type of piecewise
definitions used in mathematical functions - eg in the definition of a
piecewise line function:
/ 0 t <= 0.5
f(x) = { x-0.5 0.5<t<=1.5 \\="" 1="" t=""> 1.5
Cheers
--
Dr Russell Standish Phone 0425 253119 (mobile)
Principal, High Performance Coders
Visiting Senior Research Fellow hpcoder@hpcoders.com.au
Economics, Kingston University http://www.hpcoders.com.au
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Thanks! Maybe changing the generic name of the block from "switch" to "piecewise" would be a good idea. Certainly your explanation is very helpful when you put it this way.
Right now Minsky has no integer or modulo function. I'm trying to set up a variable that cycles through three states, {0, 1, 2}, as a function of t. E.g. assume t is set to increments of 1 unit:
x=0
if (int(t/3)=t/3)
x=0
else
x++
fi
In mathematical terms and assuming t = {0, 1, 2, ...}:
Let x= f(t) = t - [3 x int(t/3)]
But because there's no int function in Minsky, I tried to use x in the condition for a switch block, but Minsky called this cyclical and wouldn't accept it.
Is there any way to define a variable like this x in Minsky?
(Among other things, being able to do this would allow Dirac delta functions in Minsky models.)
Last edit: marshf 2016-08-23
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
On Tue, Aug 23, 2016 at 03:35:57PM +0000, marshf wrote:
Thanks! Maybe changing the generic name of the block from "switch" to "piecewise" would be a good idea. Certainly your explanation is very helpful when you put it this way.
Hmm, I don't like piecewise either. IIRC, AMSTex used the term
"choice", which might be possible, but I think the problem is the
concept has no well-used name. But it's always fun to have naming competitions!
Right now Minsky has no integer or modulo function. I'm trying to set up a variable that cycles through three states, {0, 1, 2}, as a function of t. E.g. assume t is set to increments of 1 unit:
x=0
if (int(t/3)=t/3)
x=0
else
x++
fi
In mathematical terms:
Let x= f(t) = t - [3 x int(t/3)]
But because there's no int function in Minsky, I tried to use x in the condition for a switch block, but Minsky called this cyclical and wouldn't accept it.
That sounds like a reasonable thing to add, along with mod(). Why not
raise a ticket for it?
Is there any way to define a variable like this x in Minsky?
For now, you really have only two options - a rather clumsy to
construct switch block, or also you could use a data block. Either
way, you can only define your function for a finite range. I would
suggest using a data block, and using something like a perl script to
generate the data values for the range you need.
(Among other things, being able to do this would allow Dirac delta functions in Minsky models.)
Delta functions should only appear in kernels, ie in a function fed
into the input of an integral or Godley table. You can achieve
essentially the same result by multiplying the output of that integral
by a Heaviside theta function, which is represented in Minsky by the
"<" and "<=" operators, or combination thereof.
--
Dr Russell Standish Phone 0425 253119 (mobile)
Principal, High Performance Coders
Visiting Senior Research Fellow hpcoder@hpcoders.com.au
Economics, Kingston University http://www.hpcoders.com.au
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Are integer variables supported now?
I'm playing with predator-prey systems with low populations, so integer values are important
Also the documentation mentions sliders for changing values - can't find these?
Thanks
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
I have used floor(var + 0.5) for calculation and charting.
It has added quite a few elements to the model but seems to be working
Was going to attach a screenshot but it doesn't seem to work
If you would like to refer to this comment somewhere else in this project, copy and paste the following link:
Could someone please explain proper usage of the switch block. The example in the documentation seems to show three values (1, 2.5, and -1) based on the value of t. In psuedo code, this would be:
switch (t){
case X:
A;
case Y:
B;
case Z:
C;
else:
D;
}
The three values in the example the documentation gives seem to correspond to A, B, and C in the above example. But then how does one specify X, Y, and Z? The example seems to assume they are 0 <= t < 1, 1 <= t < 2, and t > 2 respectively. But what if the conditions are more complex than this?
Also, what happens in case none of the specified options is satisfied, as in the fourth case (D) above?
On Mon, Aug 22, 2016 at 09:39:35PM +0000, marshf wrote:
If the conditions are more complex, you need to apply a nonlinear
transformation to the input. For example, if you want X=1, Y=10,
Z=100, you would attach a log_10(x) function to the input port.
As for the else case, bear in mind that the first case is t<=0.5, and
the last case applies when t>2.5. So the last input applies to the
high portion of the else case, and the first input applies to the low
portion of the else case.
Calling it a switch statement is a somewhat poor analogy, even though
fundamentally equivalent. A better analogy is the type of piecewise
definitions used in mathematical functions - eg in the definition of a
piecewise line function:
f(x) = { x-0.5 0.5<t<=1.5 \\="" 1="" t=""> 1.5
Cheers
--
Dr Russell Standish Phone 0425 253119 (mobile)
Principal, High Performance Coders
Visiting Senior Research Fellow hpcoder@hpcoders.com.au
Economics, Kingston University http://www.hpcoders.com.au
Thanks! Maybe changing the generic name of the block from "switch" to "piecewise" would be a good idea. Certainly your explanation is very helpful when you put it this way.
Right now Minsky has no integer or modulo function. I'm trying to set up a variable that cycles through three states, {0, 1, 2}, as a function of t. E.g. assume t is set to increments of 1 unit:
x=0
if (int(t/3)=t/3)
x=0
else
x++
fi
In mathematical terms and assuming t = {0, 1, 2, ...}:
Let x= f(t) = t - [3 x int(t/3)]
But because there's no int function in Minsky, I tried to use x in the condition for a switch block, but Minsky called this cyclical and wouldn't accept it.
Is there any way to define a variable like this x in Minsky?
(Among other things, being able to do this would allow Dirac delta functions in Minsky models.)
Last edit: marshf 2016-08-23
On Tue, Aug 23, 2016 at 03:35:57PM +0000, marshf wrote:
Hmm, I don't like piecewise either. IIRC, AMSTex used the term
"choice", which might be possible, but I think the problem is the
concept has no well-used name. But it's always fun to have naming competitions!
That sounds like a reasonable thing to add, along with mod(). Why not
raise a ticket for it?
For now, you really have only two options - a rather clumsy to
construct switch block, or also you could use a data block. Either
way, you can only define your function for a finite range. I would
suggest using a data block, and using something like a perl script to
generate the data values for the range you need.
Delta functions should only appear in kernels, ie in a function fed
into the input of an integral or Godley table. You can achieve
essentially the same result by multiplying the output of that integral
by a Heaviside theta function, which is represented in Minsky by the
"<" and "<=" operators, or combination thereof.
--
Dr Russell Standish Phone 0425 253119 (mobile)
Principal, High Performance Coders
Visiting Senior Research Fellow hpcoder@hpcoders.com.au
Economics, Kingston University http://www.hpcoders.com.au
Thanks. I've created the ticket.
Are integer variables supported now?
I'm playing with predator-prey systems with low populations, so integer values are important
Also the documentation mentions sliders for changing values - can't find these?
Thanks
On Fri, Aug 14, 2020 at 01:35:42AM -0000, Martin Connolly wrote:
No - all values are real
There are frac and floor functions that split a real value into its integer and remainder parts. That might help you.
Sliders appear as little dots on parameters and flow variables without
input (which are kind of like parameters).
--
Dr Russell Standish Phone 0425 253119 (mobile)
Principal, High Performance Coders hpcoder@hpcoders.com.au
http://www.hpcoders.com.au
Thanks
I have used floor(var + 0.5) for calculation and charting.
It has added quite a few elements to the model but seems to be working
Was going to attach a screenshot but it doesn't seem to work