Introduction To Computational Models Using Python -

Transcription

Introduction to Computational Models UsingPythonCS4491José M. Garrido C.Department of Computer ScienceCollege of Computing and Software EngineeringKennesaw State UniversityJune, 2016José M. Garrido C.Introduction to Computational Models Using Python

Problem SolvingA general process of problem solving involves the followingsteps:1Understanding the problem2Describing the problem in a clear, complete, andunambiguous form3Designing a solution to the problem (algorithm)4Developing a computer solution to the problem.5TestJosé M. Garrido C.Introduction to Computational Models Using Python

Computational ModelsAn essential modeling method is to use mathematicalentities such as numbers, functions, and sets to describeproperties and their relationships to problems andreal-world systems.Such models are known as mathematical models.A computational model is an implementation in a computersystem of a mathematical model and usually requires highperformance computational resources to execute.The computational model is used to study the behavior of alarge and complex system.José M. Garrido C.Introduction to Computational Models Using Python

Developing Computational ModelsDeveloping a computational model consists of:Applying a formal software development processApplying Computer Science concepts, principles andmethods, such as:Abstraction and decompositionProgramming principlesData structuresAlgorithm structuresConcurrency and synchronizationModeling and simulationMulti-threading, parallel, and distributed computing for highperformance (HPC)José M. Garrido C.Introduction to Computational Models Using Python

Developing Computational ModelsJosé M. Garrido C.Introduction to Computational Models Using Python

A Computational ModelIs a computer model that implements thesolution to a (scientific) complex problemIt usually requires a mathematical model orrepresentation that has been formulated forthe problem.The software implementation often requireshigh-performance computing (HPC) torun.José M. Garrido C.Introduction to Computational Models Using Python

Computational ScienceComputational science is an emerging area (or discipline)that includes concepts, principles, and methods fromApplied Mathematics and Computer Science.These are applied in various areas of science andengineering to solve large-scale scientific problems.Computational modeling and computational thinking arethe foundational components of computational science andfocuses on reasoning about problems.José M. Garrido C.Introduction to Computational Models Using Python

Computational ThinkingReasoning about computer problem solvingThe ability to describe the requirements of a problem and,if possible, design a solution that can be implemented in acomputerMulti-disciplinary important problems require team workImplementation of a solution results in a computationalmodelJosé M. Garrido C.Introduction to Computational Models Using Python

Multi-disciplinary Development of ComputationalModelsApplying interdisciplinary and multi-disciplinaryapproachesIncluding perspectives from the various sciences such as:physicsbiologychemistryother disciplines.José M. Garrido C.Introduction to Computational Models Using Python

What Does Computational Science Involve?Reasoning about computer problem solvingThe problem domain is multidisciplinaryThe ability to describe the requirements of a problem and,if possible, design a solution that can be implemented in acomputerDeveloping computational models needs the application ofcomputer science principles, concepts, and methods.José M. Garrido C.Introduction to Computational Models Using Python

Multi-disciplinary and Inter-disciplinary ComputingBoth are general approaches that are very useful in developingcomputational models with teams.Multidisciplinary computing is a non-integrative mixtureof approaches from the various disciplines; each disciplineretains its methodologies and assumptions without changeor development from other disciplines within themultidisciplinary relationship.Interdisciplinary computing involves the combining of twoor more approaches each from an academic field into onesingle process. An interdisciplinary approach crossestraditional boundaries between academic disciplines.José M. Garrido C.Introduction to Computational Models Using Python

Differences Between the Two ApproachesA Multidisciplinary team approach utilizes the skills andexperience of individuals from different disciplines, witheach discipline approaching the problem from their ownperspective.Most often, this approach involves separate individualanalysis. Multidisciplinary teams provide more knowledgeand experience than disciplines operating in isolation.An interdisciplinary team approach integrates separatediscipline approaches into a single analysis. It is acommon understanding and holistic view of all aspects ofthe problem.José M. Garrido C.Introduction to Computational Models Using Python

Multi-dimensional AbstractionThe term multi-dimensional abstraction is proposed toemphasize the need to improve the development ofcomputational models with an interdisciplinary approach.For practical purposes, it involves a combined approach.Every member of the team must use abstraction to reducethe complexity of the real system to fit into the conceptualmodel.Each individual will use his/her own skills and knowledgeto determine the essential aspects of the system to model,within that part of the system that relates to their field.José M. Garrido C.Introduction to Computational Models Using Python

General Types of Computing in Computational Modelscomputing numerical values of variables that defineproperties of a systemoptimization of parameters of a system giving someconstraints (Linear and non-linear)showing the dynamical behavior of a system with time viasimulation (continuous or discrete)José M. Garrido C.Introduction to Computational Models Using Python

Some Challenges of Computational ModelingMay need to apply several notations, techniques andmethods, such as: flowcharts, pseudo-code, UMLdiagrams, and/or othersUsually applies important CS/SE concepts, such as:abstraction and decompositionRequires a mathematical representation (a formalmathematical model)Not all problems can be easily modeled with mathematicsMany mathematical models do not have a formal (closed)solutionJosé M. Garrido C.Introduction to Computational Models Using Python

Software Tools for Numerical SolutionsModeling at a high level of abstraction:General purpose scientific computing environments/tools:Matlab, Octave, FreeMat, SciLabPyLab is an extension to the Python language, its five corecomponents are Python, NumPy, SciPy, Matplotlib, andIPython.Cython is an optimizing compiler for Python.Environments/tools for continuous simulation: Simulink(Matlab), Scicos (Scilab), Stella, Vensim, SimCAD, acsIX,Dymola, JMCAD, and othersJosé M. Garrido C.Introduction to Computational Models Using Python

Improving PerformanceFor improved performance, a more efficientimplementation of the computational model is necessary.Two relevant programming languages that provide veryefficient implementations are:CFortran.These have been used for very efficient numerical andscientific programming.José M. Garrido C.Introduction to Computational Models Using Python

Enhancing the ProcessThe process of developing a computational model can beenhanced by including three levels of computerimplementation:1Prototyping, using the Matlab programming language2Improved performance implementation, using: C orFortran programming languages.3Include techniques, methods, and tools for highperformance computing (HPC).José M. Garrido C.Introduction to Computational Models Using Python

Abstraction and DecompositionAbstraction is recognized as a fundamental and essentialprinciple in problem solving and software development.Abstraction and decomposition are extremely importantin dealing with large and complex systems.Abstraction is the activity of hiding the details and exposingonly the essential features of a particular system.In modeling, one of the critical tasks is representing thevarious aspects of a system at different levels ofabstraction.A good abstraction captures the essential elements of asystem, and purposely leaving out the rest.José M. Garrido C.Introduction to Computational Models Using Python

Temperature ConversionThe process of developing a computational model is illustratedin this section with an extremely simple problem: thetemperature conversion problem.The mathematical representation of the solution to the problemis the formula expressing a temperature measurement F inFahrenheit in terms of the temperature measurement C inCelsius:9C 325Here C is a variable that represents the given temperature indegrees Celsius, and F is a derived variable, whose valuedepends on C.F José M. Garrido C.Introduction to Computational Models Using Python

Area and Perimeter of a CircleAnother simple problem is formulated and requires computingthe area and circumference of a circle, given its radius.The mathematical model is:cir 2 π rarea π r 2José M. Garrido C.Introduction to Computational Models Using Python

Categories of Computational ModelsFrom the perspective of how the model changes state in time,computational models can be divided into two generalcategories:1Continuous models2Discrete modelsA continuous model is one in which the changes of state in themodel occur continuously with time.A model that represents the temperature in a boiler as part of apower plant can be considered a continuous model.José M. Garrido C.Introduction to Computational Models Using Python

Continuous ModelJosé M. Garrido C.Introduction to Computational Models Using Python

Discrete ModelA discrete model represents a system that changes itsstates at discrete points in time, i.e., at specific instants.The model of a simple car-wash system is a discrete-eventmodel because an arrival event occurs, and causes achange in the state variable that represents the number ofcars in the queue that are waiting to receive service fromthe machine (the server).This state variable and any other only change its valueswhen an event occurs, i.e., at discrete instants.José M. Garrido C.Introduction to Computational Models Using Python

Discrete ModelJosé M. Garrido C.Introduction to Computational Models Using Python

Programming LanguagesA programming language includes a defined set of syntaxand semantic rules.There are several integrated development environments(IDE) that facilitate the development of programs.Examples of these are: Eclipse, Netbeans, CodeBlocks,and Codelite.Other tools include IDEs that are designed for numericaland scientific problem solving that have their ownprogramming language.There are several IDEs available for developing scientificapplications with Python. Some of these are: Spyder, IEP,Eric, PyDev, WingIDE, Canopy, Komodo IDE, andPycharm.José M. Garrido C.Introduction to Computational Models Using Python

Interpreters and PythonAn interpreter is a special program that performs syntaxchecking of a command in a user program written in ahigh-level programming language and immediatelyexecutes the command.Examples of interpreters are the ones used for thefollowing languages: Python, MATLAB, Octave, PHP, andPerl.The Python interpreter reads a command written in thePython programming language and immediately executesthe command.A Python program is a file of Python commands, so theprogram is also known as a script.In a terminal or command window, all the interaction with auser takes place by typing Python commands.José M. Garrido C.Introduction to Computational Models Using Python

Python InterpreterJosé M. Garrido C.Introduction to Computational Models Using Python

Working with the Python InterpreterThe command prompt is the symbol that the Pythoninterpreter displays on the window to alert the user that it iswaiting for a command.The Python prompt is and is used for interactivemode of computing with Python.In a terminal window, the user starts the Python interpretersimply by typing python at the Linux prompt. Theinterpreter starts and displays the Python prompt .Note how the Python interpreter immediately responds to acommand; this is the interactive mode of using Python.José M. Garrido C.Introduction to Computational Models Using Python

Interactive Python pythonPython 2.7.8 (default, May 20 2016, 15:20:10)[GCC 4.9.1] on linux2Type "help", "copyright", "credits" or "license" for morinformation. num 15 num15 y 20.6 y20.6 x 2.56 j 200 j200 José M. Garrido C.Introduction to Computational Models Using Python

More Operations Interactive Python z y * x 125.25 z177.986 z / 12.514.23888 José M. Garrido C.Introduction to Computational Models Using Python

Questions?José M. Garrido C.Introduction to Computational Models Using Python

Python programming language and immediately executes the command. A Python program is a file of Python commands, so the program is also known as a script. In a terminal or command window, all the interaction with a user takes place by typing Python commands. José M. Garrido C. I