Model building by mouse
You can do quite a bit of modeling and creating definitions without typing -- just by drawing arrows between variables or modules.
- Draw an arrow from Index
I
into variableA
- This lets you add (or remove) Index
I
as a dimension ofA
. IfI
is not an input ofA
already, it asks if you want to addI
as an extra dimension ofA
. If so, it makesA
into an Edit table (if it isn't already), and addsI
as a dimension. It also asks if you want to repeat the old definition ofA
in each slide of the table overI
. If not, it puts the old definition in the first slice and fills the rest as zeros. If I is already an index ofA
, it asks if you want to remove it as a dimension (and warns that doing so will lose data.) If yes, it sets the definition ofA
as the first slice overI
of the old array.
- Delete an arrow
- If there is an arrow from variable
A
toB
, you can delete it
- either by selecting the arrow and pressing "delete" key,
- or, in arrow mode, by redrawing the arrow from
A
toB
.
If A
is already in the definition of B
, it asks if you want to remove A
from the Definition of B
. If yes, it puts comment brackets around A, {A}
, in the definition of B
, so you can see what was removed. Usually, the resulting definition will have bad syntax, indicated by the node for B
becoming cross-hatched.
- Redraw a deleted arrow
- If you delete an input to
B
as above, and then redraw an arrow fromA
toB
, it restores the original definition by removing the comment brackets{A}
around the variable,A
.
- Draw an arrow into a list
- If you draw an arrow from
A
toB
, andB
contains a list in square brackets, such as: B := Sum([X])
- If
A
isn't already in the list, it addsA
:
B := Sum([X, A])
- Or, if the origin variable, say
X
, is already in the list, it removes it:
B := Sum([A])
- Repeated parameters
- If
B
uses a function whose first parameter is qualified as Repeated (or "..."), it behaves like an explicit list in square brackets. For example,
Function ObjList(vars: ... Variable) B := Objlist(X) draw an arrow from A to B B := Objlist(X, A)
Note: "Repeated" means one or more elements. If you remove the last input by redrawing an arrow from A
to B
, it replaces it by "expr", which will not parse. If you want zero or more elements, you should qualify the parameter with Optional along with "...", for example:
Function ObjList(vars: ... Optional Variable)
By using these methods, you can define functions that let you wire together complex models simply by drawing arrows between nodes -- without having to edit their definitions explicitly.
- Module templates
- You can even construct models by drawing arrows to and from modules, if the modules are set up as templates. A Template module should have one of its variables as the TemplateInput attribute of the module, and another variable as the TemplateOutput attribute. When you draw an arrow into a template module, it's the same as drawing an arrow into its template input variable. And when you draw an arrow from the module, it's the same as drawing an arrow from the template output variable. So, if the definition of the Template input variable contains a list [] or uses a function with a repeated parameter, drawing an arrow inserts the origin variable into the list. It's often useful to create a template module and then make copies of it for particular instantiations. You can link them together by drawing arrows.
Enable comment auto-refresher