Download as pptx, pdf, or txt
Download as pptx, pdf, or txt
You are on page 1of 78

Modeling and Simulation

(OEC-II)
UNIT 1: Introduction
• Programming environment,
• input and output variables,
• State variables, basic syntax;
• Deterministic linear model,
• Array mathematics in Matlab, Plotting
• Static and Dynamic systems;
• Hierarchy of knowledge about a system and Modeling Strategy
WHAT IS MODELING?
• Modeling is the process of producing a model
• a model is a representation of the construction and working of some system of interest.
• A model is similar to but simpler than the system it represents.
• purpose of a model -is to enable the analyst to predict the effect of changes to the
system.
• On the one hand, a model should be a close approximation to the real system and
incorporate most of its salient features. On the other hand, it should not be so complex
that it is impossible to understand and experiment with it.
• A good model is a judicious tradeoff between realism and simplicity.

• Simulation practitioners recommend increasing the complexity of a model iteratively.


• An important issue in modeling is model validity.
• Model validation techniques include simulating the model under
known input conditions and comparing model output with system
output.
• Model intended for a simulation study is a mathematical model
developed with the help of simulation software.
• include deterministic (input and output variables are fixed values) or
stochastic (at least one of the input or output variables is
probabilistic); static (time is not taken into account) or dynamic (time-
varying interactions among variables are taken into account).
Typically, simulation models are stochastic and dynamic.
Mathematical model classifications
• deterministic (input and output variables are fixed values)
OR
stochastic (at least one of the input or output variables is probabilistic)
• static (time is not taken into account)
OR
dynamic (time-varying interactions among variables are taken into a
account).

**Typically, simulation models are stochastic and dynamic.


WHAT IS SIMULATION?
• A simulation of a system is the operation of a model of the system.
• The model can be reconfigured and experimented with; usually, this is
impossible, too expensive or impractical to do in the system it
represents.
• The operation of the model can be studied, and hence, properties
concerning the behavior of the actual system or its subsystem can be
inferred.
• simulation is a tool to evaluate the performance of a system, existing
or proposed, under different configurations of interest and over long
periods of real time.
PURPOSE OF SIMULATION
• Simulation is used before an existing system is altered or a new
system built—
to reduce the chances of failure to meet specifications
to eliminate unforeseen bottlenecks
to prevent under or over-utilization of resources
to optimize system performance.
Example
• simulation can be used to answer questions like:

What is the best design for a new telecommunications network? What are
the associated resource requirements?
How will a telecommunication network perform when the traffic load
increases by 50%?
 How will a new routing algorithm affect its performance?
Which network protocol optimizes network performance?
What will be the impact of a link failure?
SCHEMATIC OF SIMULATION STUDY
STEPS
• steps involved in developing a simulation model, designing a
simulation experiment, and performing simulation analysis are:

Step 1. Identify the problem.


Step 2. Formulate the problem.
Step 3. Collect and process real system data.
Step 4. Formulate and develop a model.
Step 5. Validate the model.
Step 6. Document model for future use.
Step 7. Select appropriate experimental design.
Step 8. Establish experimental conditions for runs.
Step 9. Perform simulation runs.
Step 10. Interpret and present results.
 Step 11. Recommend further course of action
• Step 1 − Prepare a problem statement.

• Step 2 − Choose input variables and create entities for the simulation process. There are two types of

variables - decision variables and uncontrollable variables. Decision variables are controlled by the

programmer, whereas uncontrollable variables are the random variables.

• Step 3 − Create constraints on the decision variables by assigning it to the simulation process.

• Step 4 − Determine the output variables.

• Step 5 − Collect data from the real-life system to input into the simulation.

• Step 6 − Develop a flowchart showing the progress of the simulation process.

• Step 7 − Choose an appropriate simulation software to run the model.

• Step 8 − Verify the simulation model by comparing its result with the real-time system.

• Step 9 − Perform an experiment on the model by changing the variable values to find the best solution.

• Step 10 − Finally, apply these results into the real-time system.
Modelling & Simulation ─ Advantages
• Easy to understand − Allows to understand how the system really operates
without working on real-time systems.
• Easy to test − Allows to make changes into the system and their effect on
the output without working on real-time systems.
• Easy to upgrade − Allows to determine the system requirements by
applying different configurations.
• Easy to identifying constraints − Allows to perform bottleneck analysis
that causes delay in the work process, information, etc.
• Easy to diagnose problems − Certain systems are so complex that it is not
easy to understand their interaction at a time. However, Modelling &
Simulation allows to understand all the interactions and analyze their effect.
Additionally, new policies, operations, and procedures can be explored
without affecting the real system.
Modelling & Simulation ─ Disadvantages

• Designing a model is an art which requires domain knowledge,


training and experience.
• Operations are performed on the system using random number, hence
difficult to predict the result.
• Simulation requires manpower and it is a time-consuming process.
• Simulation results are difficult to translate. It requires experts to
understand.
• Simulation process is expensive.
Modelling & Simulation ─ Application Areas
• Military applications, training & support, designing semiconductors,
telecommunications, civil engineering designs & presentations, and E-business models.

• Used to study the internal structure of a complex system such as the biological system.

• It is used while optimizing the system design such as routing algorithm, assembly line,
etc.

• It is used to test new designs and policies.

• It is used to verify analytic solutions.


Programming environment
• Programming environment combines hardware and software that
allows a developer to build applications.
• Developers typically work in integrated development environments or
IDEs. These connect users with all the features necessary to write and
test their code correctly. 
• IDEs afford developers a convenient workspace when embarking on a
project by packaging all the development tools a developer needs into
a single graphical user interface.
Examples Of Programming Environments

• Visual Studio is an IDE developed by Microsoft. 


NetBeans
• Primarily used for Java projects, NetBeans is a great open-source option 
• Its drag-and-drop user interface as well as its number of project templates make it ideal for all
levels of experience.
Simulation Environment
• Simulator provides with a simulation environment, i.e. a programming
environment dedicated to simulation.
• A simulation environment is defined as a programming environment
of a computer, that is dedicated to systems simulation and that takes
care for a flexible and intelligent interfacing between a user
(experimenter) and the system to be experimentally studied. 

Modeling Environments
provides a software-technical abstraction layer, which separates the
thermodynamical or physical model from the software engineering details of
the process simulation environment. 
e.g. MATLAB
Input and output variables
In simulation analysis-
• The behavior of a system is studied by generating an artificial history
of the system through the use of random numbers.

• simulation model is the mathematical, logical and symbolic


representation of the relationships between the objects of interest of
the system. 
Example
Classic inventory problem - newsvendor problem.  
• A newsvendor buys papers for 33 cents each and sells for 50 cents.  Newspapers
not sold are sold as scrap (recycled) for 5 cents.  Newspapers are purchased by the
paper seller in bundles of 10.  Demand for newspapers can be categorized as
“good,” “fair,” or “poor” with probability 0.35, 0.45 and 0.20 respectively, with
each day's demand being independent of prior days.  The problem for the
newsvendor is to determine the optimal number of papers to purchase when the
day's demand is not yet known.
• The daily profit equation for the newsvendor is:
Profit = [(Sale revenue) - (Cost) - (Scrap value)]
Variables: Sale revenue, Cost and Scrap value,Profit
State variable

• A state variable is defined as a measurable physical property that depends on the present state
of the system

• A state variable is one of the set of variables that describe the current “state” of a dynamical system.
• The state of a system describes about the system in the current instant of time and helps to determine
its future behavior. 

“ state variable is one of the variables used to describe the state of a dynamical system.”

• Eg: Ideal Gas Law equation -> PV = nRT


P = pressure, V = volume, T = absolute temperature, n = no. of moles and R = Ideal Gas
constant ( just a number which remains constant)
so- here we have 3 state variables which are the pressure, volume and temperature
Deterministic linear model

• The deterministic linear model serves as the basis for evaluating theoretical models.
• It is expressed as: Yi=α+βXi
• A deterministic model is systematic and contains no error, therefore Y is perfectly predicted
by X.

• Here α and β are the model parameters, and are constant terms. 


β is the slope, or the change in Y over the change in X. 
α is the intercept, or the value of Y when X is zero.
***However, we rarely work with deterministic models, nearly all models contain a stochastic,
or random, component.
Stochastic Linear Model

• The stochastic, or statistical, linear model contains


a systematic component, Y=α+β, and
a stochastic component called the error term.

• The error term is the difference between the expected value of Yi and
the observed value of Yi; i.e Yi−μ.

• This model is expressed as: Yi=α+βXi+ϵi


where ϵi is the error term.
Array mathematics in Matlab
MATLAB  has two different types of arithmetic operations:
®

array operations
matrix operations.

Used to perform arithmetic operations and numeric computations, like adding


two numbers, raising the elements of an array to a given power, or multiplying
two matrices.

• Matrix operations follow the rules of linear algebra.


• Array operations execute element by element operations and support
multidimensional arrays.
Array Operations

• Array operations execute element by element operations on


corresponding elements of vectors, matrices, and
multidimensional arrays.

• If the operands have the same size, then each element in the
first operand gets matched up with the element in the same
location in the second operand. 
Example: adding two vectors with the same size.
Operations in MATLAB
Matrix Operations
Plotting in MATLAB
Static and Dynamic systems
Static Simulation

• Static Simulation is a simulation model which has no internal history of both


output and input values that were previously applied.
• It also represents a model in which time is not a factor.
• This type of simulation model usually has some function (f) which is made
of inputs (u).
• Each output in this type of simulation is dependent on the values of the function
(f) and inputs (u).
Dynamic Simulation
• Here a computer program is used to determine the varying behavior
of the system at different times or in different scenarios.

• It maintains an internal memory comprised of prior inputs, internal


variables and outputs.
Hierarchy of knowledge
• Aim- to take best decision in within time..
• Need- qualitative and quantitative filtering mechanism for decision
making process you can help make better decisions in a shorter
period of time. 
• Solution- hierarchy of knowledge
• Data: Raw data is comprised of disparate facts, statistics, or random pieces of
information that in-and-of-themselves hold little value. Making conclusions based
on data in its raw form will lead to flawed decisions based on incomplete data
sets.

• Information: Information is simply an evolved, or more complete data set.


Information is therefore derived from a collection of processed data where context
and meaning have been added to disparate facts which allow for a more thorough
analysis.

• Knowledge: Knowledge is information that has been refined by analysis such that
it has been assimilated, tested, and/or validated. Most importantly, knowledge is
actionable with a high degree of accuracy because proof of concept exists.
• Coursera – Introduction to Programming with MATLAB
Basic matlab codes
Task 1:

Plot the simple function y = x for the range of values for x from 0 to 100, with an increment of 5.
Task 2
•  to plot the function y = x2
Task 3: To make previous curve smoother
Task: Adding Title, Labels, Grid Lines and Scaling on the Graph

• The xlabel and ylabel commands generate labels along x-axis and y-


axis.
• The title command allows you to put a title on the graph.
• The grid on command allows you to put the grid lines on the graph.
• The axis equal command allows generating the plot with the same
scale factors and the spaces on both axes.
• The axis square command generates a square plot.
Task:
• Drawing Multiple Functions on the Same Graph
Task: Setting Colors on Graph
Task: Draw 2 coloured graphs
• Draw graph of 2 polynomials
Task: Generating Sub-Plots

• WE can create an array of plots in the same figure


• each of these plots is called a subplot.
• The subplot command is used for creating subplots.
Task: Draw 2 graphs using subplot
• Draw graph of 2 polynomials

subplot(1,2,1)
Array creation in MATLAB
Concatenation of Arrays in MATLAB

We can concatenate the arrays in two ways:


• Horizontally
• Vertically
Horizontal Concatenation of Arrays in MATLAB
Vertical Concatenation of Arrays in
MATLAB

You might also like