Difference between revisions of "Scilab---FOSSEE-Optimisation-Toolbox/C2/Unconstrained-Optimization-using-FOT/English"
Nancyvarkey (Talk | contribs) |
|||
(5 intermediate revisions by 2 users not shown) | |||
Line 21: | Line 21: | ||
In this tutorial, we will learn how to: | In this tutorial, we will learn how to: | ||
− | *Use '''fot_fminunc''' and '''fot_intfminunc functions''' in '''Scilab''' | + | *Use '''fot_fminunc''' and '''fot_intfminunc functions''' in '''Scilab'''. |
− | *Solve unconstrained '''optimisation''' problems using '''fot_fminunc and fot_intfminunc functions''' | + | *Solve unconstrained '''optimisation''' problems using '''fot_fminunc and fot_intfminunc functions'''. |
|- | |- | ||
| | | | ||
Show Slide 3 | Show Slide 3 | ||
− | '''System | + | '''System Requirement''' |
| | | | ||
To record this tutorial, I am using | To record this tutorial, I am using | ||
Line 48: | Line 48: | ||
To follow this tutorial, you should | To follow this tutorial, you should | ||
− | *Install '''FOSSEE Optimization Toolbox''' version 0.4.1 or above | + | *Install '''FOSSEE Optimization Toolbox''' version 0.4.1 or above. |
− | *Have basic understanding of '''Scilab''' and ''' | + | *Have basic understanding of '''Scilab''' and '''Optimization theory'''. |
If not, for relevant tutorials please visit this site. | If not, for relevant tutorials please visit this site. | ||
Line 58: | Line 58: | ||
'''Code Files''' | '''Code Files''' | ||
| | | | ||
− | *The files used in this tutorial | + | *The files used in this tutorial have been provided in the '''Code files''' link. |
− | *Please download and extract the files | + | *Please download and extract the files. |
− | *Make a copy and then use them while practising | + | *Make a copy and then use them while practising. |
|- | |- | ||
| | | | ||
Line 88: | Line 88: | ||
In this example, we will learn how to: | In this example, we will learn how to: | ||
− | *Minimize the given '''function''' | + | *Minimize the given '''function'''. |
− | *Note that the '''objective function''' is '''nonlinear''' | + | *Note that the '''objective function''' is '''nonlinear'''. |
|- | |- | ||
| | | | ||
Line 113: | Line 113: | ||
Locate the file '''opt_fminunc.sce'''. | Locate the file '''opt_fminunc.sce'''. | ||
− | Click the '''Open''' button. | + | Click on the '''Open''' button. |
|Go to the '''Downloads''' folder. | |Go to the '''Downloads''' folder. | ||
Locate the file '''opt_fminunc.sce'''. | Locate the file '''opt_fminunc.sce'''. | ||
− | Then click the '''Open''' button. | + | Then click on the '''Open''' button. |
|- | |- | ||
|Point to the file. | |Point to the file. | ||
Line 127: | Line 127: | ||
|- | |- | ||
| Highlight '''‘f’''' | | Highlight '''‘f’''' | ||
− | |'''f''' is an '''objective function''' | + | |'''f''' is an '''objective function'''. |
|- | |- | ||
| Highlight '''‘x0’''' | | Highlight '''‘x0’''' | ||
Line 148: | Line 148: | ||
|- | |- | ||
| Highlight '''‘Output’''' | | Highlight '''‘Output’''' | ||
− | |'''Output''' is structure containing detailed information about the '''optimization'''. | + | |'''Output''' is a structure containing detailed information about the '''optimization'''. |
|- | |- | ||
| Highlight '''‘Gradient’''' | | Highlight '''‘Gradient’''' | ||
Line 162: | Line 162: | ||
| Here we see the '''Scilab''' code to define and solve the example. | | Here we see the '''Scilab''' code to define and solve the example. | ||
− | + | Now call the '''fot_fminunc function''' to solve the given problem. | |
|- | |- | ||
| | | | ||
Line 183: | Line 183: | ||
*'''xopt''' value as 1,1, | *'''xopt''' value as 1,1, | ||
*'''fopt''' value as 1.466D-16, | *'''fopt''' value as 1.466D-16, | ||
− | *'''Output''' as the '''Optimal solution Found''' | + | *'''Output''' as the '''Optimal solution Found'''. |
|- | |- | ||
| | | | ||
Line 209: | Line 209: | ||
In this example, we will learn how to: | In this example, we will learn how to: | ||
− | *Minimize the given '''function''' | + | *Minimize the given '''function'''. |
− | *Note that the '''objective function''' is '''nonlinear | + | *Note that the '''objective function''' is '''nonlinear'''. |
Some of the '''decision variables''' are '''integers'''. | Some of the '''decision variables''' are '''integers'''. | ||
Line 234: | Line 234: | ||
|- | |- | ||
− | | Highlight ‘'''xopt,''' '''fopt''', '''exitflag | + | | Highlight ‘'''xopt,''' '''fopt''', '''exitflag, gradient, hessian’''' |
| | | | ||
Now we will see the '''output arguments'''. | Now we will see the '''output arguments'''. | ||
− | '''Output arguments''' are '''xopt,''' '''fopt''', '''exitflag | + | '''Output arguments''' are '''xopt,''' '''fopt''', '''exitflag, gradient, hessian'''. |
|- | |- | ||
| Highlight '''‘xopt’''' | | Highlight '''‘xopt’''' | ||
Line 264: | Line 264: | ||
To '''run''' the file, click on the '''Execute menu'''. | To '''run''' the file, click on the '''Execute menu'''. | ||
− | Click on '''File with Echo''' from the drop-down. | + | Click on '''File with Echo''' from the drop-down menu. |
|- | |- | ||
| Change the window to '''Scilab console.''' | | Change the window to '''Scilab console.''' | ||
Line 272: | Line 272: | ||
We see that it prints the | We see that it prints the | ||
− | *'''xopt''' value | + | *'''xopt''' value, |
− | *'''fopt''' value | + | *'''fopt''' value, |
− | *'''Output''' as the '''Optimal solution Found''' | + | *'''Output''' as the '''Optimal solution Found''' as shown. |
|- | |- | ||
| | | | ||
Line 295: | Line 295: | ||
As an assignment, please do the following: | As an assignment, please do the following: | ||
− | *What will be the solution | + | *What will be the solution of the following example? |
|- | |- | ||
| | | | ||
Line 303: | Line 303: | ||
| | | | ||
*The optimal value will be 2547.7231 and | *The optimal value will be 2547.7231 and | ||
− | *Optimal solution will be '''x one''' equal to 64.363297and '''x two''' equal to 50.720229 | + | *Optimal solution will be '''x one''' equal to 64.363297and '''x two''' equal to 50.720229. |
|- | |- | ||
| | | | ||
Line 321: | Line 321: | ||
The '''Spoken Tutorial''' Project Team conducts workshops and gives certificates. | The '''Spoken Tutorial''' Project Team conducts workshops and gives certificates. | ||
− | For more details, please write to us | + | For more details, please write to us. |
|- | |- | ||
| | | |
Latest revision as of 14:23, 24 June 2022
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:
|
Show Slide 3 System Requirement |
To record this tutorial, I am using
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 |
To follow this tutorial, you should
If not, for relevant tutorials please visit this site. |
Show slide Code Files |
|
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:
|
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:
|
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
|
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:
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
|
Show Slide Summary |
This brings us to the end of this tutorial. Let us summarise. In this tutorial, we have learnt to:
|
Show Slide Assignment |
As an assignment, please do the following:
|
Show Slide Assignment |
|
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. |