Difference between revisions of "Draw arrows to build models"

(new page copied and edited from release notes)
 
(Correct and expanded)
Line 1: Line 1:
 
These new and improved features let you build and modify model expressions just by drawing arrows between variables -- without typing:
 
These new and improved features let you build and modify model expressions just by drawing arrows between variables -- without typing:
  
* If you draw an arrow from index I to variable A defined as a Table (or a ProbTable, DetermTable), if I is not an index of A, it will ask if you want to add I as an extra dimension of A. If I is already an index of A, it will ask if you want to remove it.  
+
; Draw arrow from index into Table node: Suppose variable A defined as a Table (or a ProbTable, DetermTable) and you draw an arrow from Index I to node A: If I is not an index of A, it asks if you want to add I as an extra dimension of A. If yes, it adds I as a dimension, and copies the existing array value of A into each new element over I.  If I is already an index of A, it asks if you want to remove it, and warn that doing so will lose data. If yes, it the new definition of A is the first slice  over I of the old array.  
  
* If you draw an arrow from array A to B and A is already in the definition of B:
+
; Redraw or delete an arrow: If you draw an arrow from variable A to B and 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. The resulting definition will often not parse, so the node for B becomes cross-hatched. It does the same if you delete an arrow -- select the arrow and press the "delete" key.
* Deleting arrows or input variables: If you delete an arrow from A to B (select and press "delete" key, or just redraw an arrow), Analytica changes the definition of B. It used to substitute "expr" in place of A and surround the entire definition with [[FunctionOf]](...).  That was inconvenient and lost information about the former input.  Now, if the Mid value of A is a scalar (single number or text), it substitutes it into the definition of B. Otherwise, it replaces A by '{A}' (a comment).  Or if you delete A, it doesn't change the definition of B, but B will no longer parse, and its node is cross-hatched.  
 
  
* Auto definitions: If you draw an arrow from A to B:
+
; Redraw a deleted arrow: If you delete an input to B as above, and then redraw an arrow from A to B, it restores the original definition by removing the comment brackets {A} around the variable, A.
** If B is a list of zero or more variables ''not including'' A, or if B is a function call whose first parameters is such a list, it adds A into the list. For example
+
 
 +
; Arrow into a list: If you draw an arrow from A to B, and B contains a list, enclosed in square brackets, such as
 
   B := Sum([X])
 
   B := Sum([X])
   draw an arrow from A to B
+
* It adds A into the list (if it wasn't already in it)"
   B := Sum([X, A])
+
   B := Sum([X, A])
 +
* Or if you draw an arrow from a variable X into B that is already in the list, it removes the origin variable from the list: 
 +
   B := Sum([A])
  
** If B is a list of variables ''including'' A, or is a function whose first parameter is such a list, it removes A from the list. For example,
+
; Repeated parameters: If B uses a function whose first parameter is Repeated (ellipsis or "..."), it behaves much the same as an explicit list in square brackets. For example,
  B := Sum([X, A])
+
  Function ObjList(vars: ... Variable)
  draw an arrow from A to B
 
  B := Sum([X])
 
** If B uses a function whose first parameter is an ellipsis (repeating) variable, it similarly adds A (or removes A if it is already there). For example,
 
  Function ObjList(vars: ... Optional Variable)
 
 
  B := Objlist(X)
 
  B := Objlist(X)
 
     draw an arrow from A to B
 
     draw an arrow from A to B
 
  B := Objlist(X, A)
 
  B := Objlist(X, A)
Note: If you want Objlist to have no parameters, you must use the '''Optional''' qualifier along with "..." -- otherwise, the function needs at least one parameter.
 
** If you draw an arrow from index I to and Edit table B, if B is not indexed by I, it  askif you want to add I as an index. If so, it adds the index to the table, repeating the current value over each value of I. If B is already indexed by I, it will ask if you want to remove I as an index. If so, the new value of B will be the first slice of its old value over I. It will lose all other data.
 
 
* When you drag a nodes into a module, or use the "Move to Parent" action, the location of the node in the module is not so crammed up so tightly in the top-left corner.
 
  
* Undo also works for:
+
Note: "Repeated" usually 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:
** Move Into Parent
+
  Function ObjList(vars: ... Optional Variable)
** Move node(s) using the arrow keys
 
  
* A couple UI glitches fixed: Stray compute button, result windows immediately recomputing after invalidation.
+
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.

Revision as of 03:18, 23 September 2008

These new and improved features let you build and modify model expressions just by drawing arrows between variables -- without typing:

Draw arrow from index into Table node
Suppose variable A defined as a Table (or a ProbTable, DetermTable) and you draw an arrow from Index I to node A: If I is not an index of A, it asks if you want to add I as an extra dimension of A. If yes, it adds I as a dimension, and copies the existing array value of A into each new element over I. If I is already an index of A, it asks if you want to remove it, and warn that doing so will lose data. If yes, it the new definition of A is the first slice over I of the old array.
Redraw or delete an arrow
If you draw an arrow from variable A to B and 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. The resulting definition will often not parse, so the node for B becomes cross-hatched. It does the same if you delete an arrow -- select the arrow and press the "delete" key.
Redraw a deleted arrow
If you delete an input to B as above, and then redraw an arrow from A to B, it restores the original definition by removing the comment brackets {A} around the variable, A.
Arrow into a list
If you draw an arrow from A to B, and B contains a list, enclosed in square brackets, such as
 B := Sum([X])
  • It adds A into the list (if it wasn't already in it)"
  B := Sum([X, A]) 
  • Or if you draw an arrow from a variable X into B that is already in the list, it removes the origin variable from the list:
 B := Sum([A])
Repeated parameters
If B uses a function whose first parameter is Repeated (ellipsis or "..."), it behaves much the same as 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" usually 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.

Comments


You are not allowed to post comments.