{ From user Lonnie, Model Tunnel_through_earth at 20-Aug-2012 12:18:41 PM } SoftwareVersion 4.4.3 { System Variables with non-default values: } Time := Sequence( 0, 8000, Inc ) Units Time: sec Description Time: Dynamic simulation periods are specified in Time's definition. This is usually a list of numbers or labels, typically in some unit of time (days, weeks, months, etc.). Use the “Dynamic()” function in your variables to perform dynamic simulation. UseTable := 0 TypeChecking := 1 Checking := 1 SaveOptions := 2 SaveValues := 0 {!40400|Sys_AllNullTreatment := 1} Model Tunnel_through_earth Title: Tunnel through the earth Description: Imagine a tunnel passing through the earth, perfectly straight and directly through its center. If you step into it, how long will it take you to emerge on the other side? How fast will you be traveling as you pass the center of the earth? Find out with this simple dynamic simulation of the trip. Author: Lonnie Chrisman, Ph.D.~ Lumina Decision Systems Date: Wed, Sep 15, 2004 5:23 PM SaveAuthor: Lonnie SaveDate: Mon, Aug 20, 2012 12:18 PM DefaultSize: 48,24 DiagState: 2,25,16,550,300,17 WindState: 2,282,42,476,224 FontStyle: Arial, 15 FileInfo: 0,Model Tunnel_through_earth,2,2,0,0,W:\Testmodels\12946.ana Constant Radius Title: Radius of the Earth Units: m Definition: 6350K NodeLocation: 88,56,1 NodeSize: 48,24 NodeInfo: 1,1,0,1,1,1,0,,0, WindState: 2,215,103,476,224 Variable R Title: Position Units: m Description: Your position, as a distance from the center of the earth, as a function of time. Definition: dynamic(radius,r[Time-1] + v[Time-1]*inc) NodeLocation: 208,56,1 NodeSize: 48,24 WindState: 2,38,339,476,224 ValueState: 2,220,13,650,303,1,MIDM NumberFormat: 1,D,8,2,0,0 Variable V Title: Velocity Units: m/s Description: We start at zero velocity as we step into the tunnel.~ Then g, the gravity acceleration, takes over. Definition: dynamic(0,v[Time-1] + g[Time-1]* inc ) NodeLocation: 328,56,1 NodeSize: 48,24 ValueState: 2,286,58,416,303,1,MIDM Variable G Title: Acceleration Units: m/s^2 Description: The force of acceleration due to gravity inside a solid sphere is a linear function of the distance to the center. On the surface, it is about -10 m/s^2. Definition: -10 * r/radius NodeLocation: 264,128,1 NodeSize: 56,24 ValueState: 2,56,66,416,303,1,MIDM Constant Inc Title: Simulation increment Units: sec Description: Increment of time used for the simulation. Definition: 1 NodeLocation: 88,128,1 NodeSize: 48,24 NodeInfo: 1,1,0,1,1,1,0,,0, ValueState: 2,257,113,416,303,0,MIDM Library Performance_profiler Title: Performance Profiler Description: Use this library to see which variables and functions are taking most of the computation time or memory when running your model. You need Analytica Enterprise, Power Player, or ADE - it will not work for lesser editions of Analytica. Here's how to use it:~ ~ 1. First run your model, i.e. show (and therefore compute) results for the outputs you are interested in timing.~ ~ 2. Click the "Performance profiles" button to display the Bytes (memory used) and CPU msecs (milliseconds of computation time by the computers "Central Processing Unit") for each object (variable or function). ~ ~ NOTES:~ A. Select option from "Sort objects by" to control how results are sorted.~ ~ B. It omits objects with negligible CPU time (less than 1 millisecond) AND less than 25 Bytes memory.~ ~ C. "msecs w. ancestors" means the CPU time to compute the object PLUS all its ancestors or predecessors.~ ~ D. "Bytes" shows the memory usage after computing the variable. Some objects with complex expressions may use much more memory during the computation.~ ~ E. In Performance Profiles, double-click on an Object title (in Object_ID index or its Module title to open its Object window.~ ~ If you want to add in the time for further calculations:~ ~ 3. Make those calculations by showing results for those variables.~ ~ 4. Click button "Update Profiles"~ ~ 5. Click the "Performance profiles" button again.~ ~ If you want to time some different calculations:~ ~ 6. Click "Zero out times"~ ~ 7. Change relevant inputs to cause their dependents to need to be recomputed.~ ~ 8. Show results for outputs of interest.~ ~ 9. Click button "Update Profiles"~ ~ 10. Click the "Performance profiles" button to see the new timings and memory usage.~ ~ Copyright 2007 Lumina Decision Systems, Inc Author: Lonnie Chrisman & Alex Graham Date: Sun, Jul 13, 2003 12:18 PM SaveAuthor: Lonnie SaveDate: Thu, May 26, 2011 2:37 PM NodeLocation: 128,200,0 NodeSize: 64,32 NodeInfo: 1,1,1,1,1,1,0,0,0,0, DiagState: 2,346,68,366,151,21 WindState: 2,372,189,507,744 {!40400|Att_clearTypeFonts: 1} Button Zero_out_times Title: Zero out times Description: Zeros all computation times, so that only the times of subsequent computations will be shown. NodeLocation: 248,40,1 NodeSize: 48,24 Script: ResetEvalTimes~ Reset_profiler := 1~ Button Update_profiles Title: Update profiles Description: Sets the profiles to recompute, adding in any further computation time since profiles were last generated. NodeLocation: 64,40,1 NodeSize: 48,24 WindState: 2,39,304,476,224 Script: (Reset_profiler := Reset_profiler+1) FormNode Sort_profiled_objec1 Title: Sort profiled objects by Definition: 0 NodeLocation: 175,84,1 NodeSize: 161,12 NodeInfo: 0,0,0,0,0,0,0,170 Original: Sort_objects_by FormNode Ordered_profiles1 Title: Ordered profiles Definition: 1 NodeLocation: 175,112,1 NodeSize: 161,12 NodeInfo: 1,0,0,1,0,0,0,120,0,1 Original: Performance_profiles Text Te7 NodeLocation: 176,68,-1 NodeSize: 168,60 NodeInfo: 1,0,0,0,1,1,0,,0, Module Profiler_details Title: Profiler details Author: Max Henrion Date: Wed 03-Oct-07 8:20 AM DefaultSize: 48,24 NodeLocation: 168,168,1 NodeSize: 48,24 DiagState: 2,377,221,454,301,21 Function Profiler_descendants(m: Object) Title: Profiler_Descendants(m) Description: Returns a list including module m and all its descendants, i.e. objects (variables, functions, and modules) contained in m - and in any modules it contains, recursively -- excluding this Profiling module. Definition: METAVAR res := [Handle(m)];~ METAVAR c := contains OF m ;~ IFONLY IsNull(c) OR Identifier m = Id_of_this_library THEN res~ ELSE BEGIN ~ FOR v := c Do BEGIN~ METAVAR d := Profiler_descendants(v);~ res := Concat(res, d);~ 0~ END; ~ res~ END NodeLocation: 152,184,1 NodeSize: 104,24 WindState: 2,47,141,580,585 Recursive: 1 Decision Sort_objects_by Title: Sort objects by Description: Select field to sort profiled objects. "CPU secs" or "KBytes" are most useful. "Class" doesn't work. Definition: Choice(Profiler_fields,4,0) NodeLocation: 336,248,1 NodeSize: 48,24 WindState: 2,102,90,523,465 Aliases: FormNode Sort_profiled_objec1 {!40200|Att_ChoiceIndexes: Index Profiler_fields} Index Profiler_fields Title: Profiler fields Definition: ['Class','Module','Bytes','CPU msecs','msecs w ancestors'] NodeLocation: 96,54,1 NodeSize: 48,24 {!40000|Att_PrevIndexValue: ['Class','Module','Bytes','CPU msecs','msecs w ancestors']} Variable Attrib_name_by_profi Title: Attrib name by profile field Definition: Table(Profiler_fields)(~ 'Class',0,'Memory','EvaluationTime','EvaluationTimeAll') NodeLocation: 208,55,1 NodeSize: 48,31 DefnState: 2,352,26,430,218,0,MIDM Function Profileobj(o: atomic handle) Title: ProfileObj(o) Description: Returns a profile (with Class, Bytes, Memory, CPU seconds, CPU seconds w ancestors) for the object with identifier o. Definition: FOR field := Profiler_fields DO~ IFONLY field = 'Module' THEN (Isin OF o)~ ELSE IF field = 'Bytes' THEN MemoryInUseBy(Handle(o))~ ELSE (VAR attrib := Attrib_name_by_profi[Profiler_fields=field]; ~ IF attrib ='Class' THEN (attrib OF o) ELSE (attrib OF o)*1000) NodeLocation: 336,54,1 NodeSize: 56,24 WindState: 2,432,9,541,583 Function Profileall() Title: ProfileAll() Description: Returns a profile (with Class, Bytes, CPU msecs, msecs w ancestors) for all the variables in this model whose CPU msecs>0 or Bytes > 24, excluding those in the Profiler. Definition: MetaVar top := topmodel_id;~ MetaIndex allobjs := Profiler_descendants(top);~ METAVAR allProfiles := Profileobj(allobjs);~ MetaIndex Objs := Subset(allProfiles[Profiler_fields='CPU msecs'] > 0 OR~ allProfiles[Profiler_fields='Bytes'] > 24 OR~ allProfiles[Profiler_fields='msecs w ancestors']);~ allProfiles[allobjs = Objs] NodeLocation: 336,120,1 NodeSize: 56,24 WindState: 2,438,69,525,397 Variable Topmodel_id Title: TopModel ID Definition: Reset_profiler; METAVAR m := Isin OF Self;~ WHILE (NOT IsUndef(Isin OF m )) DO m := Isin OF m NodeLocation: 208,118,1 NodeSize: 48,24 Variable Performance_profiles Title: Performance profiles Description: Shows the Class, Kbytes (memory used), CPU secs (to compute this object), CPU secs w. ancestors (time to compute this variable and all its predecessors) for all objects (variables and functions) with non-zero computation time, sorted as requested. Definition: VAR Profiles := Profileall();~ var sortField := Profiles[Profiler_fields=Sort_objects_by];~ if Sort_objects_by<>"Class" then sortField := -sortField;~ MetaIndex object_id := SortIndex(sortField, Profiles.Objs);~ Profiles[.Objs = object_id] NodeLocation: 336,184,1 NodeSize: 56,24 WindState: 2,102,90,497,494 ValueState: 2,508,534,700,255,0,MIDM Aliases: FormNode Ordered_profiles1 GraphSetup: {!40000|Att_graphvaluerange Performance_profiles:1,,,,,,10}~ {!40000|Att_graphindexrange Profiler_fields:1,,,,,,10}~ {!40000|Flip:8}~ {!40000|Att_catlinestyle Graph_primary_valdim:9} ReformVal: [Profiler_fields,Sys_LocalIndex('OBJECT_ID')] NumberFormat: 1,I,6,3,1,0 {!40000|Att_ResultSliceState: [Profiler_fields,2,Sys_localindex('OBJECTS_IDS'),1]} Variable Reset_profiler Title: Reset Profiler Description: Used to reset the computations for profiling. Definition: 0 NodeLocation: 96,118,1 NodeSize: 48,24 Variable Id_of_this_library Title: ID of this library Definition: Identifier(Isin OF (Isin OF Self)) NodeLocation: 152,248,1 NodeSize: 48,24 Close Profiler_details Close Performance_profiler Close Tunnel_through_earth