Scilab---FOSSEE-Optimisation-Toolbox/C2/Unconstrained-Optimization-using-FOT/English

From Script | Spoken-Tutorial
Revision as of 02:54, 23 December 2021 by Anandajitht (Talk | contribs)

Jump to: navigation, search

Title of the script: Unconstrained Optimisation using FOT

Author: Siddharth Agarwal, Anandajith TS

Keywords: FOSSEE Optimization Toolbox, Integer Unconstrained Optimisation, Unconstrained Optimisation, fminunc, intfminunc.

Visual Cue Narration

Show Slide 1

Title Slide

Welcome to the spoken tutorial on Unconstrained Optimisation using FOT.

Show Slide 2

Learning Objectives

In this tutorial, we will learn how to:

  • Use fot_fminunc and fot_intfminunc functions in Scilab.
  • Solve unconstrained optimisation problems using fot_fminunc and fot_intfminunc functions.

Show Slide 3

System Requirement

To record this tutorial, I am using

  • Windows 10 as the operating system
  • Scilab 6.1.0
  • FOSSEE Optimization Toolbox version 0.4.1

The process demonstrated in this tutorial is identical in Linux OS also.

Annotations will be added to the tutorial if there are any differences.

Show Slide 4

Pre-requisites

https://spoken-tutorial.org

To follow this tutorial, you should

  • Install FOSSEE Optimization Toolbox version 0.4.1 or above.
  • Have basic understanding of Scilab and Optimization theory.

If not, for relevant tutorials please visit this site.

Show slide

Code Files

  • The files used in this tutorial have been provided in the Code files link.
  • Please download and extract the files.
  • Make a copy and then use them while practising.

Slide 5

What is the Unconstrained Optimisation problem?

A function is nonlinear if it has a degree of two or more.

An unconstrained optimisation problem is a mathematical optimization model with:

  • Nonlinear objective function
  • No constraints

Show Slide 6

Mathematical Formulation

A general form of the unconstrained optimization problem is as shown.

Show Slide 7

Example

We will now solve this example to illustrate the use of fot_fminunc

In this example, we will learn how to:

  • Minimize the given function.
  • Note that the objective function is nonlinear.
We will use the toolbox to solve this example.

Make sure that the toolbox is already installed on Scilab.

Cursor on the Scilab console. Now open the Scilab console.
Type editor >> press Enter.

In the Scilab console, type editor and press Enter.

Editor window opens.

Click on Open button. Click on Open button on the toolbar.
Go to the Downloads folder.

Locate the file opt_fminunc.sce.

Click on the Open button.

Go to the Downloads folder.

Locate the file opt_fminunc.sce.

Then click on the Open button.

Point to the file. opt_fminunc.sce file opens in the editor.
Show opt_fminunc.sce in scilab editor. Now we will see the input arguments for fot_fminunc.
Highlight ‘f’ f is an objective function.
Highlight ‘x0’ x0 is a vector containing the starting values of the decision variables.
Highlight ‘xopt, fopt, exitflag, output, gradient, hessian’

Now we will see the output arguments.

Output arguments are xopt, fopt, exitflag, output, gradient, hessian.

Highlight ‘xopt’ xopt is the optimal value of x.
Highlight ‘fopt’ fopt is the optimal objective function value.
Highlight ‘exitflag’ exitflag is the status of execution.
Highlight ‘Output’ Output is a structure containing detailed information about the optimization.
Highlight ‘Gradient’ Gradient is a vector containing the objective's gradient of the solution.
Highlight ‘Hessian’ Hessian is a matrix containing the Lagrangian's hessian of the solution.

Highlight

[xopt,fopt,exitflag,output,gradient,hessian]=fot_fminunc(f,x0)

Here we see the Scilab code to define and solve the example.

Now call the fot_fminunc function to solve the given problem.

Press CTRL + s

Click on execute button on scilab.

Save the file by pressing Control and S keys simultaneously.

To run the file, click on the Execute menu.

Click on File with Echo from the drop-down.

Change the window to Scilab console.

Switch to the Scilab console to see the output.

We see that it prints the

  • xopt value as 1,1,
  • fopt value as 1.466D-16,
  • Output as the Optimal solution Found.

Show Slide

Integer Nonlinear Programming

We will now look at integer nonlinear programming problems.

These are problems where some decision variables are constrained to be integers.

Show Slide 6

Mathematical Formulation

A general form of the unconstrained integer programming problem is as shown.

Show Slide

Example

We will now solve this example to illustrate the use of fot_intfminunc.

In this example, we will learn how to:

  • Minimize the given function.
  • Note that the objective function is nonlinear.

Some of the decision variables are integers.

Show opt_intfminunc.sce in scilab editor.

We will use the toolbox to solve this example.

Open the Scilab console.

Type editor on the Scilab console and press Enter.

Open opt_intfminunc.sce in the Scilab editor.

Highlight ‘f’ f is the objective function.
Highlight ‘x0’ x0 is a vector containing the starting values of the decision variables.
Highlight ‘intcon’ intcon is a vector of the indices of the integer variables.
Highlight ‘xopt, fopt, exitflag, gradient, hessian’

Now we will see the output arguments.

Output arguments are xopt, fopt, exitflag, gradient, hessian.

Highlight ‘xopt’ xopt is the optimal value of x.
Highlight ‘fopt’ fopt is the optimal objective function value.
Highlight ‘exitflag’ exitflag is the status of execution.
Highlight ‘Gradient’ Gradient is a vector containing the objective's gradient of the solution
Highlight ‘Hessian’ Hessian is a matrix containing the Lagrangian's hessian of the solution.

Press CTRL + s

Click on execute button on scilab.

Save the file by pressing Control and S keys simultaneously.

To run the file, click on the Execute menu.

Click on File with Echo from the drop-down menu.

Change the window to Scilab console.

Switch to the Scilab console to see the output.

We see that it prints the

  • xopt value as 1,1,
  • fopt value as 1.341D-19,
  • Output as the Optimal solution Found.

Show Slide

Summary

This brings us to the end of this tutorial. Let us summarise.

In this tutorial, we have learnt to:

  • Use fot_fminunc and fot_intfminunc functions of the FOSSEE Optimization Toolbox.
  • Solve unconstrained nonlinear programming examples in Scilab.

Show Slide

Assignment

As an assignment, please do the following:

  • What will be the solution if we include the following constraint in the previous example?

Show Slide

Assignment

  • The optimal value will be 2547.7231 and
  • Optimal solution will be x one equal to 64.363297and x two equal to 50.720229.

Show Slide:

About Spoken Tutorial Project

The video at the following link summarises the Spoken Tutorial project.

Please download and watch it.

Show Slide:

Spoken Tutorial Workshops

The Spoken Tutorial Project Team conducts workshops and gives certificates.

For more details, please write to us.

Show Slide:

Answers for THIS Spoken Tutorial

Please post your timed queries in this forum.
Show Slide: FOSSEE Forum Please post your general and technical queries on Scilab in this forum.

Show Slide:

Textbook Companion project

The FOSSEE team coordinates the Textbook Companion project.

We give Certificates and Honorarium to the contributors.

For more details, please visit this site.

Show Slide: Lab Migration

The FOSSEE team coordinates the Lab Migration project.

For more details, please visit this site.

Show Slide:

Acknowledgement

Spoken Tutorial and FOSSEE projects are funded by MoE, Government of India.

Show Slide :

Thank you

This is Anandajith TS, FOSSEE intern 2021, IIT Bombay signing off.

Thanks for joining.

Contributors and Content Editors

Anandajitht, Nancyvarkey, Nirmala Venkat