soph 303 the digital world term 3 spring 2013 notes for january 28, 2013 last update: january 28,...

Download SOPH 303 The Digital World Term 3 Spring 2013 Notes for January 28, 2013 Last update: January 28, 2013 Aditya Mathur Head of Pillar Information Systems

If you can't read please download the document

Upload: dorothy-crawford

Post on 17-Dec-2015

214 views

Category:

Documents


1 download

TRANSCRIPT

  • Slide 1
  • Slide 2
  • SOPH 303 The Digital World Term 3 Spring 2013 Notes for January 28, 2013 Last update: January 28, 2013 Aditya Mathur Head of Pillar Information Systems Technology and Design Singapore University of Technology and Design Singapore http://faculty.sutd.edu.sg/~aditya_mathur
  • Slide 3
  • This is the first lecture in 10.009 Term 3 2 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 4
  • And the last! 3 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 5
  • Today 4 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Digital World: What is this class about? What is problem solving and programming? Our expectations of you Digital World: Why is it a required subject? Let us browse the course web site Introduction to Tutor and a quiz Reference material, grading, and tools Our instructors Design competition and 2D challenge
  • Slide 6
  • Digital World 5 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Physical World
  • Slide 7
  • Our approach to teaching and learning? 6 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Play and learn Solve lots of problems Do not be turned off by error!
  • Slide 8
  • Digital World 7 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Physical World Enabling technology Control technology Provides flexibility Provides variety Provides connectivity
  • Slide 9
  • What is Digital World? 8 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 It is a world of computers, embedded and otherwise it is a world where computers are used to perform a variety of tasks or help us perform tasks.. it is a world where computer hardware and software play a key role in our lives it is a world that integrates well with the physical world to add to flexibility and quality
  • Slide 10
  • Is Digital World Computer Science? 9 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Yes and no but Computer Science is one of the key drivers of the Digital World.. and so are Computer Engineering, Electrical Engineering, and Mathematics and almost everybody is a user of the Digital World!
  • Slide 11
  • You will learn the basic drivers of the digital world 10 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Problem solving and programming and how the digital world interfaces with the physical world Controlling a physical device [robot] for movement and search What will I learn?
  • Slide 12
  • 11 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Programming language used 2.73.3 Listen to Python Our snake
  • Slide 13
  • Course Web Site and Other Resources 12 The Digital World. Term 3. 2013. Week 1. Session 1 Python Resources: A Primer on Scientific Programming with Python, Hans Petter Langtangen Think Python, Allen B Downey Online resources: Python tutorialPython tutorial MIT notes on Python and linear systems 1/28/2013 Course Web site: http://faculty.sutd.edu.sg/~aditya_mathur Technical Q&A: www.piazza.com
  • Slide 14
  • Drivers (and the essential elements) of the Digital World 13 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 15
  • Problem solving Top down problem solving: How to break a problem into smaller problems, find solutions to the smaller problems and combine them to get a solution to the original problem. Bottom up problem solving: How to combine solutions to small problems into a solution to a large problem. Coding: How to code the solution to a problem in Python and let the computer solve the given problem. 14 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Debugging: How to locate errors in your program (and correct them).
  • Slide 16
  • Modularity How to build components (modules) that can be reused. Example: (a) A software module to solve a first order differential equation. (b) A hardware module that gives the current location of a mobile object. 15 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 PolynomialRoot finder Root presenter User interface User What are the modules in this diagram?
  • Slide 17
  • Abstraction The process of reducing a real life system, or an idea, to its essentials. Example: A stick-person is an abstraction of a real person. 16 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Root finder Polynomial System stability analyzer
  • Slide 18
  • Modeling Representation of one or more aspects (behavioral in our case) of a component or a system. Example: Diagrammatic description of the behavior of a system. 17 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 System: Coke vending machine 50c 50c/-- 50c/dispense coke Simple model Can you complete this state diagram for a machine of your choice? $1 50c Screen showing how much money is to be deposited
  • Slide 19
  • Design and the PCAP approach A basis set of primitive components 18 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 are combined to create complex components (or systems) by the process of abstraction that creates new primitive components that become new abstractions and patterns. Can you describe your favorite device using the above approach? [E.g. your mobile phone?]
  • Slide 20
  • Fun in the Digital World 19 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 There is a lot of---sometimes too much---fun in the Digital World. Fun with the Amigobot: Hey man! Follow the leader! The Amigobot You will learn how to program and control the Amigobot. Follow wall smooth: http://www.youtube.com/watch?v=nv6IJYBRYgg Follow wall oscillating: http://www.youtube.com/watch?v=r7ux5E8SW2g
  • Slide 21
  • Expectations 20 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Most of us know next to nil about programming. So a slower pace during the course will be greatly appreciated...if not it'll be like MATLAB...from one of you posted on Piazza.
  • Slide 22
  • Please note. Classes will begin on time. Please be at your seat a few minutes before the class begins and, if you have to, then leave only after the class ends. All students are encouraged to ask questions and participate during the cohort sessions. You may interrupt the instructor at any time. No question is a stupid question. The instructors are here to help you learn. Make full use of the instructors. We want you to succeed in this class. We will do all we can to help you succeed; this is our primary responsibility as instructors at SUTD. 21 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 23
  • Assumptions You have little or no expertise in computer programming using Python. You are hard working. You will not sleep during classes, and if you do, please do not snore! You will not use phones during class for any other purpose than specified by the instructor. Please, no phone calls received or sent. You will not disturb others by talking to your neighbors except when the instructor requests discussion during problem solving time. You will try to participate in the class by asking questions and responding to questions asked by the instructor. 22 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 24
  • Impact of Assumptions Those who know Python well may get bored during the first six weeks of this course but others may find the pace quite appealing. For those with some Python experience, we recommend solving advanced homework problems just for fun. You should skip the class if you need to discuss important matters with your friends. But skipping a class is not a good idea! So maybe you might consider rescheduling the important matters with your friend. 23 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 25
  • Expectations: Academic Honesty Unless specified otherwise, all assignments and exams are to be completed by you without assistance from anyone other than the course instructors. Please read carefully the Policies page on the course web site. 24 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 26
  • Expectations: Attendance We expect you to attend all cohort sessions during the term. Attendance is not mandatory but highly recommended. If you miss a cohort session then it is your responsibility to (a) learn on your own the material covered (b) find out if there were any announcements that might affect your course grade. 25 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 There will be no makeup for a quiz given during the cohort session.
  • Slide 27
  • Reference material, grading, and tools 26 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 28
  • Textbook There is no textbook for this course. Please use the online and other material available in the library. 27 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 29
  • Leave Please submit your leave application to the Cohort Section Manager (see Office Hours page of the course web site to find your section manager). Leave will be granted only for medical and emergency reasons. You may miss up to two quizzes without affecting your course grade. 28 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 30
  • Grading ComponentWeight (%) Midterm Exam15 (Friday March 8, 2013. 2:30-4:30pm) Cohort exercises 20 Homework 10 Quizzes10 Final Exam25 2D Designette15 Class participation5 TOTAL 100 Relative grading 29 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 31
  • Exams and quizzes All exams (not quizzes) will be open internet implying that you will be able to access and use the Internet content to help solve problems on the exam. 30 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 All in-class exercises will be completed by teams of two or three students.
  • Slide 32
  • Tools PiazzaPiazza: Please register yourself by visiting the Piazza site (www.piazza.com). You may post your questions at this site. You may answer student questions at this site. Instructors will be regularly browsing this site and answer your questions. 31 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Tutor: For homework, exams, and grading IDLEIDLE: For editing Python programs
  • Slide 33
  • Feedback Weekly feedback: via Learning CatalyticsLearning Catalytics Tell us how are we doing? 32 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Weekly feedback: open Tell us in an open forum what needs to improve. Constructive criticism of the class is highly appreciated.
  • Slide 34
  • Why is The Digital World a required subject? 33 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 35
  • I am interested in architecture. I do not like programming. I would rather get a C or a D in this class and get outta here! 34 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 But wait a minute my friend..
  • Slide 36
  • 35 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Do you know about Blender 3D Architect?Blender 3D Architect Well, it is a tool for 3D architectural visualization. Architects require knowledge in modeling, lighting, animation... But do they also need to know scripting? Python for architectsPython for architects. One of the things that I keep saying to all my students is that if they want to work with big and complex projects in Blender, they must learn how to work with Python to create custom tools and scripts to accelerate the creation process. This is a rule for, Allan Brito, Allan Brito Architecture Systems Design
  • Slide 37
  • If you have the time and are interested, read this: Redefining the role of computers in architecture: from drafting/modelling tools to knowledge-based design assistants Yehuda E. Kalay School of Architecture and Environmental Design, State University of New York at Buffalo, Buffalo, NY 14214, USA 36 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Computer-Aided Design Volume 17, Issue 7, September 1985, Pages 319328 http://python.rhino3d.com/content/130-RhinoPython-primer http://wiki.mcneel.com/developer/python http://www.plethora-project.com/2011/09/12/rhino-python-tutorials/ Want to know more about Python for architecture?
  • Slide 38
  • I am interested in Engineering Systems Design. I do not like programming. I would rather get a C or a D in this class and get outta here! 37 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 But wait a minute my friend..
  • Slide 39
  • 38 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 How does one design large transportation systems? How does one find the optimal path in a complex terrain? Optimization using Python How does one create and implement efficient and effective component supply chains across multiple countries for complex products such as aircrafts or ships? Engineering Systems Design Nearly all systems of today use computers in their design, implementation and maintenance.
  • Slide 40
  • I am interested in Engineering Product Design. I do not like programming. I would rather get a C or a D in this class and get outta here! 39 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 But wait a minute my friend..
  • Slide 41
  • 40 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 How does one design the controller for your car? Or for the MRT train? Or for. Fortunately Python is a great tool for those looking to apply the tools of science to product design. Python can help with everything from statistical analysis, to rapid development of viable products, to the creation of complex models that can be used to tweak the levers of growth, and its easy to combine these with off the shelf tools that help you analyze traffic patterns and figure out what product changes actually make a difference. Mark Ramm for EuroPython 2012 Mark Ramm Python for control systems Engineering Products Design
  • Slide 42
  • 41 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Engineering Products Design: Sample optimization problem The problem we present here is a paraboloid that is a function of two design variables. The optimization goal is to find the minimum values of this function over the design space. For the simplest form of this problem, there are no constraints, and we assume that the analytical derivative of the objective function is unavailable. Click here for details:here
  • Slide 43
  • 42 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Engineering Products Design: Auxiliary Power Unit On Tuesday, investigators will convene in Tucson, Arizona to test and examine the charger for the battery, and download non-volatile memory from the APU controller, with similar tests planned at the Phoenix facility where the APUs are built. Other components have been sent for download or examination to Boeing's Seattle facility and manufacturer facilities in Japan.. Yahoo News January 21, 2013
  • Slide 44
  • 43 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Engineering Products Design: Sample Python script from openmdao.main.api import Component from openmdao.lib.api import Float class Paraboloid(Component): """ Evaluates the equation (x-3)^2 + xy + (y+4)^2 = 3 " # set up interface to the framework x = Float(0.0, iotype='in', desc='The variable y') y = Float(0.0, iotype='in', desc='The variable x) f_xy = Float(0.0, iotype='out', desc='F(x,y)') def execute(self): """ Solve (x-3)^2 + xy + (y+4)^2 = 3 Optimal solution (minimum): x = 6.6667; y = -7.3333 " x = self.x y = self.y self.f_xy = (x-3.0)**2 + x*y + (y+4.0)**2 - 3.0 Create models of complex systems Find optimal solutions to problems
  • Slide 45
  • Hey! I have no problems with The Digital World! We live in it all the time. Hence, I better learn what it is all about! 44 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Yippe!
  • Slide 46
  • Let us now browse the course Web site 45 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 47
  • Let us learn to use Tutor 46 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 48
  • Week 1: Cohort Session 2 Self Check Quiz 47 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 49
  • Check Q1: I have written programs that 48 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) are 1000 or more lines of code. (b) are less than 1000 but around 100s of lines of code. (c) are very small. (d) do not exist (never wrote one).
  • Slide 50
  • Check Q2: The binary equivalent of decimal number 9 is 49 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 0101 (b) 1101 (c) 1001 (d) 1011
  • Slide 51
  • Check Q3: If your mobile phone has 4KB of memory then it has 50 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 4000 bytes (b) 4096 bytes (c) 4000 bits (d) 4096 bits
  • Slide 52
  • Check Q4: When talking of computer memories, 1K corresponds to 51 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 1000 (b) 1023 (c) 1024 (d) 100000
  • Slide 53
  • Check Q5: The base of the decimal number system is 52 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 4 (b) 2 (c) 10 (d) 8
  • Slide 54
  • Check Q6: The base of the binary number system is 53 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 4 (b) 2 (c) 10 (d) 8
  • Slide 55
  • Check Q7: A dual-core processor has 54 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 4 CPUs (b) 2 CPUs (c) 4 CPUs each with 16MB of RAM (d) 2 CPUs each with 16MB of RAM
  • Slide 56
  • Check Q8: Which of the following is NOT a computer programming language 55 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) Python (b) Java (c) Scratch (d) MIT
  • Slide 57
  • Check Q9: Which of the following is NOT a computer operating system 56 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) Python (b) OS X (c) Windows 8 (d) Unix
  • Slide 58
  • Check Q10: Which one of the following numbers cannot be represented in one word of a computer that uses 4-bits/word to represent integers using 2s complement. 57 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 (a) 5 (b) 3 (c) 16 (d) -1
  • Slide 59
  • Week 1: Cohort Session 2 January 28-Feb 1, 2013 Problem Solving and OO Programming 58 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 60
  • What is problem solving? Problem solving refers to a set of activities performed in order to solve a given problem. This is a generic term and applies to all disciplines, not only to Computer Science. Sequence of steps for solving a problem as proposed by George Polya in the 1950s : 59 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Understand the problem Devise a plan [Design] Execute the plan [Code, Test etc] Review solution
  • Slide 61
  • What is OO programming? OO, or Object Oriented, programming refers to a set of activities that lead to a computer program, written in an object-oriented language, that when executed on a computer will solve a problem. Python is an OO language used in SOPH 303. Other OO languages include C++, Java, C#, Delphi, Modula, Oberon, Objective C, Simula, Smalltalk, and many more! 60 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 62
  • What is Problem solving and OO programming? Problem solving and OO programming refers to a set of activities that allow the mapping of a problem to a computer program, written in an object-oriented language, that when executed on a computer will solves the problem. 61 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Understand the problem Design a solution using objects Implement the design in an OO language Test, debug, and correct the program
  • Slide 63
  • Example 1: Problem solving Problem: Find the maximum in a given set of N integers. Step 1: Understand the problem 1. We know what is a set, an integer and what does maximum mean. 2.Can N be zero? Can N be negative? We assume that N>0. 3.Suppose the given set is: {4, -5, 29, 4}. N=4. 4.The maximum in this set is 29. 62 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 64
  • Example 1: Problem solving: Sequential program Find the maximum Pictorial representation of a sequential algorithm: Output: max integer in S Input: Given set Sequential computation 63 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 65
  • Example 1: Sequential program Step 2: Design a sequential solution 1.Let S denote the given set. 2.Let S.next() denote the next element from the set. S.next() is empty if we have examined all elements of S. 3.Let currentMax=S.next(); 4.Scan each element of S until we have scanned all. The following two steps are performed for each element in S starting from the second. a)Let newElement=S.next(); b)If currentMax
  • Slide 66
  • Example 1: Sequential program Step 3: Implement the design as a well documented program in an OO language We will write a Python program later in this course. Step 4: Test, debug, and correct the program We will do this after we have written the program. 65 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 67
  • Example 3: Problem Solving Problem: Given real numbers a, b, and c, compute the value of the following expression: 66 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Step 1: Understand the problem This one is easy! So let us say we have understood the problem!
  • Slide 68
  • Example 3: Problem Solving: Sequential Solution 67 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 1: Get a, b, and c. 2: Compute x=b*b 3: Compute y=4*a*c 4: Compute z=x-y 5: Compute p= 6: Output p Step 2: Design a sequential solution
  • Slide 69
  • Discussion What differences do you notice in the two problems? 68 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 What impact would these differences have on a concurrent solution? We solved the problem assuming a dual core computer. Would your solution be different of it were to for a quad-core computer? A concurrent program consists of sequential and concurrent steps. Why? What impact do these steps have on the total time to solve a problem on a multi-core computer?
  • Slide 70
  • Week 1: January 28-Feb 1, 2013 Python program compilation 69 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013
  • Slide 71
  • The edit, compile, execute cycle 70 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013 Edit a Python program Compile your program Execute your program Syntax error Run time Error or incorrect output No syntax error Program correct In SOPH 303 we shall use IDLE for editing, compiling and execution. IDLE is a development environment for Python programs..Python file(s).py file(s)
  • Slide 72
  • Week 1: January 28, 2013 Hope you enjoyed week! 71 The Digital World. Term 3. 2013. Week 1. Session 1 1/28/2013