Difference between revisions of "Scilab---FOSSEE-Optimisation-Toolbox/C2/Quadratic-Optimisation-using-FOT/English"

From Script | Spoken-Tutorial
Jump to: navigation, search
(Created page with "'''Title of the script''': '''Quadratic Optimization''' '''Author: Siddharth Agarwal and Mankrit Singh''' '''Keywords: FOSSEE Optimization Toolbox, Integer Quadratic optimiz...")
 
Line 23: Line 23:
  
 
<ul>
 
<ul>
<li><blockquote><p>Use '''fot underscore quadprog''' and '''fot underscore intquadprog''' functions in '''Scilab'''</p></blockquote></li>
+
<li><blockquote><p>Use '''fot underscore quadprog''' and '''fot underscore intquadprog functions''' in '''Scilab'''</p></blockquote></li>
<li><blockquote><p>Solve quadratic '''optimization''' problems using, '''fot underscore quadprog''' and</p></blockquote></li></ul>
+
<li><blockquote><p>Solve quadratic '''optimization''' problems using, '''fot underscore quadprog''' and '''fot underscore intquadprog functions'''</p></blockquote></li></ul>
 
+
<blockquote>'''fot underscore intquadprog functions'''
+
</blockquote>
+
 
|-
 
|-
 
|
 
|
Line 52: Line 49:
 
<ul>
 
<ul>
 
<li><blockquote><p>Install '''FOSSEE Optimization Toolbox''' version '''0.4.1''' or above</p></blockquote></li>
 
<li><blockquote><p>Install '''FOSSEE Optimization Toolbox''' version '''0.4.1''' or above</p></blockquote></li>
<li><blockquote><p>Have basic understanding of Scilab and optimization theory</p></blockquote></li>
+
<li><blockquote><p>Have basic understanding of '''Scilab''' and '''optimization theory'''</p></blockquote></li>
 
<li><blockquote><p>If not, for relevant tutorials please visit this site.</p></blockquote></li></ul>
 
<li><blockquote><p>If not, for relevant tutorials please visit this site.</p></blockquote></li></ul>
 
|-
 
|-
Line 69: Line 66:
  
 
'''What is the Quadratic optimization problem?'''
 
'''What is the Quadratic optimization problem?'''
|
+
|What is the '''Quadratic optimization''' problem?
A function is quadratic if it has a degree of two.
+
A '''function''' is '''quadratic''' if it has a degree of two.
  
A '''quadratic optimization problem''' is a mathematical optimization model.
+
A '''quadratic optimization''' problem is a mathematical '''optimization model'''.
 
|-
 
|-
 
|
 
|
Line 82: Line 79:
  
 
<ul>
 
<ul>
<li><blockquote><p>Quadratic objective function</p></blockquote></li>
+
<li><blockquote><p>'''Quadratic objective function'''</p></blockquote></li>
<li><blockquote><p>Bounds on the decision variables</p></blockquote></li>
+
<li><blockquote><p>'''Bounds''' on the '''decision variables'''</p></blockquote></li>
<li><blockquote><p>Linear constraints on decision variables</p></blockquote></li></ul>
+
<li><blockquote><p>Linear constraints on '''decision variables'''</p></blockquote></li></ul>
 
|-
 
|-
 
|
 
|
Line 90: Line 87:
  
 
'''Mathematical Formulation'''
 
'''Mathematical Formulation'''
| A '''general form''' of the '''quadratic optimization problem''' is as shown.
+
| A general form of the '''quadratic optimization''' problem is as shown.
 
|-
 
|-
 
|
 
|
Line 99: Line 96:
 
We will now solve this example to illustrate the use of '''fot underscore quadprog'''
 
We will now solve this example to illustrate the use of '''fot underscore quadprog'''
  
In this example, we will learn how to:
+
In this example, we will learn how to minimize the given '''function'''.
 
+
<ul>
+
<li><blockquote><p>Minimize the given function</p></blockquote></li></ul>
+
  
 
Note that the '''objective function''' is '''quadratic.'''
 
Note that the '''objective function''' is '''quadratic.'''
  
Note that there are bounds and linear constraints on the variables.
+
Note that there are '''bounds''' and linear constraints on the '''variables'''.
 
|-
 
|-
 
|
 
|
Line 113: Line 107:
 
'''Example'''
 
'''Example'''
 
|
 
|
We will use the toolbox to solve this example.
+
We will use the '''toolbox''' to solve this example.
  
 
I have downloaded the required files to my '''Downloads''' folder
 
I have downloaded the required files to my '''Downloads''' folder
Line 125: Line 119:
 
Point to the '''editor''' window.
 
Point to the '''editor''' window.
 
|
 
|
In the '''Scilab console''' type '''editor''' and press '''Enter.'''
+
In the '''Scilab console,''' type '''editor''' and press '''Enter.'''
  
 
'''Editor''' window opens.
 
'''Editor''' window opens.
Line 132: Line 126:
 
Click on Open button &gt;&gt; locate the file '''opt_quadprog .sce'''.
 
Click on Open button &gt;&gt; locate the file '''opt_quadprog .sce'''.
  
Video-editor: Pls put a textbox on screen. “In Windows OS ,Click on Open button”
 
 
|
 
|
Click on the '''Open''' button on the toolbar and locate the file '''opt_quadprog .sce'''.
+
Click on the '''Open''' button on the '''toolbar''' and locate the file '''opt_quadprog .sce'''.
  
 
Then click the '''Ok''' button.
 
Then click the '''Ok''' button.
Line 141: Line 134:
 
|-
 
|-
 
| Show '''opt_quadprog .sce''' in scilab editor.
 
| Show '''opt_quadprog .sce''' in scilab editor.
| Now we will see the input arguments for '''fot underscore quadprog.'''
+
| Now we will see the '''input arguments''' for '''fot underscore quadprog.'''
 
|-
 
|-
 
| Highlight '''‘nbVar’'''
 
| Highlight '''‘nbVar’'''
| '''nbVar''' is an integer denoting the number of '''decision variables'''.
+
| '''nbVar''' is an '''integer''' denoting the number of '''decision variables'''.
 
|-
 
|-
 
| Highlight '''‘nbCon’'''
 
| Highlight '''‘nbCon’'''
| '''‘nbCon’''' is an integer denoting the number of '''constraints'''.
+
| '''nbCon''' is an '''integer''' denoting the number of constraints.
 
|-
 
|-
 
| Highlight '''‘H’'''
 
| Highlight '''‘H’'''
Line 153: Line 146:
 
|-
 
|-
 
| Highlight '''‘f’'''
 
| Highlight '''‘f’'''
| '''f''' is a '''vector,''' representing coefficients of the '''linear terms''' in the '''quadratic''' problem'''.'''
+
| '''f''' is a '''vector,''' representing '''coefficients''' of the '''linear terms''' in the '''quadratic''' problem.
 
|-
 
|-
 
| Highlight '''‘x0’'''
 
| Highlight '''‘x0’'''
| '''x0''' is a vector containing the starting values of the decision variables.
+
| '''x0''' is a '''vector''' containing the starting values of the '''decision variables'''.
 
|-
 
|-
 
| Highlight the line with '''‘A’'''
 
| Highlight the line with '''‘A’'''
 
|
 
|
'''''A''''' is a '''matrix''' of '''coefficients''' of
+
'''''A''''' is a '''matrix''' of '''coefficients''' of inequality constraints.
 
+
'''inequality''' constraints.
+
 
|-
 
|-
 
| Highlight the line with '''‘conUB’'''
 
| Highlight the line with '''‘conUB’'''
| '''conUB''' is the '''vector''' of the '''upper bounds''' of the '''constraints.'''
+
| '''conUB''' is the '''vector''' of the '''upper bounds''' of the constraints.
 
|-
 
|-
 
| Highlight the line with '''‘conLB’'''
 
| Highlight the line with '''‘conLB’'''
| '''conLB''' is the '''vector''' of the '''lower bounds''' of the '''constraints.'''
+
| '''conLB''' is the '''vector''' of the lower '''bounds''' of the constraints.
 
|-
 
|-
 
| Highlight '''lb''' and '''ub'''
 
| Highlight '''lb''' and '''ub'''
 
|
 
|
'''lb''' and '''ub''' are row vectors.
+
'''lb''' and '''ub''' are row '''vectors'''.
  
They contain the lower and upper bounds of the decision variables respectively.
+
They contain the lower and upper '''bounds''' of the '''decision variables''' respectively.
 
|-
 
|-
 
| Point to the Output arguments.
 
| Point to the Output arguments.
 
|
 
|
Now we will see the output arguments.
+
Now we will see the '''output arguments'''.
  
Output arguments are '''xopt,''' '''fopt''', '''exitflag, output and lambda.'''
+
'''Output arguments''' are '''xopt,''' '''fopt''', '''exitflag, output''' and '''lambda.'''
 
|-
 
|-
 
| Highlight '''‘xopt’'''
 
| Highlight '''‘xopt’'''
Line 186: Line 177:
 
|-
 
|-
 
| Highlight '''‘fopt’'''
 
| Highlight '''‘fopt’'''
| '''fopt''' is the optimal objective function value'''.'''
+
| '''fopt''' is the optimal '''objective function''' value.
 
|-
 
|-
 
| Highlight '''‘exitflag’'''
 
| Highlight '''‘exitflag’'''
| '''exitflag''' is the status of execution.
+
| '''exitflag''' is the status of '''execution'''.
 
|-
 
|-
 
| Highlight '''‘output’'''
 
| Highlight '''‘output’'''
| '''output''' is a '''structure''' containing detailed information about the optimization.
+
| '''output''' is a '''structure''' containing detailed information about the '''optimization'''.
 
|-
 
|-
 
| Highlight '''lambda'''
 
| Highlight '''lambda'''
Line 202: Line 193:
 
'''[xopt,fopt,exitflag,output,lambda]=fot_quadprog(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0)'''
 
'''[xopt,fopt,exitflag,output,lambda]=fot_quadprog(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0)'''
 
|
 
|
Here we see the '''scilab''' code to define and solve the example.
+
Here we see the '''Scilab''' code to define and solve the example.
  
 
We call the '''fot underscore quadprog function''' to solve the given problem.
 
We call the '''fot underscore quadprog function''' to solve the given problem.
Line 209: Line 200:
 
Press '''CTRL + S'''
 
Press '''CTRL + S'''
  
*
 
  
 
Click on the Execute button on scilab.
 
Click on the Execute button on scilab.
Line 219: Line 209:
 
To '''run''' the file, click on the '''Execute''' menu.
 
To '''run''' the file, click on the '''Execute''' menu.
  
Then click on the '''fil'''e '''with echo''' from the drop down.
+
Then click on the '''File with echo''' from the drop down.
 
|-
 
|-
 
|
 
|
Line 232: Line 222:
 
| Change the window to Scilab console
 
| Change the window to Scilab console
 
|
 
|
Switch to the Scilab '''console''' to see the output.
+
Switch to the '''Scilab console''' to see the '''output'''.
  
 
The result displays “'''Optimal Solution Found.”'''
 
The result displays “'''Optimal Solution Found.”'''
  
We see that it prints the '''fopt''' value, '''xopt''' values, '''exitflag, output, and lambda''' in the '''Scilab console'''.
+
We see that it prints the '''fopt''' value, '''xopt''' values, '''exitflag, output,''' and '''lambda''' in the '''Scilab console'''.
 
|-
 
|-
 
|
 
|
Line 245: Line 235:
 
<ul>
 
<ul>
 
<li><blockquote><p>We will now look at '''integer quadratic programming''' problems.</p></blockquote></li>
 
<li><blockquote><p>We will now look at '''integer quadratic programming''' problems.</p></blockquote></li>
<li><blockquote><p>These are problems where some decision variables are constrained to be integers.</p></blockquote></li></ul>
+
<li><blockquote><p>These are problems where some '''decision variables''' are constrained to be '''integers'''.</p></blockquote></li></ul>
 
|-
 
|-
 
|
 
|
Line 251: Line 241:
  
 
'''Mathematical Formulation'''
 
'''Mathematical Formulation'''
| A '''general form''' of the '''integer constrained''' '''quadratic optimization problem''' is as shown.
+
| A general form of the '''integer''' constrained '''quadratic optimization''' problem is as shown.
 
|-
 
|-
 
|
 
|
Line 260: Line 250:
 
We will now solve this example to illustrate the use of '''fot underscore intquadprog'''.
 
We will now solve this example to illustrate the use of '''fot underscore intquadprog'''.
  
In this example, we will learn how to:
+
In this example, we will learn how to minimize the given '''function'''.
 
+
<ul>
+
<li><blockquote><p>Minimize the given function</p></blockquote></li></ul>
+
  
 
Note that the '''objective function''' is '''quadratic.'''
 
Note that the '''objective function''' is '''quadratic.'''
  
Note that some of the '''decision variables''' are '''constrained''' to be '''integers'''.
+
Note that some of the '''decision variables''' are constrained to be '''integers'''.
 
|-
 
|-
 
| Show '''opt_intquadprog.sce''' in scilab editor.
 
| Show '''opt_intquadprog.sce''' in scilab editor.
 
|
 
|
We will use the toolbox to solve this example.
+
We will use the '''toolbox''' to solve this example.
  
 
Open the '''Scilab console'''.
 
Open the '''Scilab console'''.
  
Type '''editor''' on the Scilab console and Press '''Enter'''.
+
Type '''editor''' on the '''Scilab console''' and press '''Enter'''.
  
 
Open '''opt_intquadprog.sce''' in the '''Scilab editor.'''
 
Open '''opt_intquadprog.sce''' in the '''Scilab editor.'''
 
|-
 
|-
 
| Highlight '''‘H’'''
 
| Highlight '''‘H’'''
| '''H''' is a '''symmetric matrix,''' representing the '''Hessian''' of the '''quadratic''' problem'''.'''
+
| '''H''' is a '''symmetric matrix,''' representing the '''Hessian''' of the '''quadratic''' problem.
 
|-
 
|-
 
| Highlight '''‘f’'''
 
| Highlight '''‘f’'''
| '''f''' is a '''vector,''' representing coefficients of the '''linear terms''' in the '''quadratic''' problem'''.'''
+
| '''f''' is a '''vector,''' representing '''coefficients''' of the linear terms in the '''quadratic''' problem.
 
|-
 
|-
 
| Highlight the line with '''‘A’'''
 
| Highlight the line with '''‘A’'''
 
|
 
|
'''''A''''' is a '''matrix''' of '''coefficients''' of
+
'''''A''''' is a '''matrix''' of '''coefficients''' of inequality constraints.
 
+
'''inequality''' constraints
+
 
|-
 
|-
 
| Highlight the line with '''b'''
 
| Highlight the line with '''b'''
| '''b''' is the '''vector''' of the RHS of the '''inequality constraints '''
+
| '''b''' is the '''vector''' of the RHS of the inequality constraints.
 
|-
 
|-
 
| Highlight the line with '''Aeq'''
 
| Highlight the line with '''Aeq'''
| '''Aeq''' is the '''matrix''' of the LHS of the '''equality constraints'''
+
| '''Aeq''' is the '''matrix''' of the LHS of the equality constraints.
 
|-
 
|-
 
| Highlight the line with '''beq'''
 
| Highlight the line with '''beq'''
| '''beq''' is the '''vector''' of the RHS of the '''equality constraints'''
+
| '''beq''' is the '''vector''' of the RHS of the equality constraints.
 
|-
 
|-
 
| Highlight '''‘intcon’'''
 
| Highlight '''‘intcon’'''
| '''intcon''' is a '''vector''' of the '''indices''' of integer variables
+
| '''intcon''' is a '''vector''' of the '''indices''' of '''integer variables'''.
 
|-
 
|-
 
|
 
|
  
|
+
|Now we will see the '''output arguments'''.
Now we will see the output arguments.
+
  
Output arguments are '''xopt,''' '''fopt''', '''exitflag, output'''
+
'''Output arguments''' are '''xopt, fopt, exitflag, output'''
 
|-
 
|-
 
| Highlight '''‘xopt’'''
 
| Highlight '''‘xopt’'''
Line 314: Line 298:
 
|-
 
|-
 
| Highlight '''‘fopt’'''
 
| Highlight '''‘fopt’'''
| '''fopt''' is the optimal objective function value'''.'''
+
| '''fopt''' is the optimal '''objective function''' value.
 
|-
 
|-
 
| Highlight '''‘exitflag’'''
 
| Highlight '''‘exitflag’'''
| '''exitflag''' is the status of execution
+
| '''exitflag''' is the status of '''execution'''.
 
|-
 
|-
 
| Highlight '''output'''
 
| Highlight '''output'''
| '''Output''' is a '''structure''' containing detailed information about the optimization.
+
| '''Output''' is a '''structure''' containing detailed information about the '''optimization'''.
 
|-
 
|-
 
|
 
|
Line 326: Line 310:
  
 
'''[xopt,fopt,exitflag,output]=fot_intquadprog(H,f,intcon,A,b,Aeq,beq)'''
 
'''[xopt,fopt,exitflag,output]=fot_intquadprog(H,f,intcon,A,b,Aeq,beq)'''
| This is how we call '''fot underscore intquadprog.'''
+
| This is how we '''call fot underscore intquadprog.'''
 
|-
 
|-
 
|
 
|
 
Press '''CTRL + S'''
 
Press '''CTRL + S'''
  
*
+
 
  
 
Click on the Execute button on scilab.
 
Click on the Execute button on scilab.
Line 339: Line 323:
 
Save the file by pressing '''Control''' and '''‘S’''' keys simultaneously.
 
Save the file by pressing '''Control''' and '''‘S’''' keys simultaneously.
  
To '''run''' the file, click on the '''Execute''' menu.
+
To '''run''' the file, click on the '''Execute menu'''.
  
Then click on the '''file with echo''' from the drop down.
+
Then click on the '''File with echo''' from the drop down.
 
|-
 
|-
 
|
 
|
Line 351: Line 335:
 
| Change the window to Scilab console
 
| Change the window to Scilab console
 
|
 
|
Switch to the Scilab '''console''' to see the output.
+
Switch to the '''Scilab console''' to see the '''output'''.
  
 
The result displays “'''Optimal Solution Found.”'''
 
The result displays “'''Optimal Solution Found.”'''
Line 367: Line 351:
  
 
<ul>
 
<ul>
<li><blockquote><p>Use '''fot underscore quadprog''' and '''fot underscore intquadprog''' functions of the '''FOSSEE Optimization Toolbox'''.</p></blockquote></li>
+
<li><blockquote><p>Use '''fot underscore quadprog''' and '''fot underscore intquadprog functions''' of the '''FOSSEE Optimization Toolbox'''.</p></blockquote></li>
<li><blockquote><p>Solve Quadratic programming problems in '''Scilab'''.</p></blockquote></li></ul>
+
<li><blockquote><p>Solve '''quadratic programming''' problems in '''Scilab'''.</p></blockquote></li></ul>
 
|-
 
|-
 
|
 
|
Line 378: Line 362:
  
 
<ul>
 
<ul>
<li><blockquote><p>Minimise the following objective function.</p></blockquote></li>
+
<li><blockquote><p>Minimise the following '''objective function'''.</p></blockquote></li>
<li><blockquote><p>Use '''fot underscore quadprog''' function subjected to the given constraint:</p></blockquote></li></ul>
+
<li><blockquote><p>Use '''fot underscore quadprog function''' subjected to the given constraint</p></blockquote></li></ul>
 
|-
 
|-
 
|
 
|
Line 388: Line 372:
 
The optimum value will be -8.22.
 
The optimum value will be -8.22.
  
The optimum solution will be the vector [0.66 1.33].
+
The optimum solution will be the '''vector''' [0.66 1.33].
 
|-
 
|-
 
|
 
|
Line 398: Line 382:
  
 
<ul>
 
<ul>
<li><blockquote><p>Minimise the following objective function.</p></blockquote></li>
+
<li><blockquote><p>Minimise the following '''objective function'''.</p></blockquote></li>
<li><blockquote><p>Use '''fot underscore intquadprog''' function subjected to the given constraints:</p></blockquote></li></ul>
+
<li><blockquote><p>Use '''fot underscore intquadprog function''' subjected to the given constraints.</p></blockquote></li></ul>
 
|-
 
|-
 
|
 
|
Line 408: Line 392:
 
The optimum value will be -20.
 
The optimum value will be -20.
  
The optimum solution can be either vector [4 1 1 0 1] or [4 1 2 0 1].
+
The optimum solution can be either '''vector''' [4 1 1 0 1] or [4 1 2 0 1].
 
|-
 
|-
 
|
 
|

Revision as of 12:38, 16 November 2021

Title of the script: Quadratic Optimization

Author: Siddharth Agarwal and Mankrit Singh

Keywords: FOSSEE Optimization Toolbox, Integer Quadratic optimization, Quadratic optimization, OR, quadprog, intquadprog .

Visual Cue Narration

Show Slide

Title Slide

Hello and welcome to the Spoken tutorial on Quadratic optimization.

Show Slide

Learning Objectives

In this tutorial, we will learn how to:

  • Use fot underscore quadprog and fot underscore intquadprog functions in Scilab

  • Solve quadratic optimization problems using, fot underscore quadprog and fot underscore intquadprog functions

Show Slide

System Requirement

To record this tutorial, I am using

  • Ubuntu 18.04

  • Scilab 6.1.0 and

  • FOSSEE Optimization Toolbox version 0.4.1

Show Slide

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.

Show Slide

What is the Quadratic optimization problem?

What is the Quadratic optimization problem?

A function is quadratic if it has a degree of two.

A quadratic optimization problem is a mathematical optimization model.

Show Slide

What is the Quadratic optimization problem?

It has:

  • Quadratic objective function

  • Bounds on the decision variables

  • Linear constraints on decision variables

Show Slide

Mathematical Formulation

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

Show Slide

Example

We will now solve this example to illustrate the use of fot underscore quadprog

In this example, we will learn how to minimize the given function.

Note that the objective function is quadratic.

Note that there are bounds and linear constraints on the variables.

Show Slide

Example

We will use the toolbox to solve this example.

I have downloaded the required files to my Downloads folder

Cursor on the Scilab console. Now open the Scilab console.

Type editor >> press Enter.

Point to the editor window.

In the Scilab console, type editor and press Enter.

Editor window opens.

Click on Open button >> locate the file opt_quadprog .sce.

Click on the Open button on the toolbar and locate the file opt_quadprog .sce.

Then click the Ok button.

opt_quadprog.sce file opens in the editor

Show opt_quadprog .sce in scilab editor. Now we will see the input arguments for fot underscore quadprog.
Highlight ‘nbVar’ nbVar is an integer denoting the number of decision variables.
Highlight ‘nbCon’ nbCon is an integer denoting the number of constraints.
Highlight ‘H’ H is a symmetric matrix, representing the Hessian of the quadratic problem.
Highlight ‘f’ f is a vector, representing coefficients of the linear terms in the quadratic problem.
Highlight ‘x0’ x0 is a vector containing the starting values of the decision variables.
Highlight the line with ‘A’

A is a matrix of coefficients of inequality constraints.

Highlight the line with ‘conUB’ conUB is the vector of the upper bounds of the constraints.
Highlight the line with ‘conLB’ conLB is the vector of the lower bounds of the constraints.
Highlight lb and ub

lb and ub are row vectors.

They contain the lower and upper bounds of the decision variables respectively.

Point to the Output arguments.

Now we will see the output arguments.

Output arguments are xopt, fopt, exitflag, output and lambda.

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 lambda lambda is a structure containing the Lagrange multipliers at the optimal solution.

Highlight

[xopt,fopt,exitflag,output,lambda]=fot_quadprog(nbVar,nbCon,H,f,lb,ub,A,conLB,conUB,x0)

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

We call the fot underscore quadprog function to solve the given problem.

Press CTRL + S


Click on the Execute button on scilab.

Select file with echo from the drop-down.

Save the file by pressing Control and ‘S’ keys simultaneously.

To run the file, click on the Execute menu.

Then click on the File with echo from the drop down.

Point to the Confirmation box.

Click Yes to confirm.

A confirmation box to clear the Console appears.

Click on the Yes button to confirm.

Change the window to Scilab console

Switch to the Scilab console to see the output.

The result displays “Optimal Solution Found.”

We see that it prints the fopt value, xopt values, exitflag, output, and lambda in the Scilab console.

Show Slide

Integer Quadratic Programming

  • We will now look at integer quadratic programming problems.

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

Show Slide

Mathematical Formulation

A general form of the integer constrained quadratic optimization problem is as shown.

Show Slide

Example

We will now solve this example to illustrate the use of fot underscore intquadprog.

In this example, we will learn how to minimize the given function.

Note that the objective function is quadratic.

Note that some of the decision variables are constrained to be integers.

Show opt_intquadprog.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_intquadprog.sce in the Scilab editor.

Highlight ‘H’ H is a symmetric matrix, representing the Hessian of the quadratic problem.
Highlight ‘f’ f is a vector, representing coefficients of the linear terms in the quadratic problem.
Highlight the line with ‘A’

A is a matrix of coefficients of inequality constraints.

Highlight the line with b b is the vector of the RHS of the inequality constraints.
Highlight the line with Aeq Aeq is the matrix of the LHS of the equality constraints.
Highlight the line with beq beq is the vector of the RHS of the equality constraints.
Highlight ‘intcon’ intcon is a vector of the indices of integer variables.
Now we will see the output arguments.

Output arguments are xopt, fopt, exitflag, output

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

[xopt,fopt,exitflag,output]=fot_intquadprog(H,f,intcon,A,b,Aeq,beq)

This is how we call fot underscore intquadprog.

Press CTRL + S


Click on the Execute button on scilab.

Select file with echo from the drop-down.

Save the file by pressing Control and ‘S’ keys simultaneously.

To run the file, click on the Execute menu.

Then click on the File with echo from the drop down.

Point to the Confirmation box.

Click Yes to confirm.

In the confirmation box, click the Yes button to clear the Console.
Change the window to Scilab console

Switch to the Scilab console to see the output.

The result displays “Optimal Solution Found.”

We see that it prints the fopt value, xopt values, exitflag and output in the Scilab console.

Show Slide

Summary

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

In this tutorial, we have learnt how to:

  • Use fot underscore quadprog and fot underscore intquadprog functions of the FOSSEE Optimization Toolbox.

  • Solve quadratic programming problems in Scilab.

Show Slide

Assignment I

As an assignment:

  • Minimise the following objective function.

  • Use fot underscore quadprog function subjected to the given constraint

Show Slide

Assignment I

The optimum value will be -8.22.

The optimum solution will be the vector [0.66 1.33].

Show Slide

Assignment II

Here is another assignment problem:

  • Minimise the following objective function.

  • Use fot underscore intquadprog function subjected to the given constraints.

Show Slide

Assignment II

The optimum value will be -20.

The optimum solution can be either vector [4 1 1 0 1] or [4 1 2 0 1].

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 Mankrit Singh, a FOSSEE intern 2021, IIT Bombay signing off

Thanks for joining.

Contributors and Content Editors

Madhurig, Mankrits, Nancyvarkey