Presentation is loading. Please wait.

Presentation is loading. Please wait.

GoldSim Monthly Webinar Series. Goals  Learn the basics of simple scripts  Learn the basics of the GoldSim Script Element  Not a lesson on numerical.

Similar presentations


Presentation on theme: "GoldSim Monthly Webinar Series. Goals  Learn the basics of simple scripts  Learn the basics of the GoldSim Script Element  Not a lesson on numerical."— Presentation transcript:

1 GoldSim Monthly Webinar Series

2 Goals  Learn the basics of simple scripts  Learn the basics of the GoldSim Script Element  Not a lesson on numerical methods

3 What is a Script?  A set of instructions  Carried out by another program  Instructions are executed and something(s) is (usually) returned as output  Script languages are easier and faster to code in

4 Why use the Scripts?  Clarify complex logic Nested IF statements Iterate through items of an array  Condense equations Repetitive equations Long series of equations  Numerical solution required Iterative solvers like bisection

5 Different Ways in GoldSim  GoldSim elements, looping containers  Equations in Excel produce output that is read by GoldSim  External functions connected to GoldSim DLL Element  Write a script inside GoldSim Script Element

6 Advantages of the Script  All in one program  Transparent  No need to learn a new language

7 Main Functions  Variable definition  Variable assignment  Flow control (i.e. IF, looping, break)  Comments  Log Statements

8 Variable Definition  Syntax: Define: peak_price = 0.0 $/m3  Declaration: Number (float: double precision) or Boolean scalar or non-scalar  Initialize to a value  Description  Expose as Output

9 Variable Assignment  Syntax: ~peak_price = 50 $/m3 Result = ~peak_price  Local vs. Global variables

10 For Loop  Loop Variable, Start Value, Loop while Condition, Increment by  Syntax: FOR (i = 0; ~i < 10; i = ~i + 1) {do some work} END FOR

11 DO Loop  Loop Variable, Start Value, End Value, Increment by  Syntax: DO i = 0, 10, 1 {do some work} END DO

12 REPEAT-UNTIL Loop  Loop until true: Some Condition  Syntax: REPEAT {do some work} UNTIL (~price > 30 $/m3)

13 WHILE Loop  Loop while true: Some Condition  Syntax: WHILE (~price < 10 $/m3) {do some work} END WHILE

14 BREAK and CONTINUE  Only allowed inside Loop structures  BREAK Break out of a loop Breaks the nearest enclosing loop  CONTINUE Transfer control to the bottom of the loop Used to skip to the next loop without executing block in the loop

15 Comments  Document the operation of the program  Intended for others and yourself  Max 100 characters  Ctrl-Enter extra lines only seen in printout  White space

16 Log Statements  Message Message to Run Log No warning  Warning Message Warning dialogue message  Error Message Simulation is stopped with dialogue message

17

18 Prioritize Days By Price Save days as numbers in a vector in order of greatest unit price to lowest. Only show values that meet criteria.

19 Peak Price Days 8 2 1 7 9

20 Formulation  Save all values to an array of days  Loop thru the list (array)  If the max(list) is <= $0/m3, then done!  Stuff the day of max price to temp variable  Assign temp to Result Array at current index  Remove the current max price from list  Loop

21 Create Table of Best Days Dayprice 10.84147 20.9093 30.14112 4-0.7568 5-0.95892 6-0.27942 70.65699 80.98936 90.41212 10-0.54402 Best days 18 22 31 47 59 63 7 8 9 10

22 Final Result

23


Download ppt "GoldSim Monthly Webinar Series. Goals  Learn the basics of simple scripts  Learn the basics of the GoldSim Script Element  Not a lesson on numerical."

Similar presentations


Ads by Google