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

Slides:



Advertisements
Similar presentations
While loops.
Advertisements

Chapter 41 Variables and JSP Control Structures JavaServer Pages By Xue Bai.
Working with JavaScript. 2 Objectives Introducing JavaScript Inserting JavaScript into a Web Page File Writing Output to the Web Page Working with Variables.
Program Design and Development
Pseudocode and Algorithms
Tutorial 10 Programming with JavaScript
ECE122 L11: For loops and Arrays March 8, 2007 ECE 122 Engineering Problem Solving with Java Lecture 11 For Loops and Arrays.
Programming with JavaScript (Chapter 10). XP Various things Midterm grades: Friday Winter Career Fair – Thursday, April 28, 2011 (11 am to 3 pm). – MAC.
C++ Basics Structure of a Program. C++ Source Code Plain text file Typical file extension .CPP Must compile the C++ source code without errors before.
ASP.NET Programming with C# and SQL Server First Edition Chapter 3 Using Functions, Methods, and Control Structures.
Lecture 4 C Program Control Acknowledgment The notes are adapted from those provided by Deitel & Associates, Inc. and Pearson Education Inc.
1 JavaScript in Context. Server-Side Programming.
XP Tutorial 10New Perspectives on Creating Web Pages with HTML, XHTML, and XML 1 Working with JavaScript Creating a Programmable Web Page for North Pole.
Tutorial 10 Programming with JavaScript
Done by: Hanadi Muhsen1 Tutorial 1.  Learn the history of JavaScript  Create a script element  Write text to a Web page with JavaScript  Understand.
CPS120: Introduction to Computer Science Decision Making in Programs.
Chapter 2 Functions and Control Structures PHP Programming with MySQL 2 nd Edition.
What does C store? >>A = [1 2 3] >>B = [1 1] >>[C,D]=meshgrid(A,B) c) a) d) b)
Visual Basic Programming
CONTENTS Processing structures and commands Control structures – Sequence Sequence – Selection Selection – Iteration Iteration Naming conventions – File.
XP Tutorial 10New Perspectives on HTML and XHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties Tutorial.
Chapter 3 Functions, Events, and Control Structures JavaScript, Third Edition.
Chapter 15 JavaScript: Part III The Web Warrior Guide to Web Design Technologies.
Lecture 26: Reusable Methods: Enviable Sloth. Creating Function M-files User defined functions are stored as M- files To use them, they must be in the.
Digital Image Processing Lecture 6: Introduction to M- function Programming.
Digital Image Processing Introduction to M-function Programming.
 In computer programming, a loop is a sequence of instruction s that is continually repeated until a certain condition is reached.  PHP Loops :  In.
1 JavaScript in Context. Server-Side Programming.
ITERATION. Iteration Computers are often used to automate repetitive tasks. Repeating identical or similar tasks without making errors is something that.
Chapter 1 Java Programming Review. Introduction Java is platform-independent, meaning that you can write a program once and run it anywhere. Java programs.
STEP 3- DEVELOP AN ALGORITHM At this stage we break down the problem into simple manageable steps so that they can be handled easily.
Copyright 2006 Addison-Wesley Brief Version of Starting Out with C++ Chapter 5 Looping.
Arrays and Loops. Learning Objectives By the end of this lecture, you should be able to: – Understand what a loop is – Appreciate the need for loops and.
JavaScript and AJAX 2nd Edition Tutorial 1 Programming with JavaScript.
XP Tutorial 10New Perspectives on HTML, XHTML, and DHTML, Comprehensive 1 Working with JavaScript Creating a Programmable Web Page for North Pole Novelties.
Introduction to Programming G50PRO University of Nottingham Unit 6 : Control Flow Statements 2 Paul Tennent
C Program Control September 15, OBJECTIVES The essentials of counter-controlled repetition. To use the for and do...while repetition statements.
PHP using MySQL Database for Web Development (part II)
CIS199 Test Review 2 REACH.
Information and Computer Sciences University of Hawaii, Manoa
Software Testing.
Chapter 4 – C Program Control
Tutorial 10 Programming with JavaScript
ALGORITHMS AND FLOWCHARTS
Think What will be the output?
Miscellaneous Items Loop control, block labels, unless/until, backwards syntax for “if” statements, split, join, substring, length, logical operators,
Scripts & Functions Scripts and functions are contained in .m-files
CiS 260: App Dev I Chapter 4: Control Structures II.
JavaScript: Control Statements I
Agenda Control Flow Statements Purpose test statement
Loops CS140: Introduction to Computing 1 Savitch Chapter 4 Flow of Control: Loops 9/18/13 9/23/13.
Chapter 5 Structures.
While Loops BIS1523 – Lecture 12.
Chapter 5 Repetition.
Arrays, For loop While loop Do while loop
Conditional Statements
MATLAB – Basic For Loops
Types of Flow of Control
Coding Concepts (Basics)
Matlab tutorial course
Variables Title slide variables.
LabVIEW.
Objectives In this chapter, you will:
CPS120: Introduction to Computer Science
2. Second Step for Learning C++ Programming • Data Type • Char • Float
FLUENCY WITH INFORMATION TECNOLOGY
Introduction to Programming
Repetition Structures
CIS 136 Building Mobile Apps
Introduction to Python
Presentation transcript:

GoldSim Monthly Webinar Series

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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

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.

Peak Price Days

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

Create Table of Best Days Dayprice Best days

Final Result