Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 1 Advanced topics.

Slides:



Advertisements
Similar presentations
Copyright © 2002 Pearson Education, Inc. Slide 1.
Advertisements

Chapter 9 – One-Dimensional Numeric Arrays. Array u Data structure u Grouping of like-type data u Indicated with brackets containing positive integer.
Introduction to C Programming
Brown Bag #2 Advanced C++. Topics  Templates  Standard Template Library (STL)  Pointers and Smart Pointers  Exceptions  Lambda Expressions  Tips.
Arrays.
How SAS implements structured programming constructs
Python Mini-Course University of Oklahoma Department of Psychology Lesson 28 Classes and Methods 6/17/09 Python Mini-Course: Lesson 28 1.
Programming Languages and Paradigms The C Programming Language.
ITEC 320 Lecture 3 In-class coding / Arrays. Arrays Review Strings –Advantages / Disadvantages Input –What two methods are used? Conditionals Looping.
Making Choices in C if/else statement logical operators break and continue statements switch statement the conditional operator.
Introduction to Programming Lesson 1. Objectives Skills/ConceptsMTA Exam Objectives Understanding Computer Programming Understand computer storage and.
© Copyright 1992–2005 by Deitel & Associates, Inc. and Pearson Education Inc. All Rights Reserved. Tutorial 14 – Student Grades Application: Introducing.
More loops Horstmann Ch 7 continued.. The do-loop continue- condition ? loop-body statements next statement false true WHILE-LOOP continue- condition?
Scripting Languages Chapter 6 I/O Basics. Input from STDIN We’ve been doing so with $line = chomp($line); Same as chomp($line= ); line input op gives.
Case, Arrays, and Structures. Summary Slide  Case Structure –Select Case - Numeric Value Example 1 –Select Case - String Value Example  Arrays –Declaring.
1 Java intro Part 3. 2 Arrays in Java Store fixed number of values of a given type Arrays are objects –have attributes –must be constructed Array declaration:
Module: Definition ● A logical collection of related program entities ● Not necessarily a physical concept, e.g., file, function, class, package ● Often.
Introduction to Computers and Programming for Loops  2000 Prentice Hall, Inc. All rights reserved. Modified for use with this course. Introduction to.
©2004 Brooks/Cole Chapter 8 Arrays. Figures ©2004 Brooks/Cole CS 119: Intro to JavaFall 2005 Sometimes we have lists of data values that all need to be.
More on Numerical Computation CS-2301 B-term More on Numerical Computation CS-2301, System Programming for Non-majors (Slides include materials from.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays –Structures of related data items –Static entity (same size throughout program) A few types –Pointer-based.
1 JavaScript: Functions and Arrays October 18, 2005 Slides modified from Internet & World Wide Web: How to Program (3rd) edition. By Deitel, Deitel,
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
Program structure Four different storage-class specifications: –Automatic (auto): local to a function, normally declared variables are automatic. Does.
Fall 2006AE6382 Design Computing1 OOP: Creating a Class More OOP concepts An example that creates a ASSET class and shows how it might be used Extend the.
A First Book of ANSI C Fourth Edition
ENGR 3950U / CSCI 3020U: Operating Systems Description and C Code of Major Functions in Simulated Unix File System. Instructor: Dr. Kamran Sartipi Faculty.
Arrays Module 6. Objectives Nature and purpose of an array Using arrays in Java programs Methods with array parameter Methods that return an array Array.
Hello.java Program Output 1 public class Hello { 2 public static void main( String [] args ) 3 { 4 System.out.println( “Hello!" ); 5 } // end method main.
Object-Oriented Program Development Using Java: A Class-Centered Approach, Enhanced Edition.
DATA STRUCTURES LAB 1 TA: Nouf Al-harbi
Built-in Data Structures in Python An Introduction.
CS Midterm Study Guide Fall General topics Definitions and rules Technical names of things Syntax of C++ constructs Meaning of C++ constructs.
OOP in Java : © W. Milner 2005 : Slide 1 Java and OOP Part 2 – Classes and objects.
Data Collections: Lists CSC 161: The Art of Programming Prof. Henry Kautz 11/2/2009.
CS161 Topic #16 1 Today in CS161 Lecture #16 Prepare for the Final Reviewing all Topics this term Variables If Statements Loops (do while, while, for)
Copyright 2003 Scott/Jones Publishing Standard Version of Starting Out with C++, 4th Edition Chapter 5 Looping.
Files Tutor: You will need ….
The assignment expressions. The assignment operator in an assignment statement We have seen the assignment statement: Effect: var = expr; Stores the value.
CreatingClasses-SlideShow-part31 Creating Classes part 3 Barb Ericson Georgia Institute of Technology Dec 2009.
Arrays. The array data structure Array is a collection of elements, that have the same data type Integers (int) Floating point numbers (float, double)
By Mr. Muhammad Pervez Akhtar
ICS3U_FileIO.ppt File Input/Output (I/O)‏ ICS3U_FileIO.ppt File I/O Declare a file object File myFile = new File("billy.txt"); a file object whose name.
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 1 Aggregates, output and other basic tools.
Chapter 8 Arrays. A First Book of ANSI C, Fourth Edition2 Introduction Atomic variable: variable whose value cannot be further subdivided into a built-in.
Functions Structured Programming. Topics to be covered Introduction to Functions Defining a function Calling a function Arguments, local variables and.
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 1 4. Basic concepts, a rudimentary model, and input data (demo01.yml)
Arrays.
Computer Programming for Engineers
CSC Java Programming, Fall, 2008 Week 3: Objects, Classes, Strings, Text I/O, September 11.
Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 1 Playing with Objects.
SEQUENTIAL AND OBJECT ORIENTED PROGRAMMING Arrays.
Loops. Review Control Structure – making decisions if-statement Program Design Understand what you want to do Design your solution Write and test your.
Chapter 9: Coupling & Cohesion Omar Meqdadi SE 273 Lecture 9 Department of Computer Science and Software Engineering University of Wisconsin-Platteville.
CS Class 04 Topics  Selection statement – IF  Expressions  More practice writing simple C++ programs Announcements  Read pages for next.
Announcements Assignment 2 Out Today Quiz today - so I need to shut up at 4:25 1.
Arrays. Arrays are objects that help us organize large amounts of information.
Chapter 5 Arrays Copyright © 2016 Pearson, Inc. All rights reserved.
Winter 2016CISC101 - Prof. McLeod1 CISC101 Reminders Quiz 3 next week. See next slide. Both versions of assignment 3 are posted. Due today.
Quiz 3 Topics Functions – using and writing. Lists: –operators used with lists. –keywords used with lists. –BIF’s used with lists. –list methods. Loops.
Introduction to Programming Lesson 1. Algorithms Algorithm refers to a method for solving problems. Common techniques for representing an algorithms:
PHP and SQL Server: Connection IST 210: Organization of Data IST2101.
Java Programming Language Lecture27- An Introduction.
® IBM Software Group © 2006 IBM Corporation EGL.CSV (Excel) File Reading and Writing This section describes how to access.CSV (Excel Spreadsheet) files.
 2003 Prentice Hall, Inc. All rights reserved. 1 Arrays Outline 1 Introduction 2 Arrays 3Declaring Arrays 4Processing Array Contents 5 Multiple-Subscripted.
Two-Dimensional Arrays
Scripts & Functions Scripts and functions are contained in .m-files
JavaScript: Functions.
Advanced Programming Behnam Hatami Fall 2017.
Introduction to Programming
Presentation transcript:

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 1 Advanced topics

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 2 Topics 1.Advanced globals 2.Import other models 3.Functions with arguments 4.Loops

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 3 Advanced globals

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 4 Globals - in csv file globals: periodic: path: param\globals.csv fields: # PERIOD is implicit - WEMRA: float  No need to reimport dataset when globals change  Different globals with same dataset (variants)  Usage is the same

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 5 globals: othertable: path: param\othertable.csv fields: # PERIOD is NOT implicit - PERIOD: int - INTFIELD: int - FLOATFIELD: float […] processes : test_globals : - result : othertable.INTFIELD - result : othertable.INTFIELD[period] Globals - other tables with PERIOD field

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 6 globals: othertable2: fields: - INTFIELD: int […] processes: test_globals: # explicit index - result: othertable2.INTFIELD[0] # expr index - row_number: trunc((period ) / 10) - result: othertable2.INTFIELD[row_number] Globals - other tables without PERIOD field Row 0

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 7 globals: ARRAY: type: float MIG: path: param\mig.csv type: float […] processes: test_globals: - result: MIG * 2.5 Globals - (multi dimensional) arrays

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 8 Import other models (demo09.yml)

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 9  Re-use other model(s) inside a model/file  Usage  Split large model files  Variants  How? Merge !  "importing model" items replaces "imported model" items with the same name new fields can be added, existing fields definitions are replaced if present functions can be added, existing functions can be (completely) replaced (simulation) processes lists: replaced if present  each file does not need to be a valid model (only the merged result)! Imports

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 10 import: imported.yml # Or import: - imported1.yml - imported2.yml entities: [everything that changes] simulation: [everything that changes] Imports - format

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 11 import: demo08.yml entities: person: fields: # additional field not present in the base model # (nor in the input in this case) - study_years_failed: {type: int, initialdata: False} processes: # we override the ineducation process ineducation: - … Imports - small example

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 12 Functions with arguments

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 13 function_name(arg1, arg2): - code - return result other_func: - result: function_name(value1, value2) Functions with arguments

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 14 myaverage(a, b): - c: a + b - return c / 2 other_func: # 1.5 (scalar) - result1: myaverage(1, 2) # one value per person - result2: myaverage(age, partner.age) Functions with arguments - example

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 15 While loops

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 16 - while scalar_condition : - the_code_to_repeat  condition must be a scalar expression  single value for all individuals  number of iterations is always the same for all individuals count_to_5: - i: 1 - while i <= 5: - show(i) - i: i + 1 while loops

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 17 while loops repeat_while_below_1: - score: age / max(age) - while score < 1: # <-- this line is WRONG ! - score: score show(score) ValueError: The truth value of an array with more than one element is ambiguous.Use a.any() or a.all()

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 18 while loops repeat_while_below_1: - score: age / max(age) - while any(score < 1): - score: score show(score) repeat_while_below_1: - score: age / max(age) - while any(score < 1): - score: if(score < 1, score + 0.1, score) - show(score) Or

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide 19 Exercises (demo05.yml)

Autumn School Dynamic MSM16-18 November 2015 | L-Esch-sur-Alzette Slide Split "demo05.yml" into "demo05fields.yml" containing fields definition and "demo05rest.yml" and run "demo05rest.yml" to check it works 2. Create "demo05variant.yml"  reuse (import -- do NOT modify it in place) demo05.yml  change agegroup to be groups of 5 years including for people 50+  put all output in a directory called "output_variant" Exercises - imports