Unit II: Building, Understanding and Exploiting Data

You might also like

Download as pdf or txt
Download as pdf or txt
You are on page 1of 48

Advanced knowledge of Spreadsheets (T2.

3)

Unit II: Building, understanding and


exploiting data.
T2.3. Data analysis: solver and scenarios

Jose María Álvarez


Course 2018/2019

1
Advanced knowledge of Spreadsheets (T2.3)

Unit II

Unit I Unit II

A first contact. Building, understanding


and exploiting data.

Unit III
Representation of data and
information, task automation
and applications

2
Advanced knowledge of Spreadsheets (T2.3)

T2.3: Data analysis: solver and scenarios


Structure and Basic
Operations

Working with cells and


Block I: First contact sheets, importing data
and references

Task automation*

Formulas and functions

Tables and Pivot Tables


Block II: Building,
Course Syllabus interpreting and
exploiting data Data analysis: solver
and scenarios

Task automation*.

Visualization and
dynamic charts

Block III:
Representation of data Forms and applications
and information

Task automation*.

3
Advanced knowledge of Spreadsheets (T2.3)

Context

• So far we know MSExcel functions and formula to


mainly analyze past information:
• Census
• Experiments
• Etc.
• Can we use MSExcel to forecast data?
• What happened if data is incomplete?
• What happened if there are different possibilities to solve a
problema?
• Best y peor caso
• E.g.: scheduling, optimization, etc.
• Is it posible to use techniques such as linear regression?

4
Advanced knowledge of Spreadsheets (T2.3)

Some capabilities MSExcel…

• Impact of the different values in some variable

Scenarios • E.g.: Which is my benefit if the tax fee changes?

• Get the value of some variable

Goal seek • E.g.: What grade do I have to get to meet the requirement of average grade?

• Type of problem: optimization, cost-Benefit analysis, etc.


• Subjected to some constraints
• Formal foundations: linear programming and integer linear programming
• Get the value of some variables
Solver • Generalization of the goal seeker problem

• E.g.: Which products do I have to manufacturer to get the maximum Benefit?

5
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: problem

Predict the impact change Multiple variables


of some variable • They can be combined
• E.g.: How a change in the tax fee
impacts my benefit?

Design scenarios
depending on the variables
to change
• Values are introduced and a
report is automatically
generated.

6
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: concept

Define Change the


those variable
Define a Get a
Define a variables values to
global summary
context that may check the
objective report
impact my impact
benefit (scenario)

7
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: application
Impact of the
tax fee in my
benefits

Tax fee

Benefit

Change from
18 to 21%

Generate a
summary
report

8
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: implementation
• MSExcel provides use capabilities to define Scenarios
• In general, the next steps will be done:
• Go to tab “Data”:
• Data→”What-if analysis”→Scenario Manager
• Operations:
1. Add scenario
• Name: descriptive name
• Changing cells
• Comment: documentation
2. Delete
3. Edit
4. Merge
5. Summary

9
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: tax fee example

Example 1:

• Given data from different franchises in terms of gross


income (I) and direct costs (C) and assuming that the
benefit of each franchise (Bfi) is calculated as follows:
• Bfi = (Ifi – Cfi)-(Ifi*IVA)
• A scenario must be defined to determine to what
extent a raise from 18 to 21% in the tax fee affects to
the benefits.

10
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: example tax fee

11
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: example tax fee

12
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: example tax fee

13
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: example tax fee

14
Advanced knowledge of Spreadsheets (T2.3)

Scenarios: evaluation

Improve the documentation


It seems like something and data management.
“simple” that can be easily • Separation of data and variables.
handle with formula and • Definition of multiple scenarios.
functions. • Merge of scenarios.

15
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: problem

Predict the value of some


Multiple variables could
variable and its impact in
change.
a global function.

Possibility to combine
with “Scenarios”

16
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: concept

Review the
Define a
Define the Solve a impact in
Prepare global
variable to value for the global
data objective
be inferred the variable objective
function
function

17
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: implementation


• MSExcel provides us capabilities to seek for goals.
• In general, the next steps will be done:
• Go to tab “Data”:
• Data→What-if analysis→Goal Seek
• Operations:
1. Goal Seek

18
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: average grade

Example 2:
• To apply for an Erasmus grant it is necessary to have an
average grade of 8 out of 10.
• Currently, we have the following grades:
Course Grade
A 8
B 7
C 7
D ????
E 8
• What grade is necessary to meet the requirement of the
Erasmus grant in regards to the average grade?

19
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: example average grade

Prepare Define the Define a Seek the


data variable to global value of the Review the
• Grade table predict objective variable impact of
• Grade in function • Goal seek in the new
course D • Average MSExcel value
grade

20
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: example average grade

21
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: example average grade

22
Advanced knowledge of Spreadsheets (T2.3)

Goal seek: evaluation

A solution for simple


It can be manually done! problems
(no so complex to not • Infer the value of one variable
make a manual calculation) • Test of all possible values (no
search optimization)

High implementation costs


• Depending on all possible values
• Complexity of the objective
function

23
Advanced knowledge of Spreadsheets (T2.3)

Solver: problem
Objective function Decision variables
• Depends on decision variables • Subjected to constraints
• Goal: solve the values of those
decision variables

Type of problems Formal foundations (operations


• Maximize vs Minimize research)
• Optimization, cost-Benefit analysis, • Linear programming
scheduling, etc. etc. • Integer programming

24
Advanced knowledge of Spreadsheets (T2.3)

Solver: concept

• Linear programming
• Scope:
• Research operations
• Given:
• n variables x1,... ,xn.
• m linear inequalities in those variables.
• 3x1 + 4x2 ≤ 6,
• 0 ≤ x1 ≤ 3, etc.
• An an objective function:
• E.g..: 2x1 + 3x2 + x3.
• Objective:
• Seek the values of xi ’s that satisfy the constraints and max/min the
objective function.

25
Advanced knowledge of Spreadsheets (T2.3)

Solver: concept

• Linear programming (elements):


• Decision variables:
• All positive, >= 0
• Constraints (types):

• A = known value that must be strictly respected;


• B = known value that must be respected or exceeded;
• C = known value that must not exceeded;
• j = number of the equation, variable 1 to M (total number of constraints);
• a; b; and, c = known coefficients;
• X = unknown values, from 1 to N;
• i = number of the unknown value, variable from 1 to N.

26
Advanced knowledge of Spreadsheets (T2.3)

Solver: concept

• Linear programming (elements):


• Objective function

Where
coefficients

https://www.math.ucla.edu/~tom/LP.pdf
https://www.cs.cmu.edu/~avrim/451f11/lectures/lect1101.pdf

27
Advanced knowledge of Spreadsheets (T2.3)

Solver: concept

• Integer programming:
• Conceptually speaking, it represents a kind of subset of
linear programming problems.
• Values of decision variables are ALWAYS INTEGER (no real
values):
• Xi integer
• E.g.: people to assign tasks

28
Advanced knowledge of Spreadsheets (T2.3)

Solver: concept

Define Define Define Select Solver


decision constraints objective technique
variables • Inequalities function • Algorithm:
Prepare data • Type: Real vs • Maximize simplex,
Integer genetic, etc.
• Minimize
• Characteristics:
all different,
binary, etc.

29
Advanced knowledge of Spreadsheets (T2.3)

Solver: implementation
• MSExcel provides us capabilities to
solve linear and integer programming
problems: Solver
• In general, the next steps will be
done:
• Enable the add-in “Solver”
• File→Options→Add-ins→”Solver”
• Additionally, just to know, it is
possible to enable the
component “Data analysis”
(Analysis ToolPak)
• Statistical inference
• Random numbers
• Statistical tests
• …

30
Advanced knowledge of Spreadsheets (T2.3)

Solver: implementation

• Access to the “Solver” add-in:


• Data→Solver

31
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

Example 3:
• We want to add new products to our breakfast, and we
have the following options:
• Tuna, marmalade (strawberry), bread and energy drink.
• However, it is necessary to meet the next requirements
in terms of nutrients:

Calories 500
Protein 10
Fat 20

Carbs 50

32
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

• Furthermore, we do not want to spend too much


money. We want to minimize the overall cost.

• Given this situation:


• Get a list of products (quantity) to be introduced in our
breakfast meeting the requirements about nutrients and
minimizing the cost.

33
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

Define Define Define Select


Prepare decision constraints objective Solver
data variables • Inequalities function technique
• Type: Real on nutrients • Minimize cost • Simplex LP

34
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

35
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

36
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

• Set objective:
• Cell that contains the
objective function (quantity
of product x cost)
• To:
• Minimize (cost)
• Decision variables:
• Values to be inferred by the
solver
• Constraints:
• Restrictions on nutrients
• Solving method:
• The basic one: Simplex LP

37
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

38
Advanced knowledge of Spreadsheets (T2.3)

Solver: example diet

39
Advanced knowledge of Spreadsheets (T2.3)

Solver: Game of Thrones (GOT)


Example 4:

• The final battle in Game of Thrones is approaching. Jon Snow


and Daenerys are planning the requirements in terms of military
strength to win the battle against the “White Walkers”.
• To do so, they have made an initial evaluation of their military
strength:
• Resources and strength of each ally.
• Resources and strength of the “White Walkers”
• Now, they need to request resources to each ally but:
• The allies do not want to give the 100% of their resources, they need to
have some resources to protect their lands.
• The objective will be then:
• Request the minimum number of resources to win the final battle
against the “White Walkers” but keeping the constraints of resources for
each of their allies.

40
Advanced knowledge of Spreadsheets (T2.3)

Solver: example GOT

Define Define Define Select


decision constraints objective Solver
Prepare variables • Inequalities function technique
data • Type: Integer on military • Minimize • GRG Non-
(soldiers) resources for resources Linear
each ally (soldiers)

41
Advanced knowledge of Spreadsheets (T2.3)

Solver: example GOT

42
Advanced knowledge of Spreadsheets (T2.3)

Solver: example GOT

43
Advanced knowledge of Spreadsheets (T2.3)

Solver: example GOT


• Set objective:
• Cells that contains the sum of
military strength
• To:
• Minimize the number of military
resources (soldiers or dragons)
• Decision variables:
• Request of military resources
• Constraints:
• Accomplish with the need of
reserved resources.
• Values MUST be INTEGER in all
decision variables.
• It is necessary to win the military
strength of the “White Walkers”
• Solving method:
• GRG Non-linear (just to test)
• It has implications on the
performance (time to solve the
problem)

44
Advanced knowledge of Spreadsheets (T2.3)

Solver: example GOT

45
Advanced knowledge of Spreadsheets (T2.3)

Solver: evaluation

Complex problems Formal foundations


• Also known as “NP-Hard”. • Operations research
• Manual solving is complicated. • Linear programming
• Integer programming

Type of problems Temporal cost (for solving)


• Scheduling, optimization, etc. • Number of decision variables.
• Many problems can be • Different types of techniques.
defined under this paradigm.
• Capability to obtain optimized
solutions.

46
Advanced knowledge of Spreadsheets (T2.3)

Data Analysis

• Additional Data Analysis functionalities:


• Descriptive Statistics
• Random numbers
• Statistical testing
• …

47
Advanced knowledge of Spreadsheets (T2.3)

Unit II: Building, understanding and


exploiting data.
T2.3. Data analysis: solver and scenarios

Jose María Álvarez


Course 2018/2019

48

You might also like