« Découvrir Scilab/Calcul numérique » : différence entre les versions

Contenu supprimé Contenu ajouté
→‎Optimisation linéaire : liens externes
Ligne 1 600 :
\mathrm{A_e} \mathbf{x} = \mathbf{b_e}
\end{cases}</math>
 
'''Exemple'''
 
Si l'on veut minimiser la fonction ƒ(''x''<sub>1</sub>, ''x''<sub>2</sub>, ''x''<sub>3</sub>) = –''x''<sub>1</sub> –''x''<sub>2</sub> avec pour contraintes ''x''<sub>1</sub> – ''x''<sub>2</sub> = 0 et ''x''<sub>1</sub> + ''x''<sub>2</sub> + ''x''<sub>2</sub> = 2, on a :
: <math>\begin{pmatrix} -1 & -1 & 0 \end{pmatrix} \cdot \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} = 0 \Longrightarrow \mathbf{c} = \begin{pmatrix} -1 \\ -1 \\ 0 \end{pmatrix}</math>
: <math>\begin{pmatrix} 1 & -1 & 0 \\ 1 & 1 & 1 \end{pmatrix} \cdot \begin{pmatrix} x_1 \\ x_2 \\ x_3 \end{pmatrix} = \begin{pmatrix} 0 \\ 2 \end{pmatrix} \Longrightarrow \mathrm{A_e} = \begin{pmatrix} 1 & -1 & 0 \\ 1 & 1 & 1 \end{pmatrix} \text{ ; } \mathbf{b_e} = \begin{pmatrix} 0 \\ 2 \end{pmatrix} </math>
 
La solution s'obtient donc par
<source lang="scilab">
Aeq = [1, -1, 0 ; 1, 1,1];
beq = [0 ; 2];
c = [-1 ; -1 ; 0];
xopt = karmarkar(Aeq, beq, c)
</source>
et le résultat est :
<source lang="scilab">
xopt =
 
0.9999949
0.9999949
0.0000102
</source>
 
On peut y ajouter un système d'inéquations<ref>les cinq paramètres vides <code>[]</code> sont des paramètres que nous ne présentons pas ici. Ils sont décrits dans la page d'aide : {{lien web | url = https://help.scilab.org/docs/6.0.0/fr_FR/karmarkar.html | titre = karmarkar: Solves a linear optimization problem. | langue = en | site = help.scilab.org | consulté le = 2017-02-13}}</ref> :
<source lang="scilab">