You are on page 1of 41

Excel solver

Jude Kwaku Bonsu (PhD)

Department of Chemical Engineering, Kwame Nkrumah University of Science and Technology


Introduction
• Optimization problem developed for real processes can be very
complicated
• These complicated problems are difficult to solve by hand
• However, with help of computer, we can solve those problems with
very less effort that save both time and money
• These software use some of the numerical optimization techniques
previously discussed
Software options for optimization
• Software used in optimization, can be classified into 3 broad groups
• The first set of software are stand-alone optimization software, where
the primary focus is to solve various types of prescribed optimization
problems
• The second set of software involves design and/or analyses integration
frameworks, where analyses codes from different engineering disciplines
can be conveniently integrated and designs can be optimized
• The third set of optimization software involves large scale analyses codes
that have optimization capabilities as one of their offered features
typically added in recent years with the growing popularity of
optimization. Details of the above options are discussed next
Categorization of optimization software

Group 1 Group 2 Group 3

Matlab tool box GAMS ASPEN PLUS & HYSIS

Neos solver FICO XPRESS ANSYS

GRG 2 LINDO/LINGO COSMOL

CPLEX MICROSOFT EXCEL

ASPEN PIMS gPROMS

Minitab
Optimization software (NEOS server)

• NEOS server: The NEOS server is an environment to solve


optimization problems over the internet.
• It is available at the website www.neos-server.org/neos, and can be
used to solve a variety of optimization problems, such as linear,
nonlinear, discrete, integer programming, and combinatorial
problems
• . The NEOS server also offers global optimization algorithms. The user
needs to provide the optimization problem in a specific format, which
depends on the type of optimization problem being solved.
Optimization software (GRG2)

• This solver is based on the general reduced gradient algorithm


• The GRG2 software is used for nonlinear programming problems. It
• can be used as a stand-alone system or as a subroutine. It can handle
up to two hundred active constraints.
• Another implementation of GRG2, known as , can solve large scale
optimization problems with over 500 constraints.
Optimization software (CPLEX)
• CPLEX is used to solve linear programming and integer programming
problems.
• It employs both Simplex and interior point algorithms for linear
programming.
• It can be used directly or as a subroutine.
• The software is claimed to be robust and reliable with a user-friendly
interface
Introduction to Solver
• Microsoft Excel has an optimization solver that can be included as an
add-in
• This add-in is known as Solver

• Excel solver is probably the most used optimization software in the


world
• Due to the popularity, and ease of use of the Microsoft excel software
• Excel solver becomes one of the simplest ways for beginners to
master optimization
More on solver
• The correct use of the Solver depends on:

• the knowledge of the proper Solver inputs

• the numerous settings of Solver

• the ability to understand Solver’s output report

• the ability to correctly set up a model in Excel


Activating solver
• This lecture assumes that the student already has access to, and has
installed the Microsoft Excel software
• After this, the user must active the Solver add-in by going to file→
more→ options
• Selecting option will give us lead to the appearance of a new dialogue
box, the user must click on add-ins
• After the user chooses add-ins
• The user should click on the go sign next to manage add-ins
• This action will lead to a pop-up box, where user can choose to add
Solver
• If the user is successful, the solver option will be available under the
data tab
Activating solver
• After clicking on file,
• User should click on
more
• The available tabs are
Feed back and
options
• User should click on
options
Activating solver
• When the user clicks
on the options tab,
• The new pop up
provides a number of
choices
• User must click on
Add-ins
Activating solver
• When the user clicks
on Add-ins,
• A new interface
appears
• The user should click
on the Go… button
close to the Manage:
Excel Add-ins
Activating solver
• Clicking on the
manage Add-ins
• Provides the user with
the available Add-ins
• The user should the
Solver Add-in and
click okay
Solver activated
Using Excel Solver
• Now to operate solver, we rely on our knowledge of the nature of
optimization problems
• A quick recap ………………………………………..
• The features of an optimization problem are:
1.The objective function: an output you are trying to maximize or
minimize e.g. cost, profit
2. Decision Variables: inputs – Quantities you can manipulate to
improve the objective function
3. Constraints: Relations between the variables. They also limit how
large or small a variable can be.
Using Excel Solver continued…..
• Remember the different classes of optimization problems
• Constrained or constrained
• Linear or non-linear
• Continuous, integer or mixed integer linear/non-linear problems

• We will start with unconstrained optimization problems


Using Excel solver

• Before we are introduced to our problem, what are the features of an


unconstrained optimization problem?
1. They have an objective function (all optimization problems must
have
2. They have decision variables (all optimization problems have)
3. They have no constraints (this is limited to unconstrained
optimization problem)
Illustrative example
Minimize the function
• 𝑓 𝑥 = 𝑥1 − 2 4 + 𝑥1 − 2 2 𝑥2 2 + 𝑥2 + 1 2

𝑥0 = 1,1 𝑇 using excel solver


Steps in solving a problem using Excel Solver
1.The first step is to analyse the problem
What are the decision variables in this problem?
Answer =𝑥1 and 𝑥2
What is the objective function?
𝑓 𝑥 = 𝑥1 − 2 4 + 𝑥1 − 2 2 𝑥2 2 + 𝑥2 + 1 2

2. The next step is to enter this information in excel


Steps in solving a problem using Excel Solver
After the data has been put in
excel, the user can test the
effect of the decision variables
on the objective function
For instance what happens if X2
is increased or decreased

When the user is satisfied that


the model is properly
represented on excel
The data can be entered into
The Solver dialogue box
• As can be seen, the solver dialogue box has these five parameters
than needs to be fulfilled viz.

• Set objective: The cell that contains the objective function to be


minimize or maximize

• To Max or Min: Deciding on the nature of the optimization.


Whether maximization or minimization

• By Changing variable cells: This section is where the cells


containing the decision variables are chosen

• Subject to the Constraints: Various constraints are specified

• Select a solving method: Here you choose one of the 3 available


solving methods. The 3 are the Simplex LP method, Generalized
Reduced Gradient (GRG) method and the evolutionary method
More on constraints in Excel Solver
• The following settings can be applied to constraints in Excel Solver as in-built functions

• Make unconstrained variables non-negative: This is enforced when, the decision variables
cannot be negative

• Integer constraints: This is for discrete variables i.e. variables that can only assume whole
numbers e.g. number of heat exchangers

• Binary constraints: This is used for variables that can only assume the values of 1 or 0. Mostly
used in logical constraints. Their effect usually means exist or do no exist

• All different constraints: Sometimes all variables within a certain set must have different
values
Which solver must I choose
• Simplex LP: It is used in solving linear programming/optimization problems. Meaning both the
objective function and all the constraints are linear. This technique will produce a global
optimum for problems that it can solved

• GRG: This solver is used when there is a non-linearity in either the objective function or any of
the constraints. To be able to use GRG, the objective function and all the constraints must be
continuous and smooth. Using GRG on a non-unimodal (non-convex) problem leads to local
optimum solutions. The way to deal with this problem is to solve the problem with multiple
starting point

• Evolutionary method: This is used if either the objective function or any of the constraints is
either discontinuous or non-smooth
Which solver must I choose
• Simplex LP: It is used in solving linear programming/optimization problems. Meaning both the
objective function and all the constraints are linear. This technique will produce a global
optimum for problems that it can solved

• GRG: This solver is used when there is a non-linearity in either the objective function or any of
the constraints. To be able to use GRG, the objective function and all the constraints must be
continuous and smooth. Using GRG on a non-unimodal (non-convex) problem leads to local
optimum solutions. The way to deal with this problem is to solve the problem with multiple
starting point
Now let’s solve the problem
Solution found
Illustrative example LP
Modelling the problem
• Let x1 be barrels of crude type 1 processed,

• and x2 be barrels of crude type 2 processed

• Objective function: P=X1+0.7X2

• Constraints

• Constraints on the amount of gasoline: 0.7X1+0.31X2 ≤9000

• Constraints on the amount of kerosine: 0.06X1+0.09X2 ≤2400

• Constraints on the amount of fuel oil: 0.24X1+0.6X2 ≤12000

• Also X1≥0, X2≥0

• The next step is to put this model on excel


Building the model in excel
• The objective function and
constraints have been set up
in excel

• The next step is to feed the


solver dialogue box with data
Inputting information into the Solver dialogue box
Results from optimization
Reports generated by Solver
Trial example
Illustrative problem: Non-linear
programming
• The price per unit area of the side of a cylindrical tank is $5 and price per unit area of the top and bottom
is $8.

• a) Using the Lagrange constraint method find the height to diameter ratio that optimizes the cost for a
1000-liter cylindrical tank

• b) What is the optimal cost of the tank


Modelling the problem
• The area of the curved side is 𝝅𝑫𝑳

𝝅𝑫𝟐 𝝅𝑫𝟐
• The area of the top and bottom side is 𝟐 × =
𝟒 𝟐

𝝅𝑫𝟐
• Objective function=Total cost of cylinder 𝑪 = 𝟓 𝝅𝑫𝑳 + 𝟖
𝟐

• 𝑪 = 𝟓 𝝅𝑫𝑳 + 𝟒𝝅𝑫𝟐

𝝅𝑫𝟐
• Constraints 𝑽 = 𝑳 = 𝟏𝟎𝟎𝟎𝒍𝒊𝒕𝒓𝒆𝒔 = 𝟏𝟎𝟎𝟎𝒅𝒎𝟑
𝟒

• Now that we are done with the modelling, we must put the model on the Excel model
Building the model in excel
• The objective function and
constraints have been set up
in excel

• The next step is to feed the


solver dialogue box with data
Inputting information into the Solver dialogue box
Results from optimization
Results from optimization
THAT WILL BE ALL FOR NOW

THANK YOU!!!!!

You might also like