├── README.md ├── Exams ├── Ecrit_PROL_2016_12_BING.pdf ├── Ecrit_PROL_2018_01_BING.pdf ├── Ecrit_PROL_2018_03_BING.pdf ├── Ecrit_PROL_2018_03_fr.pdf ├── Ecrit_PROL_2018_012_BING.pdf └── TeX │ ├── Ecrit_PROL_2018_06_APPINGII.pdf │ ├── Ecrit_PROL_2018_06_APPINGII.out │ ├── Ecrit_PROL_2018_01_BING.tex │ ├── Ecrit_PROL_2018_06_APPINGII.aux │ ├── Ecrit_PROL_2018_012_BING.tex │ ├── Ecrit_PROL_2018_03_BING.tex │ ├── Style │ └── linearProgramsStyle.sty │ ├── Ecrit_PROL_2018_03_fr.tex │ └── Ecrit_PROL_2018_06_APPINGII.tex ├── Slides ├── English │ ├── b_simplexAlgorithmFirst.pdf │ ├── c_simplexAlgorithmSecond.pdf │ ├── d_simplexAlgorithmInit.pdf │ ├── a_linearProgramsDefinition.pdf │ ├── e_simplexAlgorithmValidity.pdf │ └── Tex │ │ ├── Style │ │ ├── linearProgramsStyle.sty │ │ ├── beamerthememetropolis.sty │ │ ├── pgfplotsthemetol.sty │ │ ├── beamercolorthememetropolis.sty │ │ ├── beamerouterthememetropolis.sty │ │ ├── linearProgramsBeamer.sty │ │ ├── beamerinnerthememetropolis.sty │ │ └── beamerfontthememetropolis.sty │ │ ├── e_simplexAlgorithmValidity.tex │ │ └── d_simplexAlgorithmInit.tex └── Francais │ ├── b_simplexAlgorithmFirst.pdf │ ├── d_simplexAlgorithmInit.pdf │ ├── c_simplexAlgorithmSecond.pdf │ ├── a_linearProgramsDefinition.pdf │ └── Tex │ ├── Style │ ├── linearProgramsStyle.sty │ ├── beamerthememetropolis.sty │ ├── pgfplotsthemetol.sty │ ├── beamercolorthememetropolis.sty │ ├── beamerouterthememetropolis.sty │ ├── linearProgramsBeamer.sty │ ├── beamerinnerthememetropolis.sty │ └── beamerfontthememetropolis.sty │ ├── e_simplexAlgorithmValidity.tex │ └── d_simplexAlgorithmInit.tex ├── Python ├── linprog │ ├── __init__.py │ ├── linprogs.py │ └── simplex.py └── linprog_for_dummies.ipynb ├── course_content.txt ├── .gitignore └── LICENSE /README.md: -------------------------------------------------------------------------------- 1 | # Linear Programs 2 | Linear Programs course material authored at Epita first year's engineering program. 3 | -------------------------------------------------------------------------------- /Exams/Ecrit_PROL_2016_12_BING.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Exams/Ecrit_PROL_2016_12_BING.pdf -------------------------------------------------------------------------------- /Exams/Ecrit_PROL_2018_01_BING.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Exams/Ecrit_PROL_2018_01_BING.pdf -------------------------------------------------------------------------------- /Exams/Ecrit_PROL_2018_03_BING.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Exams/Ecrit_PROL_2018_03_BING.pdf -------------------------------------------------------------------------------- /Exams/Ecrit_PROL_2018_03_fr.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Exams/Ecrit_PROL_2018_03_fr.pdf -------------------------------------------------------------------------------- /Exams/Ecrit_PROL_2018_012_BING.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Exams/Ecrit_PROL_2018_012_BING.pdf -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_06_APPINGII.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Exams/TeX/Ecrit_PROL_2018_06_APPINGII.pdf -------------------------------------------------------------------------------- /Slides/English/b_simplexAlgorithmFirst.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/English/b_simplexAlgorithmFirst.pdf -------------------------------------------------------------------------------- /Slides/English/c_simplexAlgorithmSecond.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/English/c_simplexAlgorithmSecond.pdf -------------------------------------------------------------------------------- /Slides/English/d_simplexAlgorithmInit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/English/d_simplexAlgorithmInit.pdf -------------------------------------------------------------------------------- /Slides/Francais/b_simplexAlgorithmFirst.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/Francais/b_simplexAlgorithmFirst.pdf -------------------------------------------------------------------------------- /Slides/Francais/d_simplexAlgorithmInit.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/Francais/d_simplexAlgorithmInit.pdf -------------------------------------------------------------------------------- /Slides/English/a_linearProgramsDefinition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/English/a_linearProgramsDefinition.pdf -------------------------------------------------------------------------------- /Slides/English/e_simplexAlgorithmValidity.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/English/e_simplexAlgorithmValidity.pdf -------------------------------------------------------------------------------- /Slides/Francais/c_simplexAlgorithmSecond.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/Francais/c_simplexAlgorithmSecond.pdf -------------------------------------------------------------------------------- /Slides/Francais/a_linearProgramsDefinition.pdf: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/bashardudin/LinearPrograms/HEAD/Slides/Francais/a_linearProgramsDefinition.pdf -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_06_APPINGII.out: -------------------------------------------------------------------------------- 1 | \BOOKMARK [1][-]{section.1}{\311quivalence et dualit\351}{}% 1 2 | \BOOKMARK [1][-]{section.2}{Algorithme du simplexe}{}% 2 3 | -------------------------------------------------------------------------------- /Python/linprog/__init__.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # _*_ encoding: utf-8 _*_ 3 | 4 | """__init__.py: Init file for (rational) linear programming""" 5 | 6 | __author__ = "Bashar Dudin" 7 | __email__ = "bashar.dudin@epita.fr" 8 | -------------------------------------------------------------------------------- /course_content.txt: -------------------------------------------------------------------------------- 1 | Pre-requisites: 2 | 3 | Basic linear algebra: linear systems, Gauss elimination algorithm, matrices. 4 | 5 | Basic analysis: boundedness of numerical functions, understanding 6 | statement of an optimization problem. 7 | 8 | Learning outcomes: 9 | 10 | Ability to understand and implement simplex algorithm and its variants 11 | to solve linear programs. The latter are optimization problems subject 12 | to linear constraints. 13 | 14 | Course Overview: 15 | 16 | We give a detailed overview of the simplex algorithm and its variants, 17 | one of the major algorithms solving linear optimization problems, 18 | i.e. linear programs. After properly defining such programs we 19 | establish a number of conditions under which they have finite 20 | solutions. The simplex algorithm is firstly introduced under such 21 | restrictive conditions before being extended to any general linear 22 | program. Termination and validity of the algorithm are proven along 23 | the course. An implementation of studied pseudo-code is given and 24 | variants of the algorithms are discussed. Examples of low dimensional 25 | linear programs are studied during tutoring sessions. 26 | 27 | 28 | List of topics: 29 | 30 | - Defining standard and slack forms of linear programs 31 | - Geometric solutions to low dimensional linear programs 32 | - Simplex algorithm in case of basic feasiblity 33 | - Initialization - Ensuring feasiblity 34 | - Duality - Proving validity 35 | 36 | 37 | Assessement scheme: 38 | 39 | Written exam at the end of the course. 40 | 41 | Recommended courses: 42 | 43 | A good read is Chapter VII 29 "Linear Programming" of "Introduction to Algorithms" by Cormen, Leiserson, Rivest and Stein. 44 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/linearProgramsStyle.sty: -------------------------------------------------------------------------------- 1 | %%%% This package contains my shortcuts and predefined commandes for 2 | %%%% the Mimo project. 3 | 4 | \ProvidesPackage{linearProgramsStyle}[2016/03/03 Styling Content] 5 | 6 | \RequirePackage{amsmath, amssymb, amsfonts} 7 | \RequirePackage{xcolor} 8 | \RequirePackage{colortbl} 9 | \RequirePackage{tcolorbox} 10 | \RequirePackage{wrapfig} 11 | \RequirePackage{systeme} 12 | 13 | \RequirePackage{minted} 14 | \RequirePackage{alltt} 15 | \RequirePackage{algpseudocode} 16 | \RequirePackage{algorithm} 17 | \renewcommand{\algorithmicrequire}{\textbf{Input:}} 18 | \renewcommand{\algorithmicensure}{\textbf{Output:}} 19 | \newcommand{\algorithmicbreak}{\textbf{break}} 20 | \newcommand{\Break}{\State \algorithmicbreak} 21 | 22 | \RequirePackage{pgfplots} 23 | \usepgfplotslibrary{fillbetween} 24 | \usepgfplotslibrary{colorbrewer} 25 | 26 | \RequirePackage{tikz, tkz-tab} 27 | \usetikzlibrary{colorbrewer} 28 | 29 | \RequirePackage{multicol} 30 | \RequirePackage{hyperref} 31 | \RequirePackage{centernot} 32 | 33 | %%% Usual commands 34 | 35 | \newcommand{\N}{\mathbb{N}} 36 | \newcommand{\Z}{\mathbb{Z}} 37 | \newcommand{\R}{\mathbb{R}} 38 | \newcommand{\C}{\mathbb{C}} 39 | 40 | % Fonts 41 | 42 | \renewcommand{\emph}[1]{\textit{\textbf{#1}}} 43 | \newcommand{\bs}[1]{\boldsymbol{#1}} 44 | 45 | \DeclareMathOperator{\dd}{d\!} 46 | 47 | %%% Custom envriroments and commands 48 | 49 | \newenvironment{linearProg}[4]{ 50 | \def\arraystretch{1.1} 51 | \begin{tabular}{lc} 52 | #1 & #2 \\ 53 | subject to & \\ 54 | & \sysdelim..{#3} \\ 55 | with & #4 56 | }{ 57 | \end{tabular} 58 | } 59 | 60 | \newenvironment{linearProgG}[3]{ 61 | \def\arraystretch{1.1} 62 | \begin{tabular}{lc} 63 | maximize & #1 \\ 64 | subject to & \\ 65 | & #2 \\ 66 | with & #3 67 | }{ 68 | \end{tabular} 69 | } 70 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/linearProgramsStyle.sty: -------------------------------------------------------------------------------- 1 | %%%% This package contains my shortcuts and predefined commandes for 2 | %%%% the Mimo project. 3 | 4 | \ProvidesPackage{linearProgramsStyle}[2016/03/03 Styling Content] 5 | 6 | \RequirePackage{amsmath, amssymb, amsfonts} 7 | \RequirePackage{xcolor} 8 | \RequirePackage{colortbl} 9 | \RequirePackage{tcolorbox} 10 | \RequirePackage{wrapfig} 11 | \RequirePackage{systeme} 12 | 13 | \RequirePackage{minted} 14 | \RequirePackage{alltt} 15 | \RequirePackage{algpseudocode} 16 | \RequirePackage{algorithm} 17 | \renewcommand{\algorithmicrequire}{\textbf{Input:}} 18 | \renewcommand{\algorithmicensure}{\textbf{Output:}} 19 | \newcommand{\algorithmicbreak}{\textbf{break}} 20 | \newcommand{\Break}{\State \algorithmicbreak} 21 | 22 | \RequirePackage{pgfplots} 23 | \usepgfplotslibrary{fillbetween} 24 | \usepgfplotslibrary{colorbrewer} 25 | 26 | \RequirePackage{tikz, tkz-tab} 27 | \usetikzlibrary{colorbrewer} 28 | 29 | \RequirePackage{multicol} 30 | \RequirePackage{hyperref} 31 | \RequirePackage{centernot} 32 | 33 | %%% Usual commands 34 | 35 | \newcommand{\N}{\mathbb{N}} 36 | \newcommand{\Z}{\mathbb{Z}} 37 | \newcommand{\R}{\mathbb{R}} 38 | \newcommand{\C}{\mathbb{C}} 39 | 40 | % Fonts 41 | 42 | \renewcommand{\emph}[1]{\textit{\textbf{#1}}} 43 | \newcommand{\bs}[1]{\boldsymbol{#1}} 44 | 45 | \DeclareMathOperator{\dd}{d\!} 46 | 47 | %%% Custom envriroments and commands 48 | 49 | \newenvironment{linearProg}[4]{ 50 | \def\arraystretch{1.1} 51 | \begin{tabular}{lc} 52 | #1 & #2 \\ 53 | sujet \`a & \\ 54 | & \sysdelim..{#3} \\ 55 | avec & #4 56 | }{ 57 | \end{tabular} 58 | } 59 | 60 | \newenvironment{linearProgG}[3]{ 61 | \def\arraystretch{1.1} 62 | \begin{tabular}{lc} 63 | maximiser & #1 \\ 64 | sujet \'a & \\ 65 | & #2 \\ 66 | avec & #3 67 | }{ 68 | \end{tabular} 69 | } 70 | -------------------------------------------------------------------------------- /.gitignore: -------------------------------------------------------------------------------- 1 | # Private 2 | Results/ 3 | .gitignore 4 | 5 | # Temp 6 | auto/ 7 | _minted* 8 | 9 | # Byte-compiled / optimized / DLL files 10 | __pycache__/ 11 | *.py[cod] 12 | *$py.class 13 | 14 | # C extensions 15 | *.so 16 | 17 | # Distribution / packaging 18 | .Python 19 | env/ 20 | build/ 21 | develop-eggs/ 22 | dist/ 23 | downloads/ 24 | eggs/ 25 | .eggs/ 26 | lib/ 27 | lib64/ 28 | parts/ 29 | sdist/ 30 | var/ 31 | wheels/ 32 | *.egg-info/ 33 | .installed.cfg 34 | *.egg 35 | 36 | # PyInstaller 37 | # Usually these files are written by a python script from a template 38 | # before PyInstaller builds the exe, so as to inject date/other infos into it. 39 | *.manifest 40 | *.spec 41 | 42 | # Installer logs 43 | pip-log.txt 44 | pip-delete-this-directory.txt 45 | 46 | # Unit test / coverage reports 47 | htmlcov/ 48 | .tox/ 49 | .coverage 50 | .coverage.* 51 | .cache 52 | nosetests.xml 53 | coverage.xml 54 | *.cover 55 | .hypothesis/ 56 | 57 | # Translations 58 | *.mo 59 | *.pot 60 | 61 | # Django stuff: 62 | *.log 63 | local_settings.py 64 | 65 | # Flask stuff: 66 | instance/ 67 | .webassets-cache 68 | 69 | # Scrapy stuff: 70 | .scrapy 71 | 72 | # Sphinx documentation 73 | docs/_build/ 74 | 75 | # PyBuilder 76 | target/ 77 | 78 | # Jupyter Notebook 79 | .ipynb_checkpoints 80 | 81 | # pyenv 82 | .python-version 83 | 84 | # celery beat schedule file 85 | celerybeat-schedule 86 | 87 | # SageMath parsed files 88 | *.sage.py 89 | 90 | # dotenv 91 | .env 92 | 93 | # virtualenv 94 | .venv 95 | venv/ 96 | ENV/ 97 | 98 | # Spyder project settings 99 | .spyderproject 100 | .spyproject 101 | 102 | # Rope project settings 103 | .ropeproject 104 | 105 | # mkdocs documentation 106 | /site 107 | 108 | # mypy 109 | .mypy_cache/ 110 | 111 | # temp 112 | *~ 113 | *DS_Store 114 | *_old.tex 115 | *vrb 116 | -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_01_BING.tex: -------------------------------------------------------------------------------- 1 | \documentclass[12pt,a4paper]{article} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage[T1]{fontenc} 4 | \usepackage[english]{babel} 5 | \usepackage{fancyhdr} 6 | \usepackage[margin=1in]{geometry} 7 | \usepackage{exsheets} 8 | \usepackage{enumerate} 9 | 10 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 11 | 12 | \pagestyle{fancy} 13 | \renewcommand{\headrulewidth}{2pt} 14 | \fancyhead[L]{EPITA\_ING1\_BING\_2020\_S5\_PROL} 15 | \fancyhead[R]{Janvier 2018} 16 | 17 | \fancyfoot[C]{\textbf{\thepage}} 18 | \fancyfoot[L]{} 19 | 20 | \SetupExSheets{solution/print=false} 21 | \SetupExSheets{question/type=exam} 22 | \SetupExSheets[points]{name=point,name-plural=points} 23 | \RenewQuSolPair{question}[name={\large Exercise}]{solution} 24 | 25 | \begin{document} 26 | \begin{center} 27 | 28 | {\Large \textbf{Linear Programming (PROL)\footnote{Head of course : P.~Siarry.}}}\\ 29 | 30 | \vspace{10pt} 31 | {\Large \textit{Final Exam}} 32 | 33 | \vspace{2\baselineskip} 34 | \end{center} 35 | \begin{center} 36 | \begin{minipage}{\textwidth} 37 | Duration of the exam : 1h30\\ 38 | \textbf{No documents are allowed}\\ 39 | Only \emph{non-programmable} pocket calculators are allowed. 40 | \end{minipage} 41 | \end{center} 42 | \rule{\textwidth}{2pt} 43 | \vspace{2\baselineskip} 44 | 45 | \noindent Let $(P)$ be the following linear program: 46 | \begin{center} 47 | \begin{linearProg}{ 48 | maximize 49 | }{ 50 | $z = x_1 + 5x_2 + 3x_3$ 51 | }{ 52 | \systeme{ 53 | x_1 + 3x_2 + 8x_3 \leq 2, 54 | x_1 + 6x_2 + 2x_3 \geq 8 55 | } 56 | }{ 57 | $x_1$, $x_2$, $x_3 \geq 0$ 58 | } 59 | \end{linearProg} 60 | \end{center} 61 | 62 | \begin{enumerate} 63 | \item Solve the linear program $(P)$ using the simplex algorithm in 64 | its tableau form. 65 | \item Write down the dual linear program $(D)$ of $(P)$. 66 | \item Using answer to question (1.) write down an optimal tableau of 67 | $D$. 68 | \item Using the simplex algorithm solve the linear program $(D)$ 69 | starting at its expression given by the answer to question (2.). 70 | \item Compare results of questions (3.) and (4.). Are both obtained 71 | optimal tableaux of $(D)$ identical? 72 | \end{enumerate} 73 | 74 | \end{document} 75 | 76 | %%% Local Variables: 77 | %%% mode: latex 78 | %%% TeX-master: t 79 | %%% End: 80 | -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_06_APPINGII.aux: -------------------------------------------------------------------------------- 1 | \relax 2 | \providecommand\hyper@newdestlabel[2]{} 3 | \providecommand\zref@newlabel[2]{} 4 | \catcode `:\active 5 | \catcode `;\active 6 | \catcode `!\active 7 | \catcode `?\active 8 | \providecommand \exsheets@question@property [3]{} 9 | \providecommand \exsheets@save@number [2]{} 10 | \providecommand \exsheets@sum@of@points [1]{} 11 | \providecommand \exsheets@sum@of@bonus [1]{} 12 | \providecommand \exsheets@used@id [2]{} 13 | 14 | \providecommand\HyperFirstAtBeginDocument{\AtBeginDocument} 15 | \HyperFirstAtBeginDocument{\ifx\hyper@anchor\@undefined 16 | \global\let\oldcontentsline\contentsline 17 | \gdef\contentsline#1#2#3#4{\oldcontentsline{#1}{#2}{#3}} 18 | \global\let\oldnewlabel\newlabel 19 | \gdef\newlabel#1#2{\newlabelxx{#1}#2} 20 | \gdef\newlabelxx#1#2#3#4#5#6{\oldnewlabel{#1}{{#2}{#3}}} 21 | \AtEndDocument{\ifx\hyper@anchor\@undefined 22 | \let\contentsline\oldcontentsline 23 | \let\newlabel\oldnewlabel 24 | \fi} 25 | \fi} 26 | \global\let\hyper@last\relax 27 | \gdef\HyperFirstAtBeginDocument#1{#1} 28 | \providecommand\HyField@AuxAddToFields[1]{} 29 | \providecommand\HyField@AuxAddToCoFields[2]{} 30 | \exsheets@used@id {1}{1} 31 | \exsheets@save@number {1}{-1-1} 32 | \exsheets@question@property {1}{counter}{1-1.} 33 | \exsheets@question@property {1}{points}{3} 34 | \exsheets@used@id {2}{2} 35 | \exsheets@save@number {2}{-1-2} 36 | \exsheets@question@property {2}{counter}{1-2.} 37 | \exsheets@question@property {2}{points}{1} 38 | \exsheets@used@id {3}{3} 39 | \exsheets@save@number {3}{-1-3} 40 | \exsheets@question@property {3}{counter}{1-3.} 41 | \exsheets@question@property {3}{points}{1} 42 | \exsheets@used@id {4}{4} 43 | \exsheets@save@number {4}{-1-4} 44 | \exsheets@question@property {4}{counter}{1-4.} 45 | \exsheets@question@property {4}{points}{2} 46 | \exsheets@question@property {4}{bonus-points}{1} 47 | \providecommand\tcolorbox@label[2]{} 48 | \select@language{french} 49 | \@writefile{toc}{\select@language{french}} 50 | \@writefile{lof}{\select@language{french}} 51 | \@writefile{lot}{\select@language{french}} 52 | \@writefile{toc}{\contentsline {section}{\numberline {1}\IeC {\'E}quivalence et dualit\IeC {\'e}}{1}{section.1}} 53 | \exsheets@used@id {5}{5} 54 | \exsheets@save@number {5}{-2-5} 55 | \exsheets@question@property {5}{counter}{2-5.} 56 | \exsheets@question@property {5}{bonus-points}{2} 57 | \exsheets@used@id {6}{6} 58 | \exsheets@save@number {6}{-2-6} 59 | \exsheets@question@property {6}{counter}{2-6.} 60 | \exsheets@question@property {6}{points}{7} 61 | \exsheets@used@id {7}{7} 62 | \exsheets@save@number {7}{-2-7} 63 | \exsheets@question@property {7}{counter}{2-7.} 64 | \exsheets@question@property {7}{points}{6} 65 | \exsheets@sum@of@points {20} 66 | \exsheets@sum@of@bonus {3} 67 | \gdef \numberofquestions {7} 68 | \@writefile{toc}{\contentsline {section}{\numberline {2}Algorithme du simplexe}{2}{section.2}} 69 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/beamerthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerthememetropolis} 21 | [2016/03/14 v1.1 Metropolis Beamer theme] 22 | \RequirePackage{etoolbox} 23 | \RequirePackage{pgfopts} 24 | \pgfkeys{/metropolis/.cd, 25 | .search also={ 26 | /metropolis/inner, 27 | /metropolis/outer, 28 | /metropolis/color, 29 | /metropolis/font, 30 | } 31 | } 32 | \pgfkeys{ 33 | /metropolis/titleformat plain/.cd, 34 | .is choice, 35 | regular/.code={% 36 | \let\metropolis@plaintitleformat\@empty% 37 | \setbeamerfont{standout}{shape=\normalfont}% 38 | }, 39 | smallcaps/.code={% 40 | \let\metropolis@plaintitleformat\@empty% 41 | \setbeamerfont{standout}{shape=\scshape}% 42 | }, 43 | allsmallcaps/.code={% 44 | \let\metropolis@plaintitleformat\MakeLowercase% 45 | \setbeamerfont{standout}{shape=\scshape}% 46 | \PackageWarning{beamerthememetropolis}{% 47 | Be aware that titleformat plain=allsmallcaps can lead to problems% 48 | } 49 | }, 50 | allcaps/.code={% 51 | \let\metropolis@plaintitleformat\MakeUppercase% 52 | \setbeamerfont{standout}{shape=\normalfont}% 53 | \PackageWarning{beamerthememetropolis}{% 54 | Be aware that titleformat plain=allcaps can lead to problems% 55 | } 56 | }, 57 | } 58 | \pgfkeys{ 59 | /metropolis/titleformat/.code=\pgfkeysalso{ 60 | font/titleformat title=#1, 61 | font/titleformat subtitle=#1, 62 | font/titleformat section=#1, 63 | font/titleformat frame=#1, 64 | titleformat plain=#1, 65 | } 66 | } 67 | \pgfkeys{/metropolis/.cd, 68 | usetitleprogressbar/.code=\pgfkeysalso{outer/progressbar=frametitle}, 69 | noslidenumbers/.code=\pgfkeysalso{outer/numbering=none}, 70 | usetotalslideindicator/.code=\pgfkeysalso{outer/numbering=fraction}, 71 | nosectionslide/.code=\pgfkeysalso{inner/sectionpage=none}, 72 | darkcolors/.code=\pgfkeysalso{color/background=dark}, 73 | blockbg/.code=\pgfkeysalso{color/block=fill, inner/block=fill}, 74 | } 75 | \newcommand{\metropolis@setdefaults}{ 76 | \pgfkeys{/metropolis/.cd, 77 | titleformat plain=regular, 78 | } 79 | } 80 | \useinnertheme{metropolis} 81 | \useoutertheme{metropolis} 82 | \usecolortheme{metropolis} 83 | \usefonttheme{metropolis} 84 | \AtEndPreamble{% 85 | \@ifpackageloaded{pgfplots}{% 86 | \RequirePackage{pgfplotsthemetol} 87 | }{} 88 | } 89 | \newcommand{\metroset}[1]{\pgfkeys{/metropolis/.cd,#1}} 90 | \def\metropolis@plaintitleformat#1{#1} 91 | \newcommand{\plain}[2][]{% 92 | \PackageWarning{beamerthememetropolis}{% 93 | The syntax `\plain' may be deprecated in a future version of Metropolis. 94 | Please use a frame with [standout] instead. 95 | } 96 | \begin{frame}[standout]{#1} 97 | \metropolis@plaintitleformat{#2} 98 | \end{frame} 99 | } 100 | \newcommand{\mreducelistspacing}{\vspace{-\topsep}} 101 | \metropolis@setdefaults 102 | \ProcessPgfOptions{/metropolis} 103 | \endinput 104 | %% 105 | %% End of file `beamerthememetropolis.sty'. 106 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/beamerthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerthememetropolis} 21 | [2016/03/14 v1.1 Metropolis Beamer theme] 22 | \RequirePackage{etoolbox} 23 | \RequirePackage{pgfopts} 24 | \pgfkeys{/metropolis/.cd, 25 | .search also={ 26 | /metropolis/inner, 27 | /metropolis/outer, 28 | /metropolis/color, 29 | /metropolis/font, 30 | } 31 | } 32 | \pgfkeys{ 33 | /metropolis/titleformat plain/.cd, 34 | .is choice, 35 | regular/.code={% 36 | \let\metropolis@plaintitleformat\@empty% 37 | \setbeamerfont{standout}{shape=\normalfont}% 38 | }, 39 | smallcaps/.code={% 40 | \let\metropolis@plaintitleformat\@empty% 41 | \setbeamerfont{standout}{shape=\scshape}% 42 | }, 43 | allsmallcaps/.code={% 44 | \let\metropolis@plaintitleformat\MakeLowercase% 45 | \setbeamerfont{standout}{shape=\scshape}% 46 | \PackageWarning{beamerthememetropolis}{% 47 | Be aware that titleformat plain=allsmallcaps can lead to problems% 48 | } 49 | }, 50 | allcaps/.code={% 51 | \let\metropolis@plaintitleformat\MakeUppercase% 52 | \setbeamerfont{standout}{shape=\normalfont}% 53 | \PackageWarning{beamerthememetropolis}{% 54 | Be aware that titleformat plain=allcaps can lead to problems% 55 | } 56 | }, 57 | } 58 | \pgfkeys{ 59 | /metropolis/titleformat/.code=\pgfkeysalso{ 60 | font/titleformat title=#1, 61 | font/titleformat subtitle=#1, 62 | font/titleformat section=#1, 63 | font/titleformat frame=#1, 64 | titleformat plain=#1, 65 | } 66 | } 67 | \pgfkeys{/metropolis/.cd, 68 | usetitleprogressbar/.code=\pgfkeysalso{outer/progressbar=frametitle}, 69 | noslidenumbers/.code=\pgfkeysalso{outer/numbering=none}, 70 | usetotalslideindicator/.code=\pgfkeysalso{outer/numbering=fraction}, 71 | nosectionslide/.code=\pgfkeysalso{inner/sectionpage=none}, 72 | darkcolors/.code=\pgfkeysalso{color/background=dark}, 73 | blockbg/.code=\pgfkeysalso{color/block=fill, inner/block=fill}, 74 | } 75 | \newcommand{\metropolis@setdefaults}{ 76 | \pgfkeys{/metropolis/.cd, 77 | titleformat plain=regular, 78 | } 79 | } 80 | \useinnertheme{metropolis} 81 | \useoutertheme{metropolis} 82 | \usecolortheme{metropolis} 83 | \usefonttheme{metropolis} 84 | \AtEndPreamble{% 85 | \@ifpackageloaded{pgfplots}{% 86 | \RequirePackage{pgfplotsthemetol} 87 | }{} 88 | } 89 | \newcommand{\metroset}[1]{\pgfkeys{/metropolis/.cd,#1}} 90 | \def\metropolis@plaintitleformat#1{#1} 91 | \newcommand{\plain}[2][]{% 92 | \PackageWarning{beamerthememetropolis}{% 93 | The syntax `\plain' may be deprecated in a future version of Metropolis. 94 | Please use a frame with [standout] instead. 95 | } 96 | \begin{frame}[standout]{#1} 97 | \metropolis@plaintitleformat{#2} 98 | \end{frame} 99 | } 100 | \newcommand{\mreducelistspacing}{\vspace{-\topsep}} 101 | \metropolis@setdefaults 102 | \ProcessPgfOptions{/metropolis} 103 | \endinput 104 | %% 105 | %% End of file `beamerthememetropolis.sty'. 106 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/pgfplotsthemetol.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `pgfplotsthemetol.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% pgfplotsthemetol.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{pgfplotsthemetol} 21 | [2016/03/14 PGFplots colors based on Paul Tol's SRON technical note] 22 | \definecolor{TolDarkPurple}{HTML}{332288} 23 | \definecolor{TolDarkBlue}{HTML}{6699CC} 24 | \definecolor{TolLightBlue}{HTML}{88CCEE} 25 | \definecolor{TolLightGreen}{HTML}{44AA99} 26 | \definecolor{TolDarkGreen}{HTML}{117733} 27 | \definecolor{TolDarkBrown}{HTML}{999933} 28 | \definecolor{TolLightBrown}{HTML}{DDCC77} 29 | \definecolor{TolDarkRed}{HTML}{661100} 30 | \definecolor{TolLightRed}{HTML}{CC6677} 31 | \definecolor{TolLightPink}{HTML}{AA4466} 32 | \definecolor{TolDarkPink}{HTML}{882255} 33 | \definecolor{TolLightPurple}{HTML}{AA4499} 34 | \pgfplotscreateplotcyclelist{mbarplot cycle}{% 35 | {draw=TolDarkBlue, fill=TolDarkBlue!70}, 36 | {draw=TolLightBrown, fill=TolLightBrown!70}, 37 | {draw=TolLightGreen, fill=TolLightGreen!70}, 38 | {draw=TolDarkPink, fill=TolDarkPink!70}, 39 | {draw=TolDarkPurple, fill=TolDarkPurple!70}, 40 | {draw=TolDarkRed, fill=TolDarkRed!70}, 41 | {draw=TolDarkBrown, fill=TolDarkBrown!70}, 42 | {draw=TolLightRed, fill=TolLightRed!70}, 43 | {draw=TolLightPink, fill=TolLightPink!70}, 44 | {draw=TolLightPurple, fill=TolLightPurple!70}, 45 | {draw=TolLightBlue, fill=TolLightBlue!70}, 46 | {draw=TolDarkGreen, fill=TolDarkGreen!70}, 47 | } 48 | \pgfplotscreateplotcyclelist{mlineplot cycle}{% 49 | {TolDarkBlue, mark=*, mark size=1.5pt}, 50 | {TolLightBrown, mark=square*, mark size=1.3pt}, 51 | {TolLightGreen, mark=triangle*, mark size=1.5pt}, 52 | {TolDarkBrown, mark=diamond*, mark size=1.5pt}, 53 | } 54 | \pgfplotsset{ 55 | compat=1.9, 56 | mlineplot/.style={ 57 | mbaseplot, 58 | xmajorgrids=true, 59 | ymajorgrids=true, 60 | major grid style={dotted}, 61 | axis x line=bottom, 62 | axis y line=left, 63 | legend style={ 64 | cells={anchor=west}, 65 | draw=none 66 | }, 67 | cycle list name=mlineplot cycle, 68 | }, 69 | mbarplot base/.style={ 70 | mbaseplot, 71 | bar width=6pt, 72 | axis y line*=none, 73 | }, 74 | mbarplot/.style={ 75 | mbarplot base, 76 | ybar, 77 | xmajorgrids=false, 78 | ymajorgrids=true, 79 | area legend, 80 | legend image code/.code={% 81 | \draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm); 82 | }, 83 | cycle list name=mbarplot cycle, 84 | }, 85 | horizontal mbarplot/.style={ 86 | mbarplot base, 87 | xmajorgrids=true, 88 | ymajorgrids=false, 89 | xbar stacked, 90 | area legend, 91 | legend image code/.code={% 92 | \draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm); 93 | }, 94 | cycle list name=mbarplot cycle, 95 | }, 96 | mbaseplot/.style={ 97 | legend style={ 98 | draw=none, 99 | fill=none, 100 | cells={anchor=west}, 101 | }, 102 | x tick label style={ 103 | font=\footnotesize 104 | }, 105 | y tick label style={ 106 | font=\footnotesize 107 | }, 108 | legend style={ 109 | font=\footnotesize 110 | }, 111 | major grid style={ 112 | dotted, 113 | }, 114 | axis x line*=bottom, 115 | }, 116 | disable thousands separator/.style={ 117 | /pgf/number format/.cd, 118 | 1000 sep={} 119 | }, 120 | } 121 | \endinput 122 | %% 123 | %% End of file `pgfplotsthemetol.sty'. 124 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/pgfplotsthemetol.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `pgfplotsthemetol.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% pgfplotsthemetol.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{pgfplotsthemetol} 21 | [2016/03/14 PGFplots colors based on Paul Tol's SRON technical note] 22 | \definecolor{TolDarkPurple}{HTML}{332288} 23 | \definecolor{TolDarkBlue}{HTML}{6699CC} 24 | \definecolor{TolLightBlue}{HTML}{88CCEE} 25 | \definecolor{TolLightGreen}{HTML}{44AA99} 26 | \definecolor{TolDarkGreen}{HTML}{117733} 27 | \definecolor{TolDarkBrown}{HTML}{999933} 28 | \definecolor{TolLightBrown}{HTML}{DDCC77} 29 | \definecolor{TolDarkRed}{HTML}{661100} 30 | \definecolor{TolLightRed}{HTML}{CC6677} 31 | \definecolor{TolLightPink}{HTML}{AA4466} 32 | \definecolor{TolDarkPink}{HTML}{882255} 33 | \definecolor{TolLightPurple}{HTML}{AA4499} 34 | \pgfplotscreateplotcyclelist{mbarplot cycle}{% 35 | {draw=TolDarkBlue, fill=TolDarkBlue!70}, 36 | {draw=TolLightBrown, fill=TolLightBrown!70}, 37 | {draw=TolLightGreen, fill=TolLightGreen!70}, 38 | {draw=TolDarkPink, fill=TolDarkPink!70}, 39 | {draw=TolDarkPurple, fill=TolDarkPurple!70}, 40 | {draw=TolDarkRed, fill=TolDarkRed!70}, 41 | {draw=TolDarkBrown, fill=TolDarkBrown!70}, 42 | {draw=TolLightRed, fill=TolLightRed!70}, 43 | {draw=TolLightPink, fill=TolLightPink!70}, 44 | {draw=TolLightPurple, fill=TolLightPurple!70}, 45 | {draw=TolLightBlue, fill=TolLightBlue!70}, 46 | {draw=TolDarkGreen, fill=TolDarkGreen!70}, 47 | } 48 | \pgfplotscreateplotcyclelist{mlineplot cycle}{% 49 | {TolDarkBlue, mark=*, mark size=1.5pt}, 50 | {TolLightBrown, mark=square*, mark size=1.3pt}, 51 | {TolLightGreen, mark=triangle*, mark size=1.5pt}, 52 | {TolDarkBrown, mark=diamond*, mark size=1.5pt}, 53 | } 54 | \pgfplotsset{ 55 | compat=1.9, 56 | mlineplot/.style={ 57 | mbaseplot, 58 | xmajorgrids=true, 59 | ymajorgrids=true, 60 | major grid style={dotted}, 61 | axis x line=bottom, 62 | axis y line=left, 63 | legend style={ 64 | cells={anchor=west}, 65 | draw=none 66 | }, 67 | cycle list name=mlineplot cycle, 68 | }, 69 | mbarplot base/.style={ 70 | mbaseplot, 71 | bar width=6pt, 72 | axis y line*=none, 73 | }, 74 | mbarplot/.style={ 75 | mbarplot base, 76 | ybar, 77 | xmajorgrids=false, 78 | ymajorgrids=true, 79 | area legend, 80 | legend image code/.code={% 81 | \draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm); 82 | }, 83 | cycle list name=mbarplot cycle, 84 | }, 85 | horizontal mbarplot/.style={ 86 | mbarplot base, 87 | xmajorgrids=true, 88 | ymajorgrids=false, 89 | xbar stacked, 90 | area legend, 91 | legend image code/.code={% 92 | \draw[#1] (0cm,-0.1cm) rectangle (0.15cm,0.1cm); 93 | }, 94 | cycle list name=mbarplot cycle, 95 | }, 96 | mbaseplot/.style={ 97 | legend style={ 98 | draw=none, 99 | fill=none, 100 | cells={anchor=west}, 101 | }, 102 | x tick label style={ 103 | font=\footnotesize 104 | }, 105 | y tick label style={ 106 | font=\footnotesize 107 | }, 108 | legend style={ 109 | font=\footnotesize 110 | }, 111 | major grid style={ 112 | dotted, 113 | }, 114 | axis x line*=bottom, 115 | }, 116 | disable thousands separator/.style={ 117 | /pgf/number format/.cd, 118 | 1000 sep={} 119 | }, 120 | } 121 | \endinput 122 | %% 123 | %% End of file `pgfplotsthemetol.sty'. 124 | -------------------------------------------------------------------------------- /Python/linprog/linprogs.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # _*_ encoding: utf-8 _*_ 3 | 4 | """linprogs.py: Implements rational linear program object""" 5 | 6 | import numpy as np 7 | import fractions as frac 8 | 9 | __author__ = "Bashar Dudin" 10 | __email__ = "bashar.dudin@epita.fr" 11 | 12 | 13 | class LinearProgram(object): 14 | 15 | def __init__(self, a, b, c, v=0): 16 | 17 | if not all(isinstance(i, np.ndarray) for i in (a, b, c)): 18 | raise TypeError("Arguments of numpy type array expected") 19 | 20 | if a.shape != (b.shape[0], c.shape[0]): 21 | raise TypeError("Arguments are not of coherent dimensions") 22 | 23 | m, n = a.shape 24 | 25 | # Storing slack form of input 26 | self.basic = [x for x in range(n, n+m)] 27 | self.shape = (m, n+m) 28 | 29 | self.table = np.zeros((m+1, n+m+1), dtype=frac.Fraction) 30 | self.table[0, :] = np.hstack((-c, np.zeros(m, dtype=frac.Fraction), np.array(v))) 31 | self.table[1:, :] = np.hstack((a, np.eye(self.shape[0], dtype=frac.Fraction), b)) 32 | 33 | def __str__(self, width=4): 34 | """ Prints linear program to standard IO device. 35 | 36 | Useful if size of linear problem is reasonable. 37 | """ 38 | # FIXME: Better alignement in case of fractions. Poorly supports formatting. 39 | 40 | def element_template(x, width=width): 41 | if isinstance(x, int): 42 | s = "{0: >{width}}".format(x, width=width+2) 43 | elif x.denominator == 1: 44 | s = "{0: >{width}}".format(x.numerator, width=width+2) 45 | else: 46 | s = "{0: >{width}}/{1:<}".format(x.numerator, x.denominator, width=width) 47 | s += " "*(2*width - len(s)) 48 | return(s) 49 | 50 | template = [" "] 51 | 52 | for j in range(self.shape[1]): 53 | template.append(element_template(self.table[0, j])) 54 | template.append(" {:>}\n\n".format(element_template(self.table[0, -1]))) 55 | 56 | for i in range(self.shape[0]): 57 | template.append("{:>} |".format(self.basic[i])) 58 | for j in range(self.shape[1]): 59 | template.append(element_template(self.table[i+1, j])) 60 | template.append(" {:>}\n".format(element_template(self.table[i+1, -1]))) 61 | return "".join(template) 62 | 63 | def basic_solution(self): 64 | """ Returns basic solution of linear program""" 65 | v = np.zeros(self.shape[1], dtype=frac.Fraction) 66 | for i in range(self.shape[0]): 67 | v[self.basic[i]] = self.table[i+1, -1] 68 | return v 69 | 70 | def has_feasible_basic(self): 71 | """ Checks if basic solution is feasible""" 72 | return all(self.basic_solution() >= 0) 73 | 74 | def pivot(self, index_in, index_out): 75 | """ Pivots linear program. 76 | 77 | Returns linear program equivalent ot input after exchanging roles of 78 | variables of respective indices index_in and index_out. 79 | 80 | :param index_in: index of column (in the tableau) entering into basic 81 | set of indices. 82 | :param index_out: index of line (in the tableau) leaving basic set of 83 | indices. 84 | :return: linear program equivalent to input. 85 | """ 86 | a = self.table 87 | 88 | l = index_out 89 | e = index_in 90 | 91 | pivot = a[l, e] 92 | 93 | if self.shape[0] <= l <= 0 or self.shape[1] <= e < 0: 94 | raise ValueError("Indexes out of range") 95 | 96 | if pivot == 0: 97 | raise ValueError("Cannot pivot with given leaving and entering variables.") 98 | 99 | a[l, :] = a[l, :]/pivot 100 | 101 | for k in range(self.shape[0]): 102 | if k+1 != l: 103 | a[k+1, :] = a[k+1, :] - a[k+1, e]*a[l, :] 104 | a[0, :] = a[0, :] - a[0, e]*a[l, :] 105 | 106 | self.basic[l-1] = e 107 | 108 | def dual(self): 109 | """ Dual linear program 110 | 111 | :return: the dual linear program to a linear program. 112 | """ 113 | # TODO: Write down dual linear program 114 | 115 | pass 116 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/beamercolorthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamercolorthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamercolorthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamercolorthememetropolis}[2016/03/14 Metropolis color theme] 21 | \RequirePackage{pgfopts} 22 | \pgfkeys{ 23 | /metropolis/color/block/.cd, 24 | .is choice, 25 | transparent/.code=\metropolis@block@transparent, 26 | fill/.code=\metropolis@block@fill, 27 | } 28 | \pgfkeys{ 29 | /metropolis/color/background/.cd, 30 | .is choice, 31 | dark/.code=\metropolis@colors@dark, 32 | light/.code=\metropolis@colors@light, 33 | } 34 | \newcommand{\metropolis@color@setdefaults}{ 35 | \pgfkeys{/metropolis/color/.cd, 36 | background=light, 37 | block=transparent, 38 | } 39 | } 40 | \definecolor{mDarkBrown}{HTML}{604c38} 41 | \definecolor{mDarkTeal}{HTML}{23373b} 42 | \definecolor{mLightBrown}{HTML}{EB811B} 43 | \definecolor{mLightGreen}{HTML}{14B03D} 44 | \newcommand{\metropolis@colors@dark}{ 45 | \setbeamercolor{normal text}{% 46 | fg=black!2, 47 | bg=mDarkTeal 48 | } 49 | \usebeamercolor[fg]{normal text} 50 | } 51 | \newcommand{\metropolis@colors@light}{ 52 | \setbeamercolor{normal text}{% 53 | fg=mDarkTeal, 54 | bg=black!2 55 | } 56 | } 57 | \setbeamercolor{alerted text}{% 58 | fg=mLightBrown 59 | } 60 | \setbeamercolor{example text}{% 61 | fg=mLightGreen 62 | } 63 | \setbeamercolor{titlelike}{use=normal text, parent=normal text} 64 | \setbeamercolor{author}{use=normal text, parent=normal text} 65 | \setbeamercolor{date}{use=normal text, parent=normal text} 66 | \setbeamercolor{institute}{use=normal text, parent=normal text} 67 | \setbeamercolor{structure}{use=normal text, fg=normal text.fg} 68 | \setbeamercolor{palette primary}{% 69 | use=normal text, 70 | fg=normal text.bg, 71 | bg=normal text.fg 72 | } 73 | \setbeamercolor{frametitle}{% 74 | use=palette primary, 75 | parent=palette primary 76 | } 77 | \setbeamercolor{progress bar}{% 78 | use=alerted text, 79 | fg=alerted text.fg, 80 | bg=alerted text.fg!50!black!30 81 | } 82 | \setbeamercolor{title separator}{ 83 | use=progress bar, 84 | parent=progress bar 85 | } 86 | \setbeamercolor{progress bar in head/foot}{% 87 | use=progress bar, 88 | parent=progress bar 89 | } 90 | \setbeamercolor{progress bar in section page}{ 91 | use=progress bar, 92 | parent=progress bar 93 | } 94 | \newcommand{\metropolis@block@transparent}{ 95 | \setbeamercolor{block title}{% 96 | use=normal text, 97 | fg=normal text.fg, 98 | bg= 99 | } 100 | \setbeamercolor{block body}{ 101 | bg= 102 | } 103 | } 104 | \newcommand{\metropolis@block@fill}{ 105 | \setbeamercolor{block title}{% 106 | use=normal text, 107 | fg=normal text.fg, 108 | bg=normal text.bg!80!fg 109 | } 110 | \setbeamercolor{block body}{ 111 | use={block title, normal text}, 112 | bg=block title.bg!50!normal text.bg 113 | } 114 | } 115 | \setbeamercolor{block title alerted}{% 116 | use={block title, alerted text}, 117 | bg=block title.bg, 118 | fg=alerted text.fg 119 | } 120 | \setbeamercolor{block title example}{% 121 | use={block title, example text}, 122 | bg=block title.bg, 123 | fg=example text.fg 124 | } 125 | \setbeamercolor{block body alerted}{use=block body, parent=block body} 126 | \setbeamercolor{block body example}{use=block body, parent=block body} 127 | \setbeamercolor{footnote}{fg=normal text.fg!90} 128 | \setbeamercolor{footnote mark}{fg=.} 129 | \metropolis@color@setdefaults 130 | \ProcessPgfPackageOptions{/metropolis/color} 131 | \mode 132 | \endinput 133 | %% 134 | %% End of file `beamercolorthememetropolis.sty'. 135 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/beamercolorthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamercolorthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamercolorthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamercolorthememetropolis}[2016/03/14 Metropolis color theme] 21 | \RequirePackage{pgfopts} 22 | \pgfkeys{ 23 | /metropolis/color/block/.cd, 24 | .is choice, 25 | transparent/.code=\metropolis@block@transparent, 26 | fill/.code=\metropolis@block@fill, 27 | } 28 | \pgfkeys{ 29 | /metropolis/color/background/.cd, 30 | .is choice, 31 | dark/.code=\metropolis@colors@dark, 32 | light/.code=\metropolis@colors@light, 33 | } 34 | \newcommand{\metropolis@color@setdefaults}{ 35 | \pgfkeys{/metropolis/color/.cd, 36 | background=light, 37 | block=transparent, 38 | } 39 | } 40 | \definecolor{mDarkBrown}{HTML}{604c38} 41 | \definecolor{mDarkTeal}{HTML}{23373b} 42 | \definecolor{mLightBrown}{HTML}{EB811B} 43 | \definecolor{mLightGreen}{HTML}{14B03D} 44 | \newcommand{\metropolis@colors@dark}{ 45 | \setbeamercolor{normal text}{% 46 | fg=black!2, 47 | bg=mDarkTeal 48 | } 49 | \usebeamercolor[fg]{normal text} 50 | } 51 | \newcommand{\metropolis@colors@light}{ 52 | \setbeamercolor{normal text}{% 53 | fg=mDarkTeal, 54 | bg=black!2 55 | } 56 | } 57 | \setbeamercolor{alerted text}{% 58 | fg=mLightBrown 59 | } 60 | \setbeamercolor{example text}{% 61 | fg=mLightGreen 62 | } 63 | \setbeamercolor{titlelike}{use=normal text, parent=normal text} 64 | \setbeamercolor{author}{use=normal text, parent=normal text} 65 | \setbeamercolor{date}{use=normal text, parent=normal text} 66 | \setbeamercolor{institute}{use=normal text, parent=normal text} 67 | \setbeamercolor{structure}{use=normal text, fg=normal text.fg} 68 | \setbeamercolor{palette primary}{% 69 | use=normal text, 70 | fg=normal text.bg, 71 | bg=normal text.fg 72 | } 73 | \setbeamercolor{frametitle}{% 74 | use=palette primary, 75 | parent=palette primary 76 | } 77 | \setbeamercolor{progress bar}{% 78 | use=alerted text, 79 | fg=alerted text.fg, 80 | bg=alerted text.fg!50!black!30 81 | } 82 | \setbeamercolor{title separator}{ 83 | use=progress bar, 84 | parent=progress bar 85 | } 86 | \setbeamercolor{progress bar in head/foot}{% 87 | use=progress bar, 88 | parent=progress bar 89 | } 90 | \setbeamercolor{progress bar in section page}{ 91 | use=progress bar, 92 | parent=progress bar 93 | } 94 | \newcommand{\metropolis@block@transparent}{ 95 | \setbeamercolor{block title}{% 96 | use=normal text, 97 | fg=normal text.fg, 98 | bg= 99 | } 100 | \setbeamercolor{block body}{ 101 | bg= 102 | } 103 | } 104 | \newcommand{\metropolis@block@fill}{ 105 | \setbeamercolor{block title}{% 106 | use=normal text, 107 | fg=normal text.fg, 108 | bg=normal text.bg!80!fg 109 | } 110 | \setbeamercolor{block body}{ 111 | use={block title, normal text}, 112 | bg=block title.bg!50!normal text.bg 113 | } 114 | } 115 | \setbeamercolor{block title alerted}{% 116 | use={block title, alerted text}, 117 | bg=block title.bg, 118 | fg=alerted text.fg 119 | } 120 | \setbeamercolor{block title example}{% 121 | use={block title, example text}, 122 | bg=block title.bg, 123 | fg=example text.fg 124 | } 125 | \setbeamercolor{block body alerted}{use=block body, parent=block body} 126 | \setbeamercolor{block body example}{use=block body, parent=block body} 127 | \setbeamercolor{footnote}{fg=normal text.fg!90} 128 | \setbeamercolor{footnote mark}{fg=.} 129 | \metropolis@color@setdefaults 130 | \ProcessPgfPackageOptions{/metropolis/color} 131 | \mode 132 | \endinput 133 | %% 134 | %% End of file `beamercolorthememetropolis.sty'. 135 | -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_012_BING.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,a4paper]{article} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage[T1]{fontenc} 4 | \usepackage[english]{babel} 5 | \usepackage{fancyhdr} 6 | \usepackage[margin=.7in]{geometry} 7 | \usepackage{exsheets} 8 | \usepackage{enumerate} 9 | 10 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 11 | 12 | \pagestyle{fancy} 13 | 14 | \renewcommand{\headrulewidth}{2pt} 15 | \fancyhead[L]{EPITA\_ING1\_BING\_2020\_S5\_PROL} 16 | \fancyhead[R]{January 2018} 17 | 18 | \fancyfoot[C]{\textbf{\thepage}} 19 | \fancyfoot[L]{} 20 | 21 | \pretitle{\vspace{-.5\baselineskip} \begin{center}} 22 | \title{% 23 | { \huge Linear Programming (PROL)}% 24 | } 25 | \posttitle{ 26 | \end{center} 27 | \begin{flushleft} 28 | \vspace{3\baselineskip} \textit{ 29 | \!\!\emph{Duration: 1h30.}\\ 30 | \! \emph{No documents are allowed.} \\ 31 | Only \emph{non-programmable} pocket calculators are allowed. 32 | } 33 | \end{flushleft} 34 | \rule{\textwidth}{1.5pt} 35 | \vspace{-5\baselineskip} 36 | } 37 | \author{} 38 | \date{} 39 | 40 | \pdfinfo{ 41 | /Author (Bashar Dudin) 42 | /Title (PROL Exam -- 2018) 43 | /Subject (Linear Programming) 44 | } 45 | 46 | \begin{document} 47 | 48 | \maketitle\thispagestyle{fancy} 49 | 50 | We're considering the following list of linear programs respectively 51 | given the names $(A)$, $(B)$, $(C)$, $(D)$ and $(E)$, $(F)$. 52 | \[ 53 | (A) \; 54 | \left\{ 55 | \begin{linearProg}{ 56 | maximize 57 | }{ 58 | $x_1 + x_2 + x_3$ 59 | }{ 60 | \systeme{ 61 | 2x_1 + 3x_2 + x_3 \leq 1, 62 | x_1 - 4x_2 + 3x_3 \geq 2 63 | } 64 | }{ 65 | $x_1$, $x_2 \geq 0.$ 66 | } 67 | \end{linearProg} 68 | \right. 69 | \qquad (B)\; 70 | \left\{ 71 | \begin{linearProg}{ 72 | minimize 73 | }{ 74 | $- x_1 - x_2 - x_3 + x_4$ 75 | }{ 76 | \systeme{ 77 | 2x_1 + 3x_2 + x_3 - x_4 + \leq 1, 78 | -x_1 + 4x_2 - 3x_3 + 3x_4 \leq -2 79 | } 80 | }{ 81 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 82 | } 83 | \end{linearProg} 84 | \right. 85 | \] 86 | \[ 87 | (C) \; 88 | \left\{ 89 | \begin{linearProg}{ 90 | minimize 91 | }{ 92 | $-5x_1 - 6x_2 - 9x_3 - 8x_4$ 93 | }{ 94 | \systeme{ 95 | x_1 + 2x_2 + 3x_3 + x_4 \leq 5, 96 | -x_1 - x_2 - 2x_3 - 3x_4 \geq -3 97 | } 98 | }{ 99 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 100 | } 101 | \end{linearProg} 102 | \right. 103 | \qquad (D) \; 104 | \left\{ 105 | \begin{linearProg}{ 106 | maximize 107 | }{ 108 | $5x_1 + 6x_2 + 9x_3 + 8x_4$ 109 | }{ 110 | \systeme{ 111 | x_1 + 2x_2 + 3x_3 + x_4 \leq 5, 112 | x_1 + x_2 + 2x_3 + 3x_4 \leq 3 113 | } 114 | }{ 115 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 116 | } 117 | \end{linearProg} 118 | \right. 119 | \] 120 | \[ 121 | (E) \; 122 | \left\{ 123 | \begin{linearProg}{ 124 | maximize 125 | }{ 126 | $x_1 - 2x_2 - x_3$ 127 | }{ 128 | \systeme{ 129 | 2x_1 + x_2 - x_3 \leq -1, 130 | x_1 - 2x_2 + x_3 \leq -2 131 | } 132 | }{ 133 | $x_1$, $x_2$, $x_3 \geq 0.$ 134 | } 135 | \end{linearProg} 136 | \right.\qquad (F)\; 137 | \left\{ 138 | \begin{linearProg}{ 139 | maximize 140 | }{ 141 | $5x_1 + 6x_2 + 9x_3 + 8x_4$ 142 | }{ 143 | \systeme{ 144 | x_1 + 2x_2 + 3x_3 + x_4 \leq 5, 145 | x_1 + x_2 + 2x_3 + 3x_4 + x_5 = 3 146 | } 147 | }{ 148 | $x_1$, $x_2$, $x_3$, $x_4$, $x_5 \geq 0.$ 149 | } 150 | \end{linearProg} 151 | \right. 152 | \] 153 | 154 | \section{Equivalence and Duality} 155 | 156 | \begin{question} 157 | Which previous programs are equivalent to each others? Sort them 158 | into groups of equivalent classes. 159 | \end{question} 160 | 161 | \begin{question} 162 | Give standard form of $(F)$. What is the slack form of $(E)$? 163 | \end{question} 164 | 165 | \begin{question} 166 | What are the dual programs $(C)$ and $(D)$? 167 | \end{question} 168 | 169 | \begin{question} 170 | Which programs $(D)$, $(E)$ and $(F)$ have basic feasible 171 | solution? Give a feasible solution of $(A)$. 172 | \end{question} 173 | 174 | \newpage 175 | \section{Simplex Algorithm} 176 | 177 | \begin{question} 178 | Solve linear program $(D)$. 179 | \end{question} 180 | 181 | \begin{question} 182 | Out of previous solution of $(D)$ give a solution of its dual. 183 | \end{question} 184 | 185 | \begin{question} 186 | Transform program $(E)$ into an equivalent linear program having 187 | feasible basic solution. 188 | \end{question} 189 | 190 | \end{document} 191 | 192 | %%% Local Variables: 193 | %%% mode: latex 194 | %%% TeX-master: t 195 | %%% End: 196 | -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_03_BING.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,a4paper]{article} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage[T1]{fontenc} 4 | \usepackage[english]{babel} 5 | \usepackage{fancyhdr} 6 | \usepackage[margin=.7in]{geometry} 7 | \usepackage{exsheets} 8 | \usepackage{enumerate} 9 | 10 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 11 | 12 | \pagestyle{fancy} 13 | 14 | \renewcommand{\headrulewidth}{2pt} 15 | \fancyhead[L]{EPITA\_ING1\_BING\_2020\_S5\_PROL} 16 | \fancyhead[R]{March 2018} 17 | 18 | \fancyfoot[C]{\textbf{\thepage}} 19 | \fancyfoot[L]{} 20 | 21 | \pretitle{\vspace{-.5\baselineskip} \begin{center}} 22 | \title{% 23 | { \huge Linear Programming}\\ % 24 | \vspace{.5\baselineskip} 25 | {\Large \textit{Complemetary Exam} } 26 | } 27 | \posttitle{ 28 | \end{center} 29 | \begin{flushleft} 30 | \vspace{2\baselineskip} \textit{ 31 | \!\!\emph{Duration: 1h30.}\\ 32 | \! \emph{No documents are allowed.} \\ 33 | Only \emph{non-programmable} pocket calculators are allowed. 34 | } 35 | \end{flushleft} 36 | \rule{\textwidth}{1.5pt} 37 | \vspace{-5\baselineskip} 38 | } 39 | \author{} 40 | \date{} 41 | 42 | \pdfinfo{ 43 | /Author (Bashar Dudin) 44 | /Title (PROL Exam -- 2018) 45 | /Subject (Linear Programming) 46 | } 47 | 48 | \begin{document} 49 | 50 | \maketitle\thispagestyle{fancy} 51 | 52 | We're considering the following list of linear programs respectively 53 | given the names $(A)$, $(B)$, $(C)$, $(D)$, $(E)$ and $(F)$. 54 | \[ 55 | (A) \; 56 | \left\{ 57 | \begin{linearProg}{ 58 | maximize 59 | }{ 60 | $3x_1 + 2x_2 + 3x_3$ 61 | }{ 62 | \systeme{ 63 | -x_1 - 2x_2 - 3x_3 \leq 5, 64 | 2x_1 + x_2 + x_3 \leq 3, 65 | -x_1 - x_2 + x_3 \leq 1 66 | } 67 | }{ 68 | $x_1$, $x_2$, $x_3 \geq 0.$ 69 | } 70 | \end{linearProg} 71 | \right. 72 | \qquad (B)\; 73 | \left\{ 74 | \begin{linearProg}{ 75 | minimize 76 | }{ 77 | $ x_1 + x_2 - x_3$ 78 | }{ 79 | \systeme{ 80 | -x_1 - 2x_2 + 3x_3 \leq 1, 81 | - x_1 - x_2 + 2x_3 \geq 2 82 | } 83 | }{ 84 | $x_1$, $x_2$, $x_3 \geq 0.$ 85 | } 86 | \end{linearProg} 87 | \right. 88 | \] 89 | \[ 90 | (C) \; 91 | \left\{ 92 | \begin{linearProg}{ 93 | maximize 94 | }{ 95 | $3x_1 + 2x_2 + 3x_3$ 96 | }{ 97 | \systeme{ 98 | -x_1 - 2x_2 - 3x_3 \leq 5, 99 | 2x_1 + x_2 + x_3 \leq 3, 100 | -x_1 - x_2 + x_3 \leq 1 101 | } 102 | }{ 103 | $x_1$, $x_2 \geq 0.$ 104 | } 105 | \end{linearProg} 106 | \right. 107 | \qquad (D) \; 108 | \left\{ 109 | \begin{linearProg}{ 110 | maximize 111 | }{ 112 | $-x_1 - x_2 + x_3$ 113 | }{ 114 | \systeme{ 115 | -x_1 + 2x_2 - 3x_3 + x_4 = 1, 116 | x_1 + x_2 - 2x_3 \leq -2 117 | } 118 | }{ 119 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 120 | } 121 | \end{linearProg} 122 | \right. 123 | \] 124 | \[ 125 | \qquad (E)\; 126 | \left\{ 127 | \begin{linearProg}{ 128 | maximize 129 | }{ 130 | $ -x_1 - x_2 + x_3$ 131 | }{ 132 | \systeme{ 133 | -x_1 - 2x_2 + 3x_3 \leq 1, 134 | - x_1 - x_2 + 2x_3 \geq 2 135 | } 136 | }{ 137 | $x_1$, $x_2$, $x_3 \geq 0.$ 138 | } 139 | \end{linearProg} 140 | \right. 141 | \qquad (F)\; 142 | \left\{ 143 | \begin{linearProg}{ 144 | maximize 145 | }{ 146 | $6x_1 + 4x_2 + 6x_3$ 147 | }{ 148 | \systeme{ 149 | -x_1 - 2x_2 - 3x_3 \leq 5, 150 | 2x_1 + x_2 + x_3 \leq 3, 151 | x_1 + x_2 - x_3 \geq -1 152 | } 153 | }{ 154 | $x_1$, $x_2 \geq 0.$ 155 | } 156 | \end{linearProg} 157 | \right. 158 | \] 159 | 160 | \section{Equivalence and Duality} 161 | 162 | \begin{question}{3} 163 | Which previous programs are equivalent to each others? Sort them 164 | into groups of equivalent classes. 165 | \end{question} 166 | 167 | \begin{question}{2} 168 | Give standard form of $(F)$. What is the slack form of $(B)$? 169 | \end{question} 170 | 171 | \begin{question}{2} 172 | What are the dual programs of $(A)$ and $(E)$? 173 | \end{question} 174 | 175 | \begin{question}{2} 176 | Guess feasible solutions of $(A)$ and $(D)$. 177 | \end{question} 178 | 179 | \section{Simplex Algorithm} 180 | 181 | \begin{question}{4} 182 | Solve linear program $(A)$ using the simplex algorithm. 183 | \end{question} 184 | 185 | \begin{question}{2} 186 | Out of previous solution of $(A)$ give an optimal point of its 187 | dual. What is its optimal objective value? 188 | \end{question} 189 | 190 | \begin{question}{5} 191 | Solve dual of linear program $(E)$. 192 | \end{question} 193 | 194 | \end{document} 195 | 196 | %%% Local Variables: 197 | %%% mode: latex 198 | %%% TeX-master: t 199 | %%% End: 200 | -------------------------------------------------------------------------------- /Exams/TeX/Style/linearProgramsStyle.sty: -------------------------------------------------------------------------------- 1 | %%%% This package contains my shortcuts and predefined maths commands 2 | %%%% TeXing 3 | 4 | \ProvidesPackage{TeXingStyle}[2017/18/05 Styling Content] 5 | 6 | %%% Tex basics 7 | \RequirePackage[utf8]{inputenc} 8 | \RequirePackage[T1]{fontenc} 9 | \RequirePackage{enumerate} 10 | 11 | %%% Title Formatting 12 | \RequirePackage{titling} 13 | 14 | %%% Maths symbols and typographical engines. 15 | \RequirePackage{amsmath, amssymb, amsfonts, amsthm} 16 | 17 | %%% Coloring and box wrappers 18 | \RequirePackage{xcolor} 19 | \RequirePackage{colortbl} 20 | \RequirePackage{tcolorbox} 21 | \RequirePackage{wrapfig} 22 | 23 | %%% Systeme package for equations layouts 24 | \RequirePackage{systeme} 25 | 26 | %%% Formatting pseudo-code 27 | \RequirePackage{alltt} 28 | \RequirePackage{algpseudocode} 29 | \RequirePackage{algorithm} 30 | \renewcommand{\algorithmicrequire}{\textbf{Input:}} 31 | \renewcommand{\algorithmicensure}{\textbf{Output:}} 32 | \newcommand{\algorithmicbreak}{\textbf{break}} 33 | \newcommand{\Break}{\State \algorithmicbreak} 34 | 35 | %%% Code highlighting and formatting 36 | \RequirePackage{minted} 37 | 38 | %%% Needed packages for mathplotting to combine with gnuplot (needs to 39 | %%% shell-escape latex engine) 40 | \RequirePackage{pgfplots} 41 | \usepgfplotslibrary{fillbetween} 42 | \usepgfplotslibrary{colorbrewer} 43 | 44 | %%% Tikz library packages 45 | \RequirePackage{tikz, tkz-tab} 46 | \usetikzlibrary{colorbrewer} 47 | \usetikzlibrary{arrows, decorations.text} 48 | 49 | %%% Creating multicol documents 50 | \RequirePackage{multicol} 51 | 52 | %%% Links 53 | \RequirePackage{hyperref} 54 | 55 | %%% Enabling Frames with mdframed 56 | \RequirePackage{mdframed} 57 | \mdfsetup{skipabove=\topskip,skipbelow=\topskip} 58 | \global\mdfdefinestyle{questiondefault}{% 59 | linewidth=.5pt,% 60 | bottomline=true,% 61 | topline=true,% 62 | leftline=true,% 63 | rightline=true 64 | } 65 | 66 | %%% Miscelaneous 67 | \RequirePackage{centernot} 68 | \RequirePackage{eurosym} 69 | 70 | %%% Setting up ExSheets 71 | \RequirePackage{exsheets} 72 | \newcommand*\pointsformat[1]{\,\, #1} 73 | \SetupExSheets{points/format=\pointsformat} 74 | \SetupExSheets{headings-format=\bfseries} 75 | \SetupExSheets{headings=runin} 76 | \SetupExSheets{solution/print=false} 77 | \SetupExSheets{question/type=exam} 78 | \SetupExSheets{question/skip-below=.5\baselineskip} 79 | \SetupExSheets{counter-format={se-qu[1].}} 80 | \SetupExSheets{question/pre-hook={\begin{mdframed}[style=questiondefault]}} 81 | \SetupExSheets{question/post-hook=\end{mdframed}} 82 | \renewcommand\thequestion{\thesection-\arabic{question}} 83 | 84 | %% Theoremlike environments 85 | \theoremstyle{plain} 86 | \newtheorem{thm}{Théorème}[section] 87 | \newtheorem{lem}[thm]{Lemme} 88 | \newtheorem{prop}[thm]{Proposition} 89 | \newtheorem{cor}[thm]{Corollaire} 90 | 91 | \theoremstyle{definition} 92 | \newtheorem{defn}{Définition}[section] 93 | \newtheorem{exmp}{Exemple}[section] 94 | \newtheorem{hyp}[thm]{Hypothèse} 95 | 96 | \theoremstyle{remark} 97 | \newtheorem{rem}{Remarque} 98 | \newtheorem*{nota}{Notation} 99 | \newtheorem*{affm}{Affirmation} 100 | \newtheorem{convention}{Convention} 101 | 102 | %%% Standard sets 103 | \newcommand{\Q}{\mathbb{Q}} 104 | \newcommand{\N}{\mathbb{N}} 105 | \newcommand{\Z}{\mathbb{Z}} 106 | \newcommand{\R}{\mathbb{R}} 107 | \newcommand{\C}{\mathbb{C}} 108 | 109 | %%% Fonts 110 | \renewcommand{\emph}[1]{\textit{\textbf{#1}}} 111 | \newcommand{\mr}[1]{\mathrm{#1}} 112 | \newcommand{\mc}[1]{\mathcal{#1}} 113 | \newcommand{\mf}[1]{\mathfrak{#1}} 114 | \newcommand{\mbf}[1]{\mathbf{#1}} 115 | \newcommand{\mbb}[1]{\mathbb{#1}} 116 | \newcommand{\ms}[1]{\mathscr{#1}} 117 | \newcommand{\bs}[1]{\boldsymbol{#1}} 118 | \newcommand{\rmb}[1]{\rm{\bf{#1}}} 119 | 120 | %%% Standard operators 121 | \DeclareMathOperator{\dd}{d\!} %% Integration element 122 | \DeclareMathOperator{\Di}{D\!} %% Differential operator 123 | \DeclareMathOperator{\Ker}{Ker} %% Kernel of a linear map 124 | \DeclareMathOperator{\Img}{Im} %% Image of a linear map 125 | \DeclareMathOperator{\bigO}{\mathscr{O}} %% Big O landau notation 126 | 127 | %% Standard notation 128 | \newcommand{\id}{\mathrm{id}} 129 | \newcommand{\abs}[1]{\lvert#1\rvert} 130 | \newcommand{\1}{\mathbf{1}} 131 | \newcommand{\Card}[1]{\mathrm{Card}\left(#1\right)} 132 | \newcommand{\pa}{\partial} 133 | 134 | %%% Linear Program formatting 135 | \newenvironment{linearProg}[4]{ 136 | \def\arraystretch{1.1} 137 | \begin{tabular}{lc} 138 | #1 & #2 \\ 139 | subject to & \\ 140 | & \sysdelim..{#3}\\ 141 | with & #4 142 | }{ 143 | \end{tabular} 144 | } 145 | 146 | %%% General optimisation problem formatting 147 | \newenvironment{PbOptim}[3]{ 148 | \def\arraystretch{1.1} 149 | \begin{tabular}{lc} 150 | #1 & #2 \\ 151 | subject to & \\ 152 | & #3 153 | }{ 154 | \end{tabular} 155 | } 156 | -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_03_fr.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,a4paper]{article} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage[T1]{fontenc} 4 | \usepackage[english, french]{babel} 5 | \usepackage{fancyhdr} 6 | \usepackage[margin=.7in]{geometry} 7 | \usepackage{exsheets} 8 | \usepackage{enumerate} 9 | 10 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 11 | 12 | \pagestyle{fancy} 13 | 14 | \renewcommand{\headrulewidth}{2pt} 15 | \fancyhead[L]{EPITA\_ING1\_2020\_S5\_PROL} 16 | \fancyhead[R]{Mars 2018} 17 | 18 | \fancyfoot[C]{\textbf{\thepage}} 19 | \fancyfoot[L]{} 20 | 21 | \pretitle{\vspace{-.5\baselineskip} \begin{center}} 22 | \title{% 23 | { \huge Programmation linéaire}\\ % 24 | \vspace{.5\baselineskip} 25 | {\Large \textit{Épreuve complémentaire} } 26 | } 27 | \posttitle{ 28 | \end{center} 29 | \begin{flushleft} 30 | \vspace{2\baselineskip} \textit{ 31 | \!\!\emph{Durée de l'épreuve: 1h30.}\\ 32 | \! \emph{Les documents ne sont pas autorisés} \\ 33 | Les caclulatrices non programmables sont autorisées. 34 | } 35 | \end{flushleft} 36 | \rule{\textwidth}{1.5pt} 37 | \vspace{-5\baselineskip} 38 | } 39 | \author{} 40 | \date{} 41 | 42 | \pdfinfo{ 43 | /Author (Bashar Dudin) 44 | /Title (Exam PROL-- 2018) 45 | /Subject (Programmation lineaire) 46 | } 47 | 48 | \begin{document} 49 | 50 | \maketitle\thispagestyle{fancy} 51 | 52 | On considère les programmes linéaires suivants respectivement nommés 53 | $(A)$, $(B)$, $(C)$, $(D)$, $(E)$ et $(F)$. 54 | \[ 55 | (A) \; 56 | \left\{ 57 | \begin{linearProg}{ 58 | maximize 59 | }{ 60 | $3x_1 + 2x_2 + 3x_3$ 61 | }{ 62 | \systeme{ 63 | -x_1 - 2x_2 - 3x_3 \leq 5, 64 | 2x_1 + x_2 + x_3 \leq 3, 65 | -x_1 - x_2 + x_3 \leq 1 66 | } 67 | }{ 68 | $x_1$, $x_2$, $x_3 \geq 0.$ 69 | } 70 | \end{linearProg} 71 | \right. 72 | \qquad (B)\; 73 | \left\{ 74 | \begin{linearProg}{ 75 | minimize 76 | }{ 77 | $ x_1 + x_2 - x_3$ 78 | }{ 79 | \systeme{ 80 | -x_1 - 2x_2 + 3x_3 \leq 1, 81 | - x_1 - x_2 + 2x_3 \geq 2 82 | } 83 | }{ 84 | $x_1$, $x_2$, $x_3 \geq 0.$ 85 | } 86 | \end{linearProg} 87 | \right. 88 | \] 89 | \[ 90 | (C) \; 91 | \left\{ 92 | \begin{linearProg}{ 93 | maximize 94 | }{ 95 | $3x_1 + 2x_2 + 3x_3$ 96 | }{ 97 | \systeme{ 98 | -x_1 - 2x_2 - 3x_3 \leq 5, 99 | 2x_1 + x_2 + x_3 \leq 3, 100 | -x_1 - x_2 + x_3 \leq 1 101 | } 102 | }{ 103 | $x_1$, $x_2 \geq 0.$ 104 | } 105 | \end{linearProg} 106 | \right. 107 | \qquad (D) \; 108 | \left\{ 109 | \begin{linearProg}{ 110 | maximize 111 | }{ 112 | $-x_1 - x_2 + x_3$ 113 | }{ 114 | \systeme{ 115 | -x_1 + 2x_2 - 3x_3 + x_4 = 1, 116 | x_1 + x_2 - 2x_3 \leq -2 117 | } 118 | }{ 119 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 120 | } 121 | \end{linearProg} 122 | \right. 123 | \] 124 | \[ 125 | \qquad (E)\; 126 | \left\{ 127 | \begin{linearProg}{ 128 | maximize 129 | }{ 130 | $ -x_1 - x_2 + x_3$ 131 | }{ 132 | \systeme{ 133 | -x_1 - 2x_2 + 3x_3 \leq 1, 134 | - x_1 - x_2 + 2x_3 \geq 2 135 | } 136 | }{ 137 | $x_1$, $x_2$, $x_3 \geq 0.$ 138 | } 139 | \end{linearProg} 140 | \right. 141 | \qquad (F)\; 142 | \left\{ 143 | \begin{linearProg}{ 144 | maximize 145 | }{ 146 | $6x_1 + 4x_2 + 6x_3$ 147 | }{ 148 | \systeme{ 149 | -x_1 - 2x_2 - 3x_3 \leq 5, 150 | 2x_1 + x_2 + x_3 \leq 3, 151 | x_1 + x_2 - x_3 \geq -1 152 | } 153 | }{ 154 | $x_1$, $x_2 \geq 0.$ 155 | } 156 | \end{linearProg} 157 | \right. 158 | \] 159 | 160 | \section{Équivalence et dualité} 161 | 162 | \begin{question}{3} 163 | Grouper les programmes linéaires précédents suivant leurs classes 164 | d'équivalences ; deux programmes sont dans la même classe s'ils sont 165 | équivalents. 166 | \end{question} 167 | 168 | \begin{question}{2} 169 | Donner les tableaux associés à $(F)$ et $(B)$. 170 | \end{question} 171 | 172 | \begin{question}{2} 173 | Quels sont les programmes duaux de $(A)$ et de $(E)$? 174 | \end{question} 175 | 176 | \begin{question}{2} 177 | Deviner des solutions admissibles de $(A)$ et de $(D)$. 178 | \end{question} 179 | 180 | \section{Algorithme du simplexe} 181 | 182 | \begin{question}{4} 183 | Résoudre le programme linéaire $(A)$ en suivant l'algorithme du 184 | simplex. 185 | \end{question} 186 | 187 | \begin{question}{2} 188 | À partir d'une solution de $(A)$ donner un point optimal de son 189 | dual. Quelle est sa valeur objective? 190 | \end{question} 191 | 192 | \begin{question}{5} 193 | Résoudre le programme duale de $(E)$. 194 | \end{question} 195 | 196 | \end{document} 197 | 198 | %%% Local Variables: 199 | %%% mode: latex 200 | %%% TeX-master: t 201 | %%% End: 202 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/beamerouterthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerouterthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerouterthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerouterthememetropolis}[2016/03/14 Metropolis outer theme] 21 | \RequirePackage{etoolbox} 22 | \RequirePackage{calc} 23 | \RequirePackage{pgfopts} 24 | \pgfkeys{ 25 | /metropolis/outer/numbering/.cd, 26 | .is choice, 27 | none/.code=\setbeamertemplate{frame numbering}[none], 28 | counter/.code=\setbeamertemplate{frame numbering}[counter], 29 | fraction/.code=\setbeamertemplate{frame numbering}[fraction], 30 | } 31 | \pgfkeys{ 32 | /metropolis/outer/progressbar/.cd, 33 | .is choice, 34 | none/.code={% 35 | \setbeamertemplate{headline}[plain] 36 | \setbeamertemplate{frametitle}[plain] 37 | \setbeamertemplate{footline}[plain] 38 | }, 39 | head/.code={\pgfkeys{/metropolis/outer/progressbar=none} 40 | \addtobeamertemplate{headline}{}{% 41 | \usebeamertemplate*{progress bar in head/foot} 42 | } 43 | }, 44 | frametitle/.code={\pgfkeys{/metropolis/outer/progressbar=none} 45 | \addtobeamertemplate{frametitle}{}{% 46 | \usebeamertemplate*{progress bar in head/foot} 47 | } 48 | }, 49 | foot/.code={\pgfkeys{/metropolis/outer/progressbar=none} 50 | \addtobeamertemplate{footline}{}{% 51 | \usebeamertemplate*{progress bar in head/foot}% 52 | } 53 | }, 54 | } 55 | \newcommand{\metropolis@outer@setdefaults}{ 56 | \pgfkeys{/metropolis/outer/.cd, 57 | numbering=counter, 58 | progressbar=none, 59 | } 60 | } 61 | \setbeamertemplate{navigation symbols}{} 62 | \defbeamertemplate{frame footer}{none}{} 63 | \defbeamertemplate{frame footer}{custom}[1]{ #1 } 64 | \defbeamertemplate{frame numbering}{none}{} 65 | \defbeamertemplate{frame numbering}{counter}{\insertframenumber} 66 | \defbeamertemplate{frame numbering}{fraction}{ 67 | \insertframenumber/\inserttotalframenumber 68 | } 69 | \defbeamertemplate{headline}{plain}{} 70 | \defbeamertemplate{footline}{plain}{% 71 | \begin{beamercolorbox}[wd=\textwidth, sep=3ex]{footline}% 72 | \usebeamerfont{page number in head/foot}% 73 | \usebeamertemplate*{frame footer} 74 | \hfill% 75 | \usebeamertemplate*{frame numbering} 76 | \end{beamercolorbox}% 77 | } 78 | \newlength{\metropolis@frametitle@padding} 79 | \setlength{\metropolis@frametitle@padding}{2.2ex} 80 | \newcommand{\metropolis@frametitlestrut@start}{ 81 | \rule{0pt}{\metropolis@frametitle@padding +% 82 | \totalheightof{% 83 | \ifcsdef{metropolis@frametitleformat}{\metropolis@frametitleformat X}{X}% 84 | }% 85 | }% 86 | } 87 | \newcommand{\metropolis@frametitlestrut@end}{ 88 | \rule[-\metropolis@frametitle@padding]{0pt}{\metropolis@frametitle@padding} 89 | } 90 | \defbeamertemplate{frametitle}{plain}{% 91 | \nointerlineskip% 92 | \begin{beamercolorbox}[% 93 | wd=\paperwidth,% 94 | sep=0pt,% 95 | leftskip=\metropolis@frametitle@padding,% 96 | rightskip=\metropolis@frametitle@padding,% 97 | ]{frametitle}% 98 | \metropolis@frametitlestrut@start% 99 | \insertframetitle% 100 | \nolinebreak% 101 | \metropolis@frametitlestrut@end% 102 | \end{beamercolorbox}% 103 | } 104 | \setbeamertemplate{frametitle continuation}{% 105 | \usebeamerfont{frametitle} 106 | \romannumeral \insertcontinuationcount 107 | } 108 | \newlength{\metropolis@progressinheadfoot} 109 | \setbeamertemplate{progress bar in head/foot}{ 110 | \nointerlineskip 111 | \setlength{\metropolis@progressinheadfoot}{% 112 | \paperwidth * \ratio{\insertframenumber pt}{\inserttotalframenumber pt}% 113 | }% 114 | \begin{beamercolorbox}[wd=\paperwidth]{progress bar in head/foot} 115 | \begin{tikzpicture} 116 | \fill[bg] (0,0) rectangle (\paperwidth, 0.4pt); 117 | \fill[fg] (0,0) rectangle (\metropolis@progressinheadfoot, 0.4pt); 118 | \end{tikzpicture}% 119 | \end{beamercolorbox} 120 | } 121 | \AtBeginDocument{% 122 | \apptocmd{\appendix}{% 123 | \pgfkeys{% 124 | /metropolis/outer/.cd, 125 | numbering=none, 126 | progressbar=none} 127 | }{}{} 128 | } 129 | \metropolis@outer@setdefaults 130 | \ProcessPgfPackageOptions{/metropolis/outer} 131 | \endinput 132 | %% 133 | %% End of file `beamerouterthememetropolis.sty'. 134 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/beamerouterthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerouterthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerouterthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerouterthememetropolis}[2016/03/14 Metropolis outer theme] 21 | \RequirePackage{etoolbox} 22 | \RequirePackage{calc} 23 | \RequirePackage{pgfopts} 24 | \pgfkeys{ 25 | /metropolis/outer/numbering/.cd, 26 | .is choice, 27 | none/.code=\setbeamertemplate{frame numbering}[none], 28 | counter/.code=\setbeamertemplate{frame numbering}[counter], 29 | fraction/.code=\setbeamertemplate{frame numbering}[fraction], 30 | } 31 | \pgfkeys{ 32 | /metropolis/outer/progressbar/.cd, 33 | .is choice, 34 | none/.code={% 35 | \setbeamertemplate{headline}[plain] 36 | \setbeamertemplate{frametitle}[plain] 37 | \setbeamertemplate{footline}[plain] 38 | }, 39 | head/.code={\pgfkeys{/metropolis/outer/progressbar=none} 40 | \addtobeamertemplate{headline}{}{% 41 | \usebeamertemplate*{progress bar in head/foot} 42 | } 43 | }, 44 | frametitle/.code={\pgfkeys{/metropolis/outer/progressbar=none} 45 | \addtobeamertemplate{frametitle}{}{% 46 | \usebeamertemplate*{progress bar in head/foot} 47 | } 48 | }, 49 | foot/.code={\pgfkeys{/metropolis/outer/progressbar=none} 50 | \addtobeamertemplate{footline}{}{% 51 | \usebeamertemplate*{progress bar in head/foot}% 52 | } 53 | }, 54 | } 55 | \newcommand{\metropolis@outer@setdefaults}{ 56 | \pgfkeys{/metropolis/outer/.cd, 57 | numbering=counter, 58 | progressbar=none, 59 | } 60 | } 61 | \setbeamertemplate{navigation symbols}{} 62 | \defbeamertemplate{frame footer}{none}{} 63 | \defbeamertemplate{frame footer}{custom}[1]{ #1 } 64 | \defbeamertemplate{frame numbering}{none}{} 65 | \defbeamertemplate{frame numbering}{counter}{\insertframenumber} 66 | \defbeamertemplate{frame numbering}{fraction}{ 67 | \insertframenumber/\inserttotalframenumber 68 | } 69 | \defbeamertemplate{headline}{plain}{} 70 | \defbeamertemplate{footline}{plain}{% 71 | \begin{beamercolorbox}[wd=\textwidth, sep=3ex]{footline}% 72 | \usebeamerfont{page number in head/foot}% 73 | \usebeamertemplate*{frame footer} 74 | \hfill% 75 | \usebeamertemplate*{frame numbering} 76 | \end{beamercolorbox}% 77 | } 78 | \newlength{\metropolis@frametitle@padding} 79 | \setlength{\metropolis@frametitle@padding}{2.2ex} 80 | \newcommand{\metropolis@frametitlestrut@start}{ 81 | \rule{0pt}{\metropolis@frametitle@padding +% 82 | \totalheightof{% 83 | \ifcsdef{metropolis@frametitleformat}{\metropolis@frametitleformat X}{X}% 84 | }% 85 | }% 86 | } 87 | \newcommand{\metropolis@frametitlestrut@end}{ 88 | \rule[-\metropolis@frametitle@padding]{0pt}{\metropolis@frametitle@padding} 89 | } 90 | \defbeamertemplate{frametitle}{plain}{% 91 | \nointerlineskip% 92 | \begin{beamercolorbox}[% 93 | wd=\paperwidth,% 94 | sep=0pt,% 95 | leftskip=\metropolis@frametitle@padding,% 96 | rightskip=\metropolis@frametitle@padding,% 97 | ]{frametitle}% 98 | \metropolis@frametitlestrut@start% 99 | \insertframetitle% 100 | \nolinebreak% 101 | \metropolis@frametitlestrut@end% 102 | \end{beamercolorbox}% 103 | } 104 | \setbeamertemplate{frametitle continuation}{% 105 | \usebeamerfont{frametitle} 106 | \romannumeral \insertcontinuationcount 107 | } 108 | \newlength{\metropolis@progressinheadfoot} 109 | \setbeamertemplate{progress bar in head/foot}{ 110 | \nointerlineskip 111 | \setlength{\metropolis@progressinheadfoot}{% 112 | \paperwidth * \ratio{\insertframenumber pt}{\inserttotalframenumber pt}% 113 | }% 114 | \begin{beamercolorbox}[wd=\paperwidth]{progress bar in head/foot} 115 | \begin{tikzpicture} 116 | \fill[bg] (0,0) rectangle (\paperwidth, 0.4pt); 117 | \fill[fg] (0,0) rectangle (\metropolis@progressinheadfoot, 0.4pt); 118 | \end{tikzpicture}% 119 | \end{beamercolorbox} 120 | } 121 | \AtBeginDocument{% 122 | \apptocmd{\appendix}{% 123 | \pgfkeys{% 124 | /metropolis/outer/.cd, 125 | numbering=none, 126 | progressbar=none} 127 | }{}{} 128 | } 129 | \metropolis@outer@setdefaults 130 | \ProcessPgfPackageOptions{/metropolis/outer} 131 | \endinput 132 | %% 133 | %% End of file `beamerouterthememetropolis.sty'. 134 | -------------------------------------------------------------------------------- /Exams/TeX/Ecrit_PROL_2018_06_APPINGII.tex: -------------------------------------------------------------------------------- 1 | \documentclass[11pt,a4paper]{article} 2 | \usepackage[utf8]{inputenc} 3 | \usepackage[T1]{fontenc} 4 | \usepackage[english, french]{babel} 5 | \usepackage{fancyhdr} 6 | \usepackage[margin=.7in]{geometry} 7 | \usepackage{exsheets} 8 | \usepackage{enumerate} 9 | 10 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 11 | 12 | \pagestyle{fancy} 13 | 14 | \renewcommand{\headrulewidth}{2pt} 15 | \fancyhead[L]{EPITA\_APPING2\_2019\_S8\_PROL} 16 | \fancyhead[R]{Juin 2018} 17 | 18 | \fancyfoot[C]{\textbf{\thepage}} 19 | \fancyfoot[L]{\textbf{Chargé de cours:} \textsc{B. Dudin}} 20 | 21 | \pretitle{\vspace{-.5\baselineskip} \begin{center}} 22 | \title{% 23 | { \huge Programmation linéaire}\\ 24 | } 25 | 26 | \posttitle{ 27 | \end{center} 28 | \begin{flushleft} 29 | \vspace{2\baselineskip} \textit{ 30 | \!\!\emph{Durée de l'épreuve: 2h00.}\\ 31 | \! \emph{Les documents ne sont pas autorisés} \\ 32 | Les caclulatrices non programmables sont autorisées. 33 | } 34 | \end{flushleft} 35 | \rule{\textwidth}{1.5pt} 36 | \vspace{-5\baselineskip} 37 | } 38 | \author{} 39 | \date{} 40 | 41 | \pdfinfo{ 42 | /Author (Bashar Dudin) 43 | /Title (Exam PROL APP -- 2018) 44 | /Subject (Programmation lineaire) 45 | } 46 | 47 | \begin{document} 48 | 49 | \maketitle\thispagestyle{fancy} 50 | 51 | On considère les programmes linéaires suivants respectivement nommés 52 | $(A)$, $(B)$, $(C)$, $(D)$, $(E)$ et $(F)$. 53 | \[ 54 | (A) \; 55 | \left\{ 56 | \begin{linearProg}{ 57 | maximize 58 | }{ 59 | $x_1 - 2x_2 + x_3 + 5$ 60 | }{ 61 | \systeme{ 62 | x_1 - x_2 - 2x_3 \geq 5, 63 | x_1 - x_2 + x_3 \leq 3, 64 | -x_1 + 2x_2 + x_3 \leq 1 65 | } 66 | }{ 67 | $x_1$, $x_2 \geq 0.$ 68 | } 69 | \end{linearProg} 70 | \right. 71 | \qquad (B)\; 72 | \left\{ 73 | \begin{linearProg}{ 74 | maximize 75 | }{ 76 | $ x_1 + x_2 - x_3$ 77 | }{ 78 | \systeme{ 79 | -x_1 - 2x_2 + 3x_3 \leq 1, 80 | - x_1 + x_2 + 2x_3 \geq 2 81 | } 82 | }{ 83 | $x_1$, $x_2$, $x_3 \geq 0.$ 84 | } 85 | \end{linearProg} 86 | \right. 87 | \] 88 | \[ 89 | (C) \; 90 | \left\{ 91 | \begin{linearProg}{ 92 | minimize 93 | }{ 94 | $-x_1 - 2x_2 - 3x_3$ 95 | }{ 96 | \systeme{ 97 | - x_1 - 2x_2 - 3x_3 \leq 5, 98 | - 2x_1 + x_2 + x_3 \geq 3, 99 | - x_1 - x_2 + x_3 \leq 1 100 | } 101 | }{ 102 | $x_1$, $x_2 \geq 0.$ 103 | } 104 | \end{linearProg} 105 | \right. 106 | \qquad (D) \; 107 | \left\{ 108 | \begin{linearProg}{ 109 | maximize 110 | }{ 111 | $x_1 + x_2 - x_3 + x_4 + 5 $ 112 | }{ 113 | \systeme{ 114 | x_1 - x_2 - 2x_3 + 2x_4 \geq 5, 115 | x_1 + x_2 - x_3 + x_4 \leq 3, 116 | -x_1 + 2x_2 + x_3 - x_4 \leq 1 117 | } 118 | }{ 119 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 120 | } 121 | \end{linearProg} 122 | \right. 123 | \] 124 | \[ 125 | \qquad (E)\;\left\{ 126 | \begin{linearProg}{ 127 | minimize 128 | }{ 129 | $ - x_1 - x_2 + x_3$ 130 | }{ 131 | \systeme{ 132 | -x_1 - 2x_2 + 3x_3 = 1 - x_4, 133 | - x_1 + x_2 + 2x_3 \geq 2 134 | } 135 | }{ 136 | $x_1$, $x_2$, $x_3$, $x_4 \geq 0.$ 137 | } 138 | \end{linearProg} 139 | \right. 140 | \qquad (F)\; 141 | \left\{ 142 | \begin{linearProg}{ 143 | maximize 144 | }{ 145 | $x_1 + x_2$ 146 | }{ 147 | \systeme{ 148 | x_1 + 2x_2 \leq 4, 149 | 4x_1 + 2x_2 \leq 12, 150 | -x_1 + x_2 \leq 1 151 | } 152 | }{ 153 | $x_1$, $x_2 \geq 0.$ 154 | } 155 | \end{linearProg} 156 | \right. 157 | \] 158 | 159 | \section{Équivalence et dualité} 160 | 161 | \begin{question}{3} 162 | Grouper les programmes linéaires précédents suivant leurs classes 163 | d'équivalences ; deux programmes sont dans la même classe s'ils sont 164 | équivalents. 165 | \end{question} 166 | 167 | \begin{question}{1} 168 | Deviner des solutions admissibles de $(E)$ et de $(F)$. 169 | \end{question} 170 | 171 | \begin{question}{1} 172 | Donner les tableaux associés à $(D)$ et $(C)$. 173 | \end{question} 174 | 175 | \begin{question}{2+1} 176 | Quels sont les programmes linéaires qui n'ont pas une solution de 177 | base admissible? Justifier le fait que $(B)$ ne soit pas borné. 178 | \end{question} 179 | 180 | \section{Algorithme du simplexe} 181 | 182 | \begin{question}{+2} 183 | Quel est le nombre maximum d'itérations de l'algorithme du simplexe 184 | (nombre d'opérations d'entrée-sortie en base) qu'on peut avoir dans 185 | le cas de $(B)$? 186 | \end{question} 187 | 188 | \begin{question}{7} 189 | Résoudre les programmes linéaires $(C)$ et $(F)$ en suivant 190 | l'algorithme du simplex. 191 | \end{question} 192 | 193 | \begin{question}{6} 194 | Est-ce que le programme linéaire $(D)$ est admissible? Si oui, en 195 | donner une forme équivalente qui a une solution de base admissible. 196 | \end{question} 197 | 198 | \end{document} 199 | 200 | %%% Local Variables: 201 | %%% mode: latex 202 | %%% TeX-master: t 203 | %%% End: 204 | -------------------------------------------------------------------------------- /Python/linprog/simplex.py: -------------------------------------------------------------------------------- 1 | #!/usr/bin/env python 2 | # _*_ encoding: utf-8 _*_ 3 | 4 | """simplex.py: Simplex algorithm with rational coefficients""" 5 | 6 | import numpy as np 7 | import fractions as frac 8 | 9 | __author__ = "Bashar Dudin" 10 | __email__ = "bashar.dudin@epita.fr" 11 | 12 | 13 | class RestrictedSimplex(object): 14 | 15 | def __init__(self, leaving_index=None, entering_index=None): 16 | if not leaving_index: 17 | def func(l): 18 | m = 0 19 | while not l[m] and m < len(l): 20 | m += 1 21 | if m == len(l): 22 | return 0 23 | for i in range(len(l)): 24 | if l[i] and l[m] > l[i]: 25 | m = i 26 | return m 27 | leaving_index = func 28 | 29 | if not entering_index: 30 | def func(l): 31 | return l.index(min(l)) 32 | entering_index = func 33 | 34 | self.leaving_index = leaving_index 35 | self.entering_index = entering_index 36 | 37 | def __call__(self, lin_p, recursion_limit=100): 38 | """ Runs a restricted version of the simplex algorithm 39 | 40 | Runs simplex algorithm on linear programs having feasible basic 41 | solution. It takes in an integer to limit the number of recursions. 42 | 43 | :return: a linear program whose basic solution has maximal objective 44 | value. 45 | """ 46 | a = lin_p.table 47 | 48 | if not lin_p.has_feasible_basic: 49 | raise TypeError("Linear program doesn't have feasible base solution") 50 | 51 | n = 0 52 | while any(a[0, :-1] < 0) and n < recursion_limit: 53 | entering_choices = [i for i in map(lambda x: 0 if x > 0 else x, 54 | a[0, :-1])] 55 | e = self.entering_index(entering_choices) 56 | 57 | leaving_choices = [None]*lin_p.shape[0] 58 | for i in range(lin_p.shape[0]): 59 | if a[i+1, e] > 0: 60 | leaving_choices[i] = (a[i+1, -1]/a[i+1, e]) 61 | if not [i for i in leaving_choices if i]: 62 | raise OverflowError("Linear program unbounded | check model and state.") 63 | else: 64 | l = 1 + self.leaving_index(leaving_choices) 65 | 66 | lin_p.pivot(e, l) 67 | n += 1 68 | 69 | form = "Basic solution = " + \ 70 | "(" + "{}, " * (lin_p.shape[1] - 1) + "{})" + \ 71 | " with objective value = {}." 72 | print(form.format(*lin_p.basic_solution(), lin_p.table[0, -1]), end="\n\n") 73 | 74 | return lin_p.basic_solution(), lin_p.table[0, -1] 75 | 76 | 77 | class Simplex(RestrictedSimplex): 78 | 79 | def is_feasible(self, lin_p): 80 | """ Checks if linear program is feasible.. 81 | 82 | Has side effect: transforms linear program if not basic feasible 83 | into an equivalent linear program having basic feasible solution. 84 | 85 | :return: boolean. 86 | """ 87 | 88 | print(" ### Checking feasibility of linear program", lin_p, sep="\n\n") 89 | 90 | if lin_p.has_feasible_basic(): 91 | print(" ### Input linear program has feasible basic solution", end="\n\n") 92 | return True 93 | 94 | print(" ### Basic solution is not feasible: using auxiliary linear program in next step", end="\n\n") 95 | 96 | gain_fun = np.copy(lin_p.table[0]) 97 | 98 | lin_p.shape = (lin_p.shape[0], lin_p.shape[1] + 1) 99 | lin_p.table = np.insert(lin_p.table, 0, frac.Fraction(-1, 1), axis=1) 100 | lin_p.table[0] = np.hstack((np.ones(1, dtype=frac.Fraction), 101 | np.zeros(lin_p.shape[1], dtype=frac.Fraction))) 102 | lin_p.basic = [i+1 for i in lin_p.basic] 103 | 104 | l = 1 + np.argmin(lin_p.table[1:, -1]) 105 | lin_p.pivot(0, l) # Now program has feasible basic solution 106 | 107 | if RestrictedSimplex.__call__(self, lin_p)[1] == 0: 108 | print(" ### Input linear program is thus feasible", end="\n\n") 109 | 110 | if 0 in lin_p.basic: 111 | l = lin_p.basic.index(0) 112 | 113 | e = 0 114 | while e < lin_p.shape and lin_p.table[l, e] == 0: 115 | # There is a at least an e with this property 116 | # Unbounded otherwise 117 | e += 1 118 | lin_p.pivot(e, l) # 0 not basic anymore 119 | 120 | lin_p.basic = [i-1 for i in lin_p.basic] 121 | lin_p.table = lin_p.table[:, 1:] 122 | lin_p.shape = (lin_p.shape[0], lin_p.shape[1] - 1) 123 | 124 | lin_p.table[0] = gain_fun 125 | for i in lin_p.basic: 126 | lin_p.table[0, :] = lin_p.table[0, :] - \ 127 | lin_p.table[0, i] * \ 128 | lin_p.table[1 + lin_p.basic.index(i), :] 129 | lin_p.table[0, -1] = -lin_p.table[0, -1] 130 | 131 | return True 132 | 133 | else: 134 | return False 135 | 136 | def __call__(self, lin_p, recursion_limit=100): 137 | """ Simplex algorithm. 138 | 139 | :return: a linear program whose basic solution has maximal objective 140 | value. 141 | """ 142 | if self.is_feasible(lin_p): 143 | simplex = RestrictedSimplex(self.leaving_index, 144 | self.entering_index) 145 | 146 | print(" ### Getting back to linear program equivalent to input with feasible basic solution", end="\n\n") 147 | return simplex(lin_p, recursion_limit=recursion_limit) 148 | 149 | else: 150 | raise Exception("Linear program is not feasible.") 151 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | CC0 1.0 Universal 2 | 3 | Statement of Purpose 4 | 5 | The laws of most jurisdictions throughout the world automatically confer 6 | exclusive Copyright and Related Rights (defined below) upon the creator and 7 | subsequent owner(s) (each and all, an "owner") of an original work of 8 | authorship and/or a database (each, a "Work"). 9 | 10 | Certain owners wish to permanently relinquish those rights to a Work for the 11 | purpose of contributing to a commons of creative, cultural and scientific 12 | works ("Commons") that the public can reliably and without fear of later 13 | claims of infringement build upon, modify, incorporate in other works, reuse 14 | and redistribute as freely as possible in any form whatsoever and for any 15 | purposes, including without limitation commercial purposes. These owners may 16 | contribute to the Commons to promote the ideal of a free culture and the 17 | further production of creative, cultural and scientific works, or to gain 18 | reputation or greater distribution for their Work in part through the use and 19 | efforts of others. 20 | 21 | For these and/or other purposes and motivations, and without any expectation 22 | of additional consideration or compensation, the person associating CC0 with a 23 | Work (the "Affirmer"), to the extent that he or she is an owner of Copyright 24 | and Related Rights in the Work, voluntarily elects to apply CC0 to the Work 25 | and publicly distribute the Work under its terms, with knowledge of his or her 26 | Copyright and Related Rights in the Work and the meaning and intended legal 27 | effect of CC0 on those rights. 28 | 29 | 1. Copyright and Related Rights. A Work made available under CC0 may be 30 | protected by copyright and related or neighboring rights ("Copyright and 31 | Related Rights"). Copyright and Related Rights include, but are not limited 32 | to, the following: 33 | 34 | i. the right to reproduce, adapt, distribute, perform, display, communicate, 35 | and translate a Work; 36 | 37 | ii. moral rights retained by the original author(s) and/or performer(s); 38 | 39 | iii. publicity and privacy rights pertaining to a person's image or likeness 40 | depicted in a Work; 41 | 42 | iv. rights protecting against unfair competition in regards to a Work, 43 | subject to the limitations in paragraph 4(a), below; 44 | 45 | v. rights protecting the extraction, dissemination, use and reuse of data in 46 | a Work; 47 | 48 | vi. database rights (such as those arising under Directive 96/9/EC of the 49 | European Parliament and of the Council of 11 March 1996 on the legal 50 | protection of databases, and under any national implementation thereof, 51 | including any amended or successor version of such directive); and 52 | 53 | vii. other similar, equivalent or corresponding rights throughout the world 54 | based on applicable law or treaty, and any national implementations thereof. 55 | 56 | 2. Waiver. To the greatest extent permitted by, but not in contravention of, 57 | applicable law, Affirmer hereby overtly, fully, permanently, irrevocably and 58 | unconditionally waives, abandons, and surrenders all of Affirmer's Copyright 59 | and Related Rights and associated claims and causes of action, whether now 60 | known or unknown (including existing as well as future claims and causes of 61 | action), in the Work (i) in all territories worldwide, (ii) for the maximum 62 | duration provided by applicable law or treaty (including future time 63 | extensions), (iii) in any current or future medium and for any number of 64 | copies, and (iv) for any purpose whatsoever, including without limitation 65 | commercial, advertising or promotional purposes (the "Waiver"). Affirmer makes 66 | the Waiver for the benefit of each member of the public at large and to the 67 | detriment of Affirmer's heirs and successors, fully intending that such Waiver 68 | shall not be subject to revocation, rescission, cancellation, termination, or 69 | any other legal or equitable action to disrupt the quiet enjoyment of the Work 70 | by the public as contemplated by Affirmer's express Statement of Purpose. 71 | 72 | 3. Public License Fallback. Should any part of the Waiver for any reason be 73 | judged legally invalid or ineffective under applicable law, then the Waiver 74 | shall be preserved to the maximum extent permitted taking into account 75 | Affirmer's express Statement of Purpose. In addition, to the extent the Waiver 76 | is so judged Affirmer hereby grants to each affected person a royalty-free, 77 | non transferable, non sublicensable, non exclusive, irrevocable and 78 | unconditional license to exercise Affirmer's Copyright and Related Rights in 79 | the Work (i) in all territories worldwide, (ii) for the maximum duration 80 | provided by applicable law or treaty (including future time extensions), (iii) 81 | in any current or future medium and for any number of copies, and (iv) for any 82 | purpose whatsoever, including without limitation commercial, advertising or 83 | promotional purposes (the "License"). The License shall be deemed effective as 84 | of the date CC0 was applied by Affirmer to the Work. Should any part of the 85 | License for any reason be judged legally invalid or ineffective under 86 | applicable law, such partial invalidity or ineffectiveness shall not 87 | invalidate the remainder of the License, and in such case Affirmer hereby 88 | affirms that he or she will not (i) exercise any of his or her remaining 89 | Copyright and Related Rights in the Work or (ii) assert any associated claims 90 | and causes of action with respect to the Work, in either case contrary to 91 | Affirmer's express Statement of Purpose. 92 | 93 | 4. Limitations and Disclaimers. 94 | 95 | a. No trademark or patent rights held by Affirmer are waived, abandoned, 96 | surrendered, licensed or otherwise affected by this document. 97 | 98 | b. Affirmer offers the Work as-is and makes no representations or warranties 99 | of any kind concerning the Work, express, implied, statutory or otherwise, 100 | including without limitation warranties of title, merchantability, fitness 101 | for a particular purpose, non infringement, or the absence of latent or 102 | other defects, accuracy, or the present or absence of errors, whether or not 103 | discoverable, all to the greatest extent permissible under applicable law. 104 | 105 | c. Affirmer disclaims responsibility for clearing rights of other persons 106 | that may apply to the Work or any use thereof, including without limitation 107 | any person's Copyright and Related Rights in the Work. Further, Affirmer 108 | disclaims responsibility for obtaining any necessary consents, permissions 109 | or other rights required for any use of the Work. 110 | 111 | d. Affirmer understands and acknowledges that Creative Commons is not a 112 | party to this document and has no duty or obligation with respect to this 113 | CC0 or use of the Work. 114 | 115 | For more information, please see 116 | 117 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/linearProgramsBeamer.sty: -------------------------------------------------------------------------------- 1 | %%%% This is a style package for my own math beamer presentations. 2 | %%%% The looks of the standard beamer blocks are redefined, some maths 3 | %%%% environnements are as well. 4 | 5 | \ProvidesPackage{linearProgramsBeamer}[2016/03/25 linearPrograms_Beamer] 6 | 7 | \RequirePackage[T1]{fontenc} 8 | \RequirePackage{graphicx} % Allows including images 9 | \RequirePackage{tikz} % Needed to tweak graphics 10 | \RequirePackage[most]{tcolorbox} % Needed to define the definition and theorem 11 | \RequirePackage{fourier} 12 | 13 | %%%%%%%%%%%%%%% Defining colors %%%%%%%%%%%%%%% 14 | 15 | \definecolor{mDarkBrown}{HTML}{604c38} 16 | \definecolor{mDarkTeal}{HTML}{23373b} 17 | \definecolor{mLightBrown}{HTML}{EB811B} 18 | \definecolor{mLightGreen}{HTML}{14B03D} 19 | 20 | %%%%%%%%%%%%%%% Default theme %%%%%%%%%%%%%%% 21 | 22 | \usetheme{metropolis} 23 | 24 | %%%%%%%%%%%%%%% How does the head and footer look like %%%%%%%%%%%%%%% 25 | 26 | \setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line 27 | \setbeamertemplate{headline}[default] % Style of the headline 28 | \setbeamertemplate{footline}[default] % Style of footline 29 | 30 | %%%%%%%%%%%%%%% Itemiez bullets %%%%%%%%%%%%%%% 31 | 32 | \setbeamertemplate{itemize item}[circle] % For the style of item bullets 33 | 34 | %%%%%%%%%%%%%%% Choosing fonts for document %%%%%%%%%%%%%%% 35 | 36 | \usefonttheme{serif} % For only math in serif add onlymath option in brackets 37 | 38 | %%%%%%%%%%%%%%% Setting color and font for frame titles %%%%%%%%%%%%%%% 39 | 40 | \usefonttheme[onlylarge]{structurebold} 41 | 42 | %%%%%%%%%%%%%%% Redefining tikz functions %%%%%%%%%%%%%%% 43 | 44 | \tikzset{ 45 | every overlay node/.style={ 46 | draw=white,fill=white, anchor=north west, 47 | }, 48 | } 49 | % Usage: 50 | % \tikzoverlay at (-1cm,-5cm) {content}; 51 | % or 52 | % \tikzoverlay[text width=5cm] at (-1cm,-5cm) {content}; 53 | \def\tikzoverlay{% 54 | \tikz[baseline,overlay]\node[every overlay node] 55 | }% 56 | 57 | %%%%%%%%%%%%%%% Redefining shape of blocks %%%%%%%%%%%%%%% 58 | 59 | \renewenvironment{block}[1]{% 60 | \begin{tcolorbox}[ 61 | enhanced, 62 | parbox = false, 63 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 64 | colback=lightgray!20!white, 65 | colframe=mDarkTeal, 66 | colbacktitle=mDarkTeal, 67 | adjusted title = {#1}, 68 | fonttitle=\bfseries, 69 | arc=0mm, 70 | boxed title style={size=small, top=-3pt, bottom=-2pt, colframe=mDarkTeal, arc=0mm} 71 | ] 72 | }{% 73 | \end{tcolorbox}% 74 | } 75 | 76 | \newenvironment{shyblock}[1]{% 77 | \begin{tcolorbox}[ 78 | enhanced, 79 | parbox = false, 80 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 81 | colback=white, 82 | colframe=mDarkTeal, 83 | colbacktitle=white, 84 | coltitle=mDarkTeal, 85 | adjusted title = {#1}, 86 | fonttitle=\bfseries, 87 | arc=0mm, 88 | boxed title style={size=small, top = -3pt, bottom=-2pt, colframe=white, arc=0mm} 89 | ] 90 | }{% 91 | \end{tcolorbox}% 92 | } 93 | 94 | \newenvironment{halfshyblock}[1]{% 95 | \begin{tcolorbox}[ 96 | enhanced, 97 | parbox = false, 98 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 99 | colback=white, 100 | colframe=mDarkTeal, 101 | colbacktitle=white, 102 | coltitle=mLightBrown, 103 | adjusted title = {#1}, 104 | fonttitle=\bfseries, 105 | arc=0mm, 106 | boxed title style={size=small, top = -3pt, bottom=-2pt, colframe=white, arc=0mm} 107 | ] 108 | }{% 109 | \end{tcolorbox}% 110 | } 111 | 112 | \renewenvironment{exampleblock}[1]{% 113 | \begin{tcolorbox}[ 114 | enhanced, 115 | parbox = false, 116 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 117 | colback=mDarkBrown!10!white, 118 | colframe=mDarkBrown, 119 | colbacktitle=mDarkBrown, 120 | adjusted title = {#1}, 121 | fonttitle=\bfseries, 122 | arc=0mm, 123 | boxed title style={size=small, top =-3pt, bottom=-2pt, colframe=mDarkBrown, arc=0mm} 124 | ] 125 | }{% 126 | \end{tcolorbox}% 127 | } 128 | 129 | \renewenvironment{alertblock}[1]{% 130 | \begin{tcolorbox}[ 131 | enhanced, 132 | parbox = false, 133 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 134 | colback=mLightBrown!10!white, 135 | colframe=mLightBrown, 136 | colbacktitle=mLightBrown, 137 | adjusted title = {#1}, 138 | fonttitle=\bfseries, 139 | arc=0mm, 140 | boxed title style={size=small, top=-3pt, bottom = -2pt, colframe=mLightBrown, arc=0mm} 141 | ] 142 | }{% 143 | \end{tcolorbox}% 144 | } 145 | 146 | %%%%%%%%%%%%%%% (Re-)Defining theorem-like environnements %%%%%%%%%%%%%%% 147 | 148 | \newenvironment{thm}[1][\unskip]{ % Theoreme 149 | \vspace{1em} 150 | \begin{alertblock}{Theorem #1} 151 | }{\end{alertblock}} 152 | 153 | \newenvironment{prop}[1][\unskip]{ % Proposition 154 | \vspace{1em} 155 | \begin{block}{Proposition #1} 156 | }{\end{block}} 157 | 158 | \newenvironment{lem}[1][\unskip]{ % Lemme 159 | \vspace{1em} 160 | \begin{shyblock}{Lemma #1} 161 | }{\end{shyblock}} 162 | 163 | \newenvironment{defn}[1][\unskip]{ % Definition 164 | \vspace{1em} 165 | \begin{exampleblock}{Definition #1} 166 | }{\end{exampleblock}} 167 | 168 | \newenvironment{rem}[1][\unskip]{ % Remarque 169 | \vspace{.2\baselineskip} 170 | \textbf{Remark #1 :} 171 | }{\par\vspace{5pt}} 172 | 173 | \newenvironment{exemple}[1][\unskip]{ % Exemple 174 | \vspace{.2\baselineskip} 175 | \textbf{Example #1 :} 176 | }{\par} 177 | 178 | \newenvironment{demo}[1][\unskip]{ % Proof 179 | \textbf{Proof #1 :} 180 | }{\hfill $\blacksquare$ \par} 181 | 182 | \newenvironment{nota}[1][\unskip]{ % Notation 183 | \vspace{.2\baselineskip} 184 | \textbf{Notation #1 :} 185 | }{\par} 186 | 187 | 188 | \newenvironment{cor}[1][\unskip]{ % Corollaire 189 | \begin{shyblock}{Corollary #1} 190 | }{\end{shyblock}} 191 | 192 | \newenvironment{question}[1][\unskip]{ 193 | \begin{halfshyblock}{Question #1} 194 | }{\end{halfshyblock}} 195 | 196 | %%%%%%%%%%%%%%% Empasizing text %%%%%%%%%%%%%%% 197 | 198 | \newcommand\mybox[3][mLightBrown]{\textcolor{#1}{\rule{#2}{#3}}} 199 | 200 | \newenvironment{paremph}[1][black]{% 201 | \begin{tcolorbox}[ 202 | parbox = false, 203 | blanker, 204 | borderline west={1.2mm}{0pt}{#1} 205 | ] 206 | }{\end{tcolorbox}} 207 | 208 | %%%%%%%%%%%%%%% No indentation enumerate and itemize environments %%%%%%%%%%%%%%% 209 | 210 | \newenvironment{leftenumerate} 211 | { 212 | \setlength{\leftmargini}{0em} 213 | \begin{enumerate} 214 | } 215 | { 216 | \setlength{\leftmargini}{2em} 217 | \end{enumerate} 218 | } 219 | 220 | \newenvironment{leftitemize} 221 | { 222 | \setlength{\leftmargini}{0em} 223 | \begin{itemize} 224 | } 225 | { 226 | \setlength{\leftmargini}{2em} 227 | \end{itemize} 228 | } 229 | 230 | %%%%%%%%%%%%%%% Each section creates a frame with the section title %%%%%%%%%%%%%%% 231 | 232 | \AtBeginSection[]{ 233 | \begin{frame} 234 | \vfill 235 | \centering 236 | \usebeamerfont{title} 237 | \usebeamercolor[fg]{title} 238 | \insertsectionhead\par% 239 | \vfill 240 | \end{frame} 241 | } 242 | 243 | %%%%%%%%%%%%%%%%%%%%%%%%%%% 244 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/linearProgramsBeamer.sty: -------------------------------------------------------------------------------- 1 | %%%% This is a style package for my own math beamer presentations. 2 | %%%% The looks of the standard beamer blocks are redefined, some maths 3 | %%%% environnements are as well. 4 | 5 | \ProvidesPackage{linearProgramsBeamer}[2016/03/25 linearPrograms_Beamer] 6 | 7 | \RequirePackage[T1]{fontenc} 8 | \RequirePackage{graphicx} % Allows including images 9 | \RequirePackage{tikz} % Needed to tweak graphics 10 | \RequirePackage[most]{tcolorbox} % Needed to define the definition and theorem 11 | \RequirePackage{fourier} 12 | 13 | %%%%%%%%%%%%%%% Defining colors %%%%%%%%%%%%%%% 14 | 15 | \definecolor{mDarkBrown}{HTML}{604c38} 16 | \definecolor{mDarkTeal}{HTML}{23373b} 17 | \definecolor{mLightBrown}{HTML}{EB811B} 18 | \definecolor{mLightGreen}{HTML}{14B03D} 19 | 20 | %%%%%%%%%%%%%%% Default theme %%%%%%%%%%%%%%% 21 | 22 | \usetheme{metropolis} 23 | 24 | %%%%%%%%%%%%%%% How does the head and footer look like %%%%%%%%%%%%%%% 25 | 26 | \setbeamertemplate{navigation symbols}{} % To remove the navigation symbols from the bottom of all slides uncomment this line 27 | \setbeamertemplate{headline}[default] % Style of the headline 28 | \setbeamertemplate{footline}[default] % Style of footline 29 | 30 | %%%%%%%%%%%%%%% Itemiez bullets %%%%%%%%%%%%%%% 31 | 32 | \setbeamertemplate{itemize item}[circle] % For the style of item bullets 33 | 34 | %%%%%%%%%%%%%%% Choosing fonts for document %%%%%%%%%%%%%%% 35 | 36 | \usefonttheme{serif} % For only math in serif add onlymath option in brackets 37 | 38 | %%%%%%%%%%%%%%% Setting color and font for frame titles %%%%%%%%%%%%%%% 39 | 40 | \usefonttheme[onlylarge]{structurebold} 41 | 42 | %%%%%%%%%%%%%%% Redefining tikz functions %%%%%%%%%%%%%%% 43 | 44 | \tikzset{ 45 | every overlay node/.style={ 46 | draw=white,fill=white, anchor=north west, 47 | }, 48 | } 49 | % Usage: 50 | % \tikzoverlay at (-1cm,-5cm) {content}; 51 | % or 52 | % \tikzoverlay[text width=5cm] at (-1cm,-5cm) {content}; 53 | \def\tikzoverlay{% 54 | \tikz[baseline,overlay]\node[every overlay node] 55 | }% 56 | 57 | %%%%%%%%%%%%%%% Redefining shape of blocks %%%%%%%%%%%%%%% 58 | 59 | \renewenvironment{block}[1]{% 60 | \begin{tcolorbox}[ 61 | enhanced, 62 | parbox = false, 63 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 64 | colback=lightgray!20!white, 65 | colframe=mDarkTeal, 66 | colbacktitle=mDarkTeal, 67 | adjusted title = {#1}, 68 | fonttitle=\bfseries, 69 | arc=0mm, 70 | boxed title style={size=small, top=-3pt, bottom=-2pt, colframe=mDarkTeal, arc=0mm} 71 | ] 72 | }{% 73 | \end{tcolorbox}% 74 | } 75 | 76 | \newenvironment{shyblock}[1]{% 77 | \begin{tcolorbox}[ 78 | enhanced, 79 | parbox = false, 80 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 81 | colback=white, 82 | colframe=mDarkTeal, 83 | colbacktitle=white, 84 | coltitle=mDarkTeal, 85 | adjusted title = {#1}, 86 | fonttitle=\bfseries, 87 | arc=0mm, 88 | boxed title style={size=small, top = -3pt, bottom=-2pt, colframe=white, arc=0mm} 89 | ] 90 | }{% 91 | \end{tcolorbox}% 92 | } 93 | 94 | \newenvironment{halfshyblock}[1]{% 95 | \begin{tcolorbox}[ 96 | enhanced, 97 | parbox = false, 98 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 99 | colback=white, 100 | colframe=mDarkTeal, 101 | colbacktitle=white, 102 | coltitle=mLightBrown, 103 | adjusted title = {#1}, 104 | fonttitle=\bfseries, 105 | arc=0mm, 106 | boxed title style={size=small, top = -3pt, bottom=-2pt, colframe=white, arc=0mm} 107 | ] 108 | }{% 109 | \end{tcolorbox}% 110 | } 111 | 112 | \renewenvironment{exampleblock}[1]{% 113 | \begin{tcolorbox}[ 114 | enhanced, 115 | parbox = false, 116 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 117 | colback=mDarkBrown!10!white, 118 | colframe=mDarkBrown, 119 | colbacktitle=mDarkBrown, 120 | adjusted title = {#1}, 121 | fonttitle=\bfseries, 122 | arc=0mm, 123 | boxed title style={size=small, top =-3pt, bottom=-2pt, colframe=mDarkBrown, arc=0mm} 124 | ] 125 | }{% 126 | \end{tcolorbox}% 127 | } 128 | 129 | \renewenvironment{alertblock}[1]{% 130 | \begin{tcolorbox}[ 131 | enhanced, 132 | parbox = false, 133 | attach boxed title to top left={xshift=3mm,yshift=-2.5mm,yshifttext=-1mm}, 134 | colback=mLightBrown!10!white, 135 | colframe=mLightBrown, 136 | colbacktitle=mLightBrown, 137 | adjusted title = {#1}, 138 | fonttitle=\bfseries, 139 | arc=0mm, 140 | boxed title style={size=small, top=-3pt, bottom = -2pt, colframe=mLightBrown, arc=0mm} 141 | ] 142 | }{% 143 | \end{tcolorbox}% 144 | } 145 | 146 | %%%%%%%%%%%%%%% (Re-)Defining theorem-like environnements %%%%%%%%%%%%%%% 147 | 148 | \newenvironment{thm}[1][\unskip]{ % Theoreme 149 | \vspace{1em} 150 | \begin{alertblock}{Th\'eor\`eme #1} 151 | }{\end{alertblock}} 152 | 153 | \newenvironment{prop}[1][\unskip]{ % Proposition 154 | \vspace{1em} 155 | \begin{block}{Proposition #1} 156 | }{\end{block}} 157 | 158 | \newenvironment{lem}[1][\unskip]{ % Lemme 159 | \vspace{1em} 160 | \begin{shyblock}{Lemme #1} 161 | }{\end{shyblock}} 162 | 163 | \newenvironment{defn}[1][\unskip]{ % Definition 164 | \vspace{1em} 165 | \begin{exampleblock}{D\'efinition #1} 166 | }{\end{exampleblock}} 167 | 168 | \newenvironment{rem}[1][\unskip]{ % Remarque 169 | \vspace{.2\baselineskip} 170 | \textbf{Remarque #1 :} 171 | }{\par\vspace{5pt}} 172 | 173 | \newenvironment{exemple}[1][\unskip]{ % Exemple 174 | \vspace{.2\baselineskip} 175 | \textbf{Exemple #1 :} 176 | }{\par} 177 | 178 | \newenvironment{demo}[1][\unskip]{ % Proof 179 | \textbf{Preuve #1 :} 180 | }{\hfill $\blacksquare$ \par} 181 | 182 | \newenvironment{nota}[1][\unskip]{ % Notation 183 | \vspace{.2\baselineskip} 184 | \textbf{Notation #1 :} 185 | }{\par} 186 | 187 | 188 | \newenvironment{cor}[1][\unskip]{ % Corollaire 189 | \begin{shyblock}{Corollaire #1} 190 | }{\end{shyblock}} 191 | 192 | \newenvironment{question}[1][\unskip]{ 193 | \begin{halfshyblock}{Question #1} 194 | }{\end{halfshyblock}} 195 | 196 | %%%%%%%%%%%%%%% Empasizing text %%%%%%%%%%%%%%% 197 | 198 | \newcommand\mybox[3][mLightBrown]{\textcolor{#1}{\rule{#2}{#3}}} 199 | 200 | \newenvironment{paremph}[1][black]{% 201 | \begin{tcolorbox}[ 202 | parbox = false, 203 | blanker, 204 | borderline west={1.2mm}{0pt}{#1} 205 | ] 206 | }{\end{tcolorbox}} 207 | 208 | %%%%%%%%%%%%%%% No indentation enumerate and itemize environments %%%%%%%%%%%%%%% 209 | 210 | \newenvironment{leftenumerate} 211 | { 212 | \setlength{\leftmargini}{0em} 213 | \begin{enumerate} 214 | } 215 | { 216 | \setlength{\leftmargini}{2em} 217 | \end{enumerate} 218 | } 219 | 220 | \newenvironment{leftitemize} 221 | { 222 | \setlength{\leftmargini}{0em} 223 | \begin{itemize} 224 | } 225 | { 226 | \setlength{\leftmargini}{2em} 227 | \end{itemize} 228 | } 229 | 230 | %%%%%%%%%%%%%%% Each section creates a frame with the section title %%%%%%%%%%%%%%% 231 | 232 | \AtBeginSection[]{ 233 | \begin{frame} 234 | \vfill 235 | \centering 236 | \usebeamerfont{title} 237 | \usebeamercolor[fg]{title} 238 | \insertsectionhead\par% 239 | \vfill 240 | \end{frame} 241 | } 242 | 243 | %%%%%%%%%%%%%%%%%%%%%%%%%%% 244 | -------------------------------------------------------------------------------- /Slides/English/Tex/e_simplexAlgorithmValidity.tex: -------------------------------------------------------------------------------- 1 | \documentclass[32pt, aspectratio = 169]{beamer} 2 | 3 | \usepackage[utf8]{inputenc} % Character encoding. 4 | 5 | \pdfinfo{ 6 | /Author (Bashar Dudin) 7 | /Title (Validity of the Simplex Algorithm) 8 | /Subject (Linear Programs) 9 | } 10 | 11 | 12 | \usepackage{./Style/linearProgramsBeamer} % This is extra styling for Beamer environments. 13 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 14 | 15 | %------------------------------------------------------------------------------- 16 | % TITLE PAGE 17 | %------------------------------------------------------------------------------- 18 | 19 | \author[BD]{Bashar Dudin} 20 | 21 | \institute[]{EPITA} 22 | 23 | \title{Linear Programs} % 24 | \subtitle{Validity of the Simplex Algorithm} 25 | 26 | %------------------------------------------------------------------------------- 27 | % DOCUMENT BODY 28 | %------------------------------------------------------------------------------- 29 | 30 | \begin{document} 31 | 32 | \begin{frame}[plain] 33 | \titlepage % Print the title page as the first slide 34 | \end{frame} 35 | 36 | \begin{frame}{Where We Stand? What Is Left?} 37 | Given a linear program we are now able to check whether it is 38 | feasible or not. Under such an assumption we can find an equivalent 39 | linear program who has basic feasible solution. When that is the 40 | case we can execute the \textit{restricted} simplex algorithm. We 41 | find ourselves in front of the upcoming two outputs 42 | \begin{itemize} 43 | \item the program is unbounded 44 | \item the algorithm terminates with a finite output. 45 | \end{itemize} 46 | Up so far we haven't proved that this procedure gives back an 47 | optimal solution. We only know it is feasible. Showing optimality 48 | is the subject of this set of slides. 49 | \end{frame} 50 | 51 | \begin{frame}{The Dual Linear Program} 52 | \begin{columns}[T] 53 | \begin{column}{.5\textwidth} 54 | ~\vspace{.15\baselineskip} 55 | 56 | Let $L$ be the linear program (called \emph{primal}), 57 | given in standard form by : 58 | \begin{figure} 59 | \begin{linearProgG}{ 60 | ${\displaystyle z = \sum_{j = 1 }^n c_jx_j}$ 61 | }{ 62 | ${\displaystyle \forall i \in \{1, \ldots, m\} , \quad \sum_{j = 1}^n a_{ij}x_j \leq b_i}$ 63 | }{ 64 | $\forall j \in \{1, \ldots, n\}, \quad x_j \geq 0$ 65 | } 66 | \end{linearProgG} 67 | \end{figure} 68 | \end{column} 69 | \begin{column}{.55\textwidth} 70 | \begin{tcolorbox}[ 71 | enhanced, 72 | parbox = false, 73 | colback = mLightBrown!30!white, 74 | colframe = mLightBrown!30!white, 75 | arc = 0mm, 76 | ] 77 | Out of $L$ we build the following linear program 78 | $L^\vee$ called the \emph{dual} of $L$ : 79 | \begin{figure} 80 | \begin{linearProg}{ 81 | minimize 82 | }{ 83 | ${\displaystyle z = \sum_{i=1}^m b_iy_i }$ 84 | }{ 85 | ${\displaystyle \forall j \in \{1, \ldots, n\}, \quad \sum_{i =1 }^m a_{ij}y_i \geq c_j}$ 86 | }{ 87 | $\forall i \in \{1, \ldots, m\}, \quad y_i \geq 0$ 88 | } 89 | \end{linearProg} 90 | \end{figure} 91 | \end{tcolorbox} 92 | \end{column} 93 | \end{columns} 94 | \end{frame} 95 | 96 | \begin{frame}{Duality} 97 | The main result justifying, for us, the existence and denomination of the dual linear program is the following. 98 | \begin{alertblock}{Duality} 99 | A linear program $L$ and its dual $L^\vee$ have same optimal objective values if bounded. 100 | \end{alertblock} 101 | We have, in fact, a much more precise statement : 102 | \begin{prop} 103 | If $L$ is in a slack form having optimal basic solution then 104 | setting $y_i = -c_{n+i}$ gives an optimal solution of $L^\vee$. 105 | \end{prop} 106 | \end{frame} 107 | 108 | \begin{frame}{Duality} 109 | We'll only be checking duality and giving a glimpse of the 110 | perception to have. 111 | 112 | Assume we are given a feasible solution 113 | $(\bar{x}_1, \ldots, \bar{x}_n)$ of $L$ and another one 114 | $(\bar{y}_1, \ldots, \bar{y}_m)$ of $L^\vee$. Using constraints of 115 | both linear programs we have that 116 | \begin{align} 117 | \sum_{i=1}^m b_i\bar{y}_i & \geq \sum_{i=1}^m \sum_{j=1}^n a_{ij}\bar{x}_j\bar{y}_i \\ 118 | & \geq \sum_{j=1}^n \sum_{i=1}^m a_{ij}\bar{y}_i\bar{x}_j \geq \sum_{j=1}^n c_j\bar{x}_j 119 | \end{align} 120 | \begin{tcolorbox}[ 121 | enhanced, 122 | parbox = false, 123 | colback = mLightBrown!30!white, 124 | colframe = mLightBrown!30!white, 125 | arc = 0mm, 126 | ] 127 | The optimal objective value of $L$, if any, is bounded from 128 | above by the objective value of any feasible solution of 129 | $L^\vee$. Conversely, the optimal objective value of $L^\vee$ 130 | is bounded from below by the objective value of any feasible 131 | solution of $L$. 132 | \end{tcolorbox} 133 | \end{frame} 134 | 135 | \begin{frame}{Duality} 136 | The previous reasoning stands for the following result 137 | \begin{lem} 138 | If $L$ and $L^\vee$ have respective feasible solutions 139 | $(\bar{x}_1, \ldots, \bar{x}_n)$ and 140 | $(\bar{y}_1, \ldots, \bar{y}_n)$ such that 141 | \[ 142 | \sum_{i=1}^m b_i\bar{y}_i = \sum_{j=1}^nc_j\bar{x}_j 143 | \] 144 | then both are \emph{optimal} feasible solutions of their respective linear programs. 145 | \end{lem} 146 | \begin{demo} 147 | We've just seen that the optimal objective value of $L$ is 148 | smaller or equal to the one of $L^\vee$. The previous hypothesis 149 | just says it also has to be bigger or equal to the one of 150 | $L^\vee$, thus equality. 151 | \end{demo} 152 | \end{frame} 153 | 154 | \begin{frame}{Duality} 155 | To prove the duality theorem as well as the subsequent proposition 156 | the strategy is the following : 157 | \begin{itemize} 158 | \item 159 | run \textsc{Simplex} on $L$ 160 | \item 161 | if result is a solution having finite\footnote{If it is 162 | unfeasible or unbounded above lemma ensures this is also 163 | the case of $L^\vee$.} objective value, check that 164 | instruction of proposition gives a feasible solution of 165 | $L^\vee$ having same objective value 166 | \item 167 | lemma implies both objective values are optimal. 168 | \end{itemize} 169 | This reasoning shows that if we have an optimal feasible solution 170 | for $L$ then we have one of same objective value for $L^\vee$. To 171 | check the converse try making sense of 172 | \begin{halfshyblock}{Bi-duality} 173 | The dual of the dual linear program is the primal one. 174 | \end{halfshyblock} 175 | \end{frame} 176 | 177 | \begin{frame}{Fundamental Theorem of Linear Programming} 178 | Incidently, the previous strategy shows that \textsc{Simplex} finds 179 | solutions of both $L$ and $L^\vee$ that have same objective 180 | values. Thus \textsc{Simplex} does compute an optimal solution of 181 | $L$. 182 | \begin{thm} 183 | \textsc{Simplex} does either check whether a linear program $L$ 184 | is feasible, unbounded or gives back an optimal feasible 185 | solution of $L$ having finite objective value. 186 | \end{thm} 187 | This gives the following core result on linear programs : 188 | \begin{cor}[\textit{(Fundamental Theorem of Linear Programming)}] 189 | Any linear program $L$ is either infeasible, unbounded or has 190 | finite optimal objective value 191 | \end{cor} 192 | \end{frame} 193 | 194 | 195 | \begin{frame} 196 | \centering 197 | {\huge \textbf{Merry Christmas!}} 198 | \end{frame} 199 | 200 | \end{document} 201 | 202 | %%% Local Variables: 203 | %%% mode: latex 204 | %%% TeX-master: t 205 | %%% End: 206 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/e_simplexAlgorithmValidity.tex: -------------------------------------------------------------------------------- 1 | \documentclass[32pt, aspectratio = 169]{beamer} 2 | 3 | \usepackage[utf8]{inputenc} % Character encoding. 4 | 5 | \pdfinfo{ 6 | /Author (Bashar Dudin) 7 | /Title (Validity of the Simplex Algorithm) 8 | /Subject (Linear Programs) 9 | } 10 | 11 | 12 | \usepackage{./Style/linearProgramsBeamer} % This is extra styling for Beamer environments. 13 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 14 | 15 | %------------------------------------------------------------------------------- 16 | % TITLE PAGE 17 | %------------------------------------------------------------------------------- 18 | 19 | \author[BD]{Bashar Dudin} 20 | 21 | \institute[]{EPITA} 22 | 23 | \title{Linear Programs} % 24 | \subtitle{Validity of the Simplex Algorithm} 25 | 26 | %------------------------------------------------------------------------------- 27 | % DOCUMENT BODY 28 | %------------------------------------------------------------------------------- 29 | 30 | \begin{document} 31 | 32 | \begin{frame}[plain] 33 | \titlepage % Print the title page as the first slide 34 | \end{frame} 35 | 36 | \begin{frame}{Where We Stand? What Is Left?} 37 | Given a linear program we are now able to check whether it is 38 | feasible or not. Under such an assumption we can find an equivalent 39 | linear program who has basic feasible solution. When that is the 40 | case we can execute the \textit{restricted} simplex algorithm. We 41 | find ourselves in front of the upcoming two outputs 42 | \begin{itemize} 43 | \item the program is unbounded 44 | \item the algorithm terminates with a finite output. 45 | \end{itemize} 46 | Up so far we haven't proved that this procedure gives back an 47 | optimal solution. We only know it is feasible. Showing optimality 48 | is the subject of this set of slides. 49 | \end{frame} 50 | 51 | \begin{frame}{The Dual Linear Program} 52 | \begin{columns}[T] 53 | \begin{column}{.5\textwidth} 54 | ~\vspace{.15\baselineskip} 55 | 56 | Let $L$ be the linear program (called \emph{primal}), 57 | given in standard form by : 58 | \begin{figure} 59 | \begin{linearProgG}{ 60 | ${\displaystyle z = \sum_{j = 1 }^n c_jx_j}$ 61 | }{ 62 | ${\displaystyle \forall i \in \{1, \ldots, m\} , \quad \sum_{j = 1}^n a_{ij}x_j \leq b_i}$ 63 | }{ 64 | $\forall j \in \{1, \ldots, n\}, \quad x_j \geq 0$ 65 | } 66 | \end{linearProgG} 67 | \end{figure} 68 | \end{column} 69 | \begin{column}{.55\textwidth} 70 | \begin{tcolorbox}[ 71 | enhanced, 72 | parbox = false, 73 | colback = mLightBrown!30!white, 74 | colframe = mLightBrown!30!white, 75 | arc = 0mm, 76 | ] 77 | Out of $L$ we build the following linear program 78 | $L^\vee$ called the \emph{dual} of $L$ : 79 | \begin{figure} 80 | \begin{linearProg}{ 81 | minimize 82 | }{ 83 | ${\displaystyle z = \sum_{i=1}^m b_iy_i }$ 84 | }{ 85 | ${\displaystyle \forall j \in \{1, \ldots, n\}, \quad \sum_{i =1 }^m a_{ij}y_i \geq c_j}$ 86 | }{ 87 | $\forall i \in \{1, \ldots, m\}, \quad y_i \geq 0$ 88 | } 89 | \end{linearProg} 90 | \end{figure} 91 | \end{tcolorbox} 92 | \end{column} 93 | \end{columns} 94 | \end{frame} 95 | 96 | \begin{frame}{Duality} 97 | The main result justifying, for us, the existence and denomination of the dual linear program is the following. 98 | \begin{alertblock}{Duality} 99 | A linear program $L$ and its dual $L^\vee$ have same optimal objective values if bounded. 100 | \end{alertblock} 101 | We have, in fact, a much more precise statement : 102 | \begin{prop} 103 | If $L$ is in a slack form having optimal basic solution then 104 | setting $y_i = -c_{n+i}$ gives an optimal solution of $L^\vee$. 105 | \end{prop} 106 | \end{frame} 107 | 108 | \begin{frame}{Duality} 109 | We'll only be checking duality and giving a glimpse of the 110 | perception to have. 111 | 112 | Assume we are given a feasible solution 113 | $(\bar{x}_1, \ldots, \bar{x}_n)$ of $L$ and another one 114 | $(\bar{y}_1, \ldots, \bar{y}_m)$ of $L^\vee$. Using constraints of 115 | both linear programs we have that 116 | \begin{align} 117 | \sum_{i=1}^m b_i\bar{y}_i & \geq \sum_{i=1}^m \sum_{j=1}^n a_{ij}\bar{x}_j\bar{y}_i \\ 118 | & \geq \sum_{j=1}^n \sum_{i=1}^m a_{ij}\bar{y}_i\bar{x}_j \geq \sum_{j=1}^n c_j\bar{x}_j 119 | \end{align} 120 | \begin{tcolorbox}[ 121 | enhanced, 122 | parbox = false, 123 | colback = mLightBrown!30!white, 124 | colframe = mLightBrown!30!white, 125 | arc = 0mm, 126 | ] 127 | The optimal objective value of $L$, if any, is bounded from 128 | above by the objective value of any feasible solution of 129 | $L^\vee$. Conversely, the optimal objective value of $L^\vee$ 130 | is bounded from below by the objective value of any feasible 131 | solution of $L$. 132 | \end{tcolorbox} 133 | \end{frame} 134 | 135 | \begin{frame}{Duality} 136 | The previous reasoning stands for the following result 137 | \begin{lem} 138 | If $L$ and $L^\vee$ have respective feasible solutions 139 | $(\bar{x}_1, \ldots, \bar{x}_n)$ and 140 | $(\bar{y}_1, \ldots, \bar{y}_n)$ such that 141 | \[ 142 | \sum_{i=1}^m b_i\bar{y}_i = \sum_{j=1}^nc_j\bar{x}_j 143 | \] 144 | then both are \emph{optimal} feasible solutions of their respective linear programs. 145 | \end{lem} 146 | \begin{demo} 147 | We've just seen that the optimal objective value of $L$ is 148 | smaller or equal to the one of $L^\vee$. The previous hypothesis 149 | just says it also has to be bigger or equal to the one of 150 | $L^\vee$, thus equality. 151 | \end{demo} 152 | \end{frame} 153 | 154 | \begin{frame}{Duality} 155 | To prove the duality theorem as well as the subsequent proposition 156 | the strategy is the following : 157 | \begin{itemize} 158 | \item 159 | run \textsc{Simplex} on $L$ 160 | \item 161 | if result is a solution having finite\footnote{If it is 162 | unfeasible or unbounded above lemma ensures this is also 163 | the case of $L^\vee$.} objective value, check that 164 | instruction of proposition gives a feasible solution of 165 | $L^\vee$ having same objective value 166 | \item 167 | lemma implies both objective values are optimal. 168 | \end{itemize} 169 | This reasoning shows that if we have an optimal feasible solution 170 | for $L$ then we have one of same objective value for $L^\vee$. To 171 | check the converse try making sense of 172 | \begin{halfshyblock}{Bi-duality} 173 | The dual of the dual linear program is the primal one. 174 | \end{halfshyblock} 175 | \end{frame} 176 | 177 | \begin{frame}{Fundamental Theorem of Linear Programming} 178 | Incidently, the previous strategy shows that \textsc{Simplex} finds 179 | solutions of both $L$ and $L^\vee$ that have same objective 180 | values. Thus \textsc{Simplex} does compute an optimal solution of 181 | $L$. 182 | \begin{thm} 183 | \textsc{Simplex} does either check whether a linear program $L$ 184 | is feasible, unbounded or gives back an optimal feasible 185 | solution of $L$ having finite objective value. 186 | \end{thm} 187 | This gives the following core result on linear programs : 188 | \begin{cor}[\textit{(Fundamental Theorem of Linear Programming)}] 189 | Any linear program $L$ is either infeasible, unbounded or has 190 | finite optimal objective value 191 | \end{cor} 192 | \end{frame} 193 | 194 | 195 | \begin{frame} 196 | \centering 197 | {\huge \textbf{Merry Christmas!}} 198 | \end{frame} 199 | 200 | \end{document} 201 | 202 | %%% Local Variables: 203 | %%% mode: latex 204 | %%% TeX-master: t 205 | %%% End: 206 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/beamerinnerthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerinnerthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerinnerthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerinnerthememetropolis}[2016/03/14 Metropolis inner theme] 21 | \RequirePackage{etoolbox} 22 | \RequirePackage{keyval} 23 | \RequirePackage{calc} 24 | \RequirePackage{pgfopts} 25 | \RequirePackage{tikz} 26 | \pgfkeys{ 27 | /metropolis/inner/sectionpage/.cd, 28 | .is choice, 29 | none/.code=\metropolis@disablesectionpage, 30 | simple/.code={\metropolis@enablesectionpage 31 | \setbeamertemplate{section page}[simple]}, 32 | progressbar/.code={\metropolis@enablesectionpage 33 | \setbeamertemplate{section page}[progressbar]}, 34 | } 35 | \pgfkeys{ 36 | /metropolis/inner/subsectionpage/.cd, 37 | .is choice, 38 | none/.code=\metropolis@disablesubsectionpage, 39 | simple/.code={\metropolis@enablesubsectionpage 40 | \setbeamertemplate{section page}[simple]}, 41 | progressbar/.code={\metropolis@enablesubsectionpage 42 | \setbeamertemplate{section page}[progressbar]}, 43 | } 44 | \newcommand{\metropolis@inner@setdefaults}{ 45 | \pgfkeys{/metropolis/inner/.cd, 46 | sectionpage=progressbar, 47 | subsectionpage=none 48 | } 49 | } 50 | \setbeamertemplate{title page}{ 51 | \begin{minipage}[b][\paperheight]{\textwidth} 52 | \ifx\inserttitlegraphic\@empty\else\usebeamertemplate*{title graphic}\fi 53 | \vfill% 54 | \ifx\inserttitle\@empty\else\usebeamertemplate*{title}\fi 55 | \ifx\insertsubtitle\@empty\else\usebeamertemplate*{subtitle}\fi 56 | \usebeamertemplate*{title separator} 57 | \ifx\beamer@shortauthor\@empty\else\usebeamertemplate*{author}\fi 58 | \ifx\insertdate\@empty\else\usebeamertemplate*{date}\fi 59 | \ifx\insertinstitute\@empty\else\usebeamertemplate*{institute}\fi 60 | \vfill 61 | \vspace*{1mm} 62 | \end{minipage} 63 | } 64 | \def\maketitle{% 65 | \ifbeamer@inframe 66 | \titlepage 67 | \else 68 | \frame[plain,noframenumbering]{\titlepage} 69 | \fi 70 | } 71 | \def\titlepage{% 72 | \usebeamertemplate{title page} 73 | } 74 | \setbeamertemplate{title graphic}{ 75 | \vbox to 0pt { 76 | \vspace*{2em} 77 | \inserttitlegraphic% 78 | }% 79 | \nointerlineskip% 80 | } 81 | \setbeamertemplate{title}{ 82 | \raggedright% 83 | \linespread{1.0}% 84 | \inserttitle% 85 | \par% 86 | \vspace*{0.5em} 87 | } 88 | \setbeamertemplate{subtitle}{ 89 | \raggedright% 90 | \insertsubtitle% 91 | \par% 92 | \vspace*{0.5em} 93 | } 94 | \setbeamertemplate{title separator}{ 95 | \begin{tikzpicture} 96 | \fill[fg] (0,0) rectangle (\textwidth, 0.4pt); 97 | \end{tikzpicture}% 98 | \par% 99 | } 100 | \setbeamertemplate{author}{ 101 | \vspace*{2em} 102 | \insertauthor% 103 | \par% 104 | \vspace*{0.25em} 105 | } 106 | \setbeamertemplate{date}{ 107 | \insertdate% 108 | \par% 109 | } 110 | \setbeamertemplate{institute}{ 111 | \vspace*{3mm} 112 | \insertinstitute% 113 | \par% 114 | } 115 | \defbeamertemplate{section page}{simple}{ 116 | \begin{center} 117 | \usebeamercolor[fg]{section title} 118 | \usebeamerfont{section title} 119 | \insertsectionhead\par 120 | \ifx\insertsubsectionhead\@empty\else 121 | \usebeamercolor[fg]{subsection title} 122 | \usebeamerfont{subsection title} 123 | \insertsubsectionhead 124 | \fi 125 | \end{center} 126 | } 127 | \defbeamertemplate{section page}{progressbar}{ 128 | \centering 129 | \begin{minipage}{22em} 130 | \raggedright 131 | \usebeamercolor[fg]{section title} 132 | \usebeamerfont{section title} 133 | \insertsectionhead\\[-1ex] 134 | \usebeamertemplate*{progress bar in section page} 135 | \par 136 | \ifx\insertsubsectionhead\@empty\else% 137 | \usebeamercolor[fg]{subsection title}% 138 | \usebeamerfont{subsection title}% 139 | \insertsubsectionhead 140 | \fi 141 | \end{minipage} 142 | \par 143 | \vspace{\baselineskip} 144 | } 145 | \newcommand{\metropolis@disablesectionpage}{ 146 | \AtBeginSection{ 147 | % intentionally empty 148 | } 149 | } 150 | \newcommand{\metropolis@enablesectionpage}{ 151 | \AtBeginSection{ 152 | \ifbeamer@inframe 153 | \sectionpage 154 | \else 155 | \frame[plain,c,noframenumbering]{\sectionpage} 156 | \fi 157 | } 158 | } 159 | \setbeamertemplate{subsection page}{% 160 | \usebeamertemplate*{section page} 161 | } 162 | \newcommand{\metropolis@disablesubsectionpage}{ 163 | \AtBeginSubsection{ 164 | % intentionally empty 165 | } 166 | } 167 | \newcommand{\metropolis@enablesubsectionpage}{ 168 | \AtBeginSubsection{ 169 | \ifbeamer@inframe 170 | \subsectionpage 171 | \else 172 | \frame[plain,c,noframenumbering]{\subsectionpage} 173 | \fi 174 | } 175 | } 176 | \newlength{\metropolis@progressonsectionpage} 177 | \setbeamertemplate{progress bar in section page}{ 178 | \setlength{\metropolis@progressonsectionpage}{% 179 | \textwidth * \ratio{\insertframenumber pt}{\inserttotalframenumber pt}% 180 | }% 181 | \begin{tikzpicture} 182 | \fill[bg] (0,0) rectangle (\textwidth, 0.4pt); 183 | \fill[fg] (0,0) rectangle (\metropolis@progressonsectionpage, 0.4pt); 184 | \end{tikzpicture}% 185 | } 186 | \def\inserttotalframenumber{100} 187 | \newlength{\metropolis@blocksep} 188 | \newlength{\metropolis@blockadjust} 189 | \setlength{\metropolis@blocksep}{0.75ex} 190 | \setlength{\metropolis@blockadjust}{0.25ex} 191 | \providecommand{\metropolis@strut}{% 192 | \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz()}% 193 | } 194 | \newcommand{\metropolis@block}[1]{ 195 | \par\vskip\medskipamount% 196 | \setlength{\parskip}{0pt} 197 | \ifbeamercolorempty[bg]{block title#1}{% 198 | \begin{beamercolorbox}[rightskip=0pt plus 4em]{block title#1}}{% 199 | \ifbeamercolorempty[bg]{block title}{% 200 | \begin{beamercolorbox}[rightskip=0pt plus 4em]{block title#1}% 201 | }% 202 | {% 203 | \begin{beamercolorbox}[ 204 | sep=\dimexpr\metropolis@blocksep-\metropolis@blockadjust\relax, 205 | leftskip=\metropolis@blockadjust, 206 | rightskip=\dimexpr\metropolis@blockadjust plus 4em\relax 207 | ]{block title#1}% 208 | }}% 209 | \usebeamerfont*{block title#1}% 210 | \metropolis@strut% 211 | \insertblocktitle% 212 | \metropolis@strut% 213 | \end{beamercolorbox}% 214 | \nointerlineskip% 215 | \ifbeamercolorempty[bg]{block body#1}{% 216 | \begin{beamercolorbox}[vmode]{block body#1}}{ 217 | \ifbeamercolorempty[bg]{block body}{% 218 | \begin{beamercolorbox}[vmode]{block body#1}% 219 | }{% 220 | \begin{beamercolorbox}[sep=\metropolis@blocksep, vmode]{block body#1}% 221 | \vspace{-\metropolis@parskip} 222 | }}% 223 | \usebeamerfont{block body#1}% 224 | \setlength{\parskip}{\metropolis@parskip}% 225 | } 226 | \setbeamertemplate{block begin}{\metropolis@block{}} 227 | \setbeamertemplate{block alerted begin}{\metropolis@block{ alerted}} 228 | \setbeamertemplate{block example begin}{\metropolis@block{ example}} 229 | \setbeamertemplate{block end}{\end{beamercolorbox}\vspace*{0.2ex}} 230 | \setbeamertemplate{block alerted end}{\end{beamercolorbox}\vspace*{0.2ex}} 231 | \setbeamertemplate{block example end}{\end{beamercolorbox}\vspace*{0.2ex}} 232 | \setbeamertemplate{itemize items}{\textbullet} 233 | \setbeamertemplate{caption label separator}{: } 234 | \setbeamertemplate{caption}[numbered] 235 | \setbeamertemplate{footnote}{% 236 | \parindent 0em\noindent% 237 | \raggedright 238 | \usebeamercolor{footnote}\hbox to 0.8em{\hfil\insertfootnotemark}\insertfootnotetext\par% 239 | } 240 | \newlength{\metropolis@parskip} 241 | \setlength{\metropolis@parskip}{0.5em} 242 | \setlength{\parskip}{\metropolis@parskip} 243 | \linespread{1.15} 244 | \define@key{beamerframe}{c}[true]{% centered 245 | \beamer@frametopskip=0pt plus 1fill\relax% 246 | \beamer@framebottomskip=0pt plus 1fill\relax% 247 | \beamer@frametopskipautobreak=0pt plus .4\paperheight\relax% 248 | \beamer@framebottomskipautobreak=0pt plus .6\paperheight\relax% 249 | \def\beamer@initfirstlineunskip{}% 250 | } 251 | \providebool{metropolis@standout} 252 | \define@key{beamerframe}{standout}[true]{% 253 | \booltrue{metropolis@standout} 254 | \begingroup 255 | \setkeys{beamerframe}{c} 256 | \setkeys{beamerframe}{noframenumbering} 257 | \ifbeamercolorempty[bg]{palette primary}{ 258 | \setbeamercolor{background canvas}{ 259 | use=palette primary, 260 | bg=-palette primary.fg 261 | } 262 | }{ 263 | \setbeamercolor{background canvas}{ 264 | use=palette primary, 265 | bg=palette primary.bg 266 | } 267 | } 268 | \centering 269 | \usebeamercolor[fg]{palette primary} 270 | \usebeamerfont{standout} 271 | } 272 | \apptocmd{\beamer@reseteecodes}{% 273 | \ifbool{metropolis@standout}{ 274 | \endgroup 275 | \boolfalse{metropolis@standout} 276 | }{} 277 | }{}{} 278 | \metropolis@inner@setdefaults 279 | \ProcessPgfPackageOptions{/metropolis/inner} 280 | \endinput 281 | %% 282 | %% End of file `beamerinnerthememetropolis.sty'. 283 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/beamerinnerthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerinnerthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerinnerthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerinnerthememetropolis}[2016/03/14 Metropolis inner theme] 21 | \RequirePackage{etoolbox} 22 | \RequirePackage{keyval} 23 | \RequirePackage{calc} 24 | \RequirePackage{pgfopts} 25 | \RequirePackage{tikz} 26 | \pgfkeys{ 27 | /metropolis/inner/sectionpage/.cd, 28 | .is choice, 29 | none/.code=\metropolis@disablesectionpage, 30 | simple/.code={\metropolis@enablesectionpage 31 | \setbeamertemplate{section page}[simple]}, 32 | progressbar/.code={\metropolis@enablesectionpage 33 | \setbeamertemplate{section page}[progressbar]}, 34 | } 35 | \pgfkeys{ 36 | /metropolis/inner/subsectionpage/.cd, 37 | .is choice, 38 | none/.code=\metropolis@disablesubsectionpage, 39 | simple/.code={\metropolis@enablesubsectionpage 40 | \setbeamertemplate{section page}[simple]}, 41 | progressbar/.code={\metropolis@enablesubsectionpage 42 | \setbeamertemplate{section page}[progressbar]}, 43 | } 44 | \newcommand{\metropolis@inner@setdefaults}{ 45 | \pgfkeys{/metropolis/inner/.cd, 46 | sectionpage=progressbar, 47 | subsectionpage=none 48 | } 49 | } 50 | \setbeamertemplate{title page}{ 51 | \begin{minipage}[b][\paperheight]{\textwidth} 52 | \ifx\inserttitlegraphic\@empty\else\usebeamertemplate*{title graphic}\fi 53 | \vfill% 54 | \ifx\inserttitle\@empty\else\usebeamertemplate*{title}\fi 55 | \ifx\insertsubtitle\@empty\else\usebeamertemplate*{subtitle}\fi 56 | \usebeamertemplate*{title separator} 57 | \ifx\beamer@shortauthor\@empty\else\usebeamertemplate*{author}\fi 58 | \ifx\insertdate\@empty\else\usebeamertemplate*{date}\fi 59 | \ifx\insertinstitute\@empty\else\usebeamertemplate*{institute}\fi 60 | \vfill 61 | \vspace*{1mm} 62 | \end{minipage} 63 | } 64 | \def\maketitle{% 65 | \ifbeamer@inframe 66 | \titlepage 67 | \else 68 | \frame[plain,noframenumbering]{\titlepage} 69 | \fi 70 | } 71 | \def\titlepage{% 72 | \usebeamertemplate{title page} 73 | } 74 | \setbeamertemplate{title graphic}{ 75 | \vbox to 0pt { 76 | \vspace*{2em} 77 | \inserttitlegraphic% 78 | }% 79 | \nointerlineskip% 80 | } 81 | \setbeamertemplate{title}{ 82 | \raggedright% 83 | \linespread{1.0}% 84 | \inserttitle% 85 | \par% 86 | \vspace*{0.5em} 87 | } 88 | \setbeamertemplate{subtitle}{ 89 | \raggedright% 90 | \insertsubtitle% 91 | \par% 92 | \vspace*{0.5em} 93 | } 94 | \setbeamertemplate{title separator}{ 95 | \begin{tikzpicture} 96 | \fill[fg] (0,0) rectangle (\textwidth, 0.4pt); 97 | \end{tikzpicture}% 98 | \par% 99 | } 100 | \setbeamertemplate{author}{ 101 | \vspace*{2em} 102 | \insertauthor% 103 | \par% 104 | \vspace*{0.25em} 105 | } 106 | \setbeamertemplate{date}{ 107 | \insertdate% 108 | \par% 109 | } 110 | \setbeamertemplate{institute}{ 111 | \vspace*{3mm} 112 | \insertinstitute% 113 | \par% 114 | } 115 | \defbeamertemplate{section page}{simple}{ 116 | \begin{center} 117 | \usebeamercolor[fg]{section title} 118 | \usebeamerfont{section title} 119 | \insertsectionhead\par 120 | \ifx\insertsubsectionhead\@empty\else 121 | \usebeamercolor[fg]{subsection title} 122 | \usebeamerfont{subsection title} 123 | \insertsubsectionhead 124 | \fi 125 | \end{center} 126 | } 127 | \defbeamertemplate{section page}{progressbar}{ 128 | \centering 129 | \begin{minipage}{22em} 130 | \raggedright 131 | \usebeamercolor[fg]{section title} 132 | \usebeamerfont{section title} 133 | \insertsectionhead\\[-1ex] 134 | \usebeamertemplate*{progress bar in section page} 135 | \par 136 | \ifx\insertsubsectionhead\@empty\else% 137 | \usebeamercolor[fg]{subsection title}% 138 | \usebeamerfont{subsection title}% 139 | \insertsubsectionhead 140 | \fi 141 | \end{minipage} 142 | \par 143 | \vspace{\baselineskip} 144 | } 145 | \newcommand{\metropolis@disablesectionpage}{ 146 | \AtBeginSection{ 147 | % intentionally empty 148 | } 149 | } 150 | \newcommand{\metropolis@enablesectionpage}{ 151 | \AtBeginSection{ 152 | \ifbeamer@inframe 153 | \sectionpage 154 | \else 155 | \frame[plain,c,noframenumbering]{\sectionpage} 156 | \fi 157 | } 158 | } 159 | \setbeamertemplate{subsection page}{% 160 | \usebeamertemplate*{section page} 161 | } 162 | \newcommand{\metropolis@disablesubsectionpage}{ 163 | \AtBeginSubsection{ 164 | % intentionally empty 165 | } 166 | } 167 | \newcommand{\metropolis@enablesubsectionpage}{ 168 | \AtBeginSubsection{ 169 | \ifbeamer@inframe 170 | \subsectionpage 171 | \else 172 | \frame[plain,c,noframenumbering]{\subsectionpage} 173 | \fi 174 | } 175 | } 176 | \newlength{\metropolis@progressonsectionpage} 177 | \setbeamertemplate{progress bar in section page}{ 178 | \setlength{\metropolis@progressonsectionpage}{% 179 | \textwidth * \ratio{\insertframenumber pt}{\inserttotalframenumber pt}% 180 | }% 181 | \begin{tikzpicture} 182 | \fill[bg] (0,0) rectangle (\textwidth, 0.4pt); 183 | \fill[fg] (0,0) rectangle (\metropolis@progressonsectionpage, 0.4pt); 184 | \end{tikzpicture}% 185 | } 186 | \def\inserttotalframenumber{100} 187 | \newlength{\metropolis@blocksep} 188 | \newlength{\metropolis@blockadjust} 189 | \setlength{\metropolis@blocksep}{0.75ex} 190 | \setlength{\metropolis@blockadjust}{0.25ex} 191 | \providecommand{\metropolis@strut}{% 192 | \vphantom{ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz()}% 193 | } 194 | \newcommand{\metropolis@block}[1]{ 195 | \par\vskip\medskipamount% 196 | \setlength{\parskip}{0pt} 197 | \ifbeamercolorempty[bg]{block title#1}{% 198 | \begin{beamercolorbox}[rightskip=0pt plus 4em]{block title#1}}{% 199 | \ifbeamercolorempty[bg]{block title}{% 200 | \begin{beamercolorbox}[rightskip=0pt plus 4em]{block title#1}% 201 | }% 202 | {% 203 | \begin{beamercolorbox}[ 204 | sep=\dimexpr\metropolis@blocksep-\metropolis@blockadjust\relax, 205 | leftskip=\metropolis@blockadjust, 206 | rightskip=\dimexpr\metropolis@blockadjust plus 4em\relax 207 | ]{block title#1}% 208 | }}% 209 | \usebeamerfont*{block title#1}% 210 | \metropolis@strut% 211 | \insertblocktitle% 212 | \metropolis@strut% 213 | \end{beamercolorbox}% 214 | \nointerlineskip% 215 | \ifbeamercolorempty[bg]{block body#1}{% 216 | \begin{beamercolorbox}[vmode]{block body#1}}{ 217 | \ifbeamercolorempty[bg]{block body}{% 218 | \begin{beamercolorbox}[vmode]{block body#1}% 219 | }{% 220 | \begin{beamercolorbox}[sep=\metropolis@blocksep, vmode]{block body#1}% 221 | \vspace{-\metropolis@parskip} 222 | }}% 223 | \usebeamerfont{block body#1}% 224 | \setlength{\parskip}{\metropolis@parskip}% 225 | } 226 | \setbeamertemplate{block begin}{\metropolis@block{}} 227 | \setbeamertemplate{block alerted begin}{\metropolis@block{ alerted}} 228 | \setbeamertemplate{block example begin}{\metropolis@block{ example}} 229 | \setbeamertemplate{block end}{\end{beamercolorbox}\vspace*{0.2ex}} 230 | \setbeamertemplate{block alerted end}{\end{beamercolorbox}\vspace*{0.2ex}} 231 | \setbeamertemplate{block example end}{\end{beamercolorbox}\vspace*{0.2ex}} 232 | \setbeamertemplate{itemize items}{\textbullet} 233 | \setbeamertemplate{caption label separator}{: } 234 | \setbeamertemplate{caption}[numbered] 235 | \setbeamertemplate{footnote}{% 236 | \parindent 0em\noindent% 237 | \raggedright 238 | \usebeamercolor{footnote}\hbox to 0.8em{\hfil\insertfootnotemark}\insertfootnotetext\par% 239 | } 240 | \newlength{\metropolis@parskip} 241 | \setlength{\metropolis@parskip}{0.5em} 242 | \setlength{\parskip}{\metropolis@parskip} 243 | \linespread{1.15} 244 | \define@key{beamerframe}{c}[true]{% centered 245 | \beamer@frametopskip=0pt plus 1fill\relax% 246 | \beamer@framebottomskip=0pt plus 1fill\relax% 247 | \beamer@frametopskipautobreak=0pt plus .4\paperheight\relax% 248 | \beamer@framebottomskipautobreak=0pt plus .6\paperheight\relax% 249 | \def\beamer@initfirstlineunskip{}% 250 | } 251 | \providebool{metropolis@standout} 252 | \define@key{beamerframe}{standout}[true]{% 253 | \booltrue{metropolis@standout} 254 | \begingroup 255 | \setkeys{beamerframe}{c} 256 | \setkeys{beamerframe}{noframenumbering} 257 | \ifbeamercolorempty[bg]{palette primary}{ 258 | \setbeamercolor{background canvas}{ 259 | use=palette primary, 260 | bg=-palette primary.fg 261 | } 262 | }{ 263 | \setbeamercolor{background canvas}{ 264 | use=palette primary, 265 | bg=palette primary.bg 266 | } 267 | } 268 | \centering 269 | \usebeamercolor[fg]{palette primary} 270 | \usebeamerfont{standout} 271 | } 272 | \apptocmd{\beamer@reseteecodes}{% 273 | \ifbool{metropolis@standout}{ 274 | \endgroup 275 | \boolfalse{metropolis@standout} 276 | }{} 277 | }{}{} 278 | \metropolis@inner@setdefaults 279 | \ProcessPgfPackageOptions{/metropolis/inner} 280 | \endinput 281 | %% 282 | %% End of file `beamerinnerthememetropolis.sty'. 283 | -------------------------------------------------------------------------------- /Slides/English/Tex/Style/beamerfontthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerfontthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerfontthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerfontthememetropolis}[2016/03/14 Metropolis font theme] 21 | \RequirePackage{etoolbox} 22 | \RequirePackage{ifxetex} 23 | \RequirePackage{ifluatex} 24 | \RequirePackage{pgfopts} 25 | \ifboolexpr{bool {xetex} or bool {luatex}}{ 26 | \RequirePackage[no-math]{fontspec} 27 | \newcounter{fontsnotfound} 28 | \newcommand{\checkfont}[1]{% 29 | \suppressfontnotfounderror=1% 30 | \font\x = "#1" at 10pt 31 | \selectfont 32 | \ifx\x\nullfont% 33 | \stepcounter{fontsnotfound}% 34 | \fi% 35 | \suppressfontnotfounderror=0% 36 | } 37 | 38 | \newcommand{\iffontsavailable}[3]{% 39 | \setcounter{fontsnotfound}{0}% 40 | \expandafter\forcsvlist\expandafter% 41 | \checkfont\expandafter{#1}% 42 | \ifnum\value{fontsnotfound}=0% 43 | #2% 44 | \else% 45 | #3% 46 | \fi% 47 | } 48 | \iffontsavailable{Fira Sans Light,% 49 | Fira Sans Light Italic,% 50 | Fira Sans,% 51 | Fira Sans Italic}% 52 | {% 53 | \setsansfont[ItalicFont={Fira Sans Light Italic},% 54 | BoldFont={Fira Sans},% 55 | BoldItalicFont={Fira Sans Italic}]% 56 | {Fira Sans Light}% 57 | }{% 58 | \iffontsavailable{Fira Sans Light OT,% 59 | Fira Sans Light Italic OT,% 60 | Fira Sans OT,% 61 | Fira Sans Italic OT}% 62 | {% 63 | \setsansfont[ItalicFont={Fira Sans Light Italic OT},% 64 | BoldFont={Fira Sans OT},% 65 | BoldItalicFont={Fira Sans Italic OT}]% 66 | {Fira Sans Light OT}% 67 | }{% 68 | \PackageWarning{beamerthememetropolis}{% 69 | Could not find Fira Sans fonts% 70 | } 71 | } 72 | } 73 | \iffontsavailable{Fira Mono, Fira Mono Bold}{% 74 | \setmonofont[BoldFont={Fira Mono Medium}]{Fira Mono}% 75 | }{% 76 | \iffontsavailable{Fira Mono OT, Fira Mono Bold OT}{% 77 | \setmonofont[BoldFont={Fira Mono Medium OT}]{Fira Mono OT}% 78 | }{% 79 | \PackageWarning{beamerthememetropolis}{% 80 | Could not find Fira Mono fonts% 81 | } 82 | } 83 | } 84 | \AtBeginEnvironment{tabular}{% 85 | \addfontfeature{Numbers={Monospaced}}% 86 | } 87 | }{% 88 | \PackageWarning{beamerthememetropolis}{% 89 | You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts% 90 | } 91 | } 92 | \setbeamerfont{title}{size=\Large,% 93 | series=\bfseries} 94 | \setbeamerfont{author}{size=\small} 95 | \setbeamerfont{date}{size=\small} 96 | \setbeamerfont{section title}{size=\Large,% 97 | series=\bfseries} 98 | \setbeamerfont{block title}{size=\normalsize,% 99 | series=\bfseries} 100 | \setbeamerfont{block title alerted}{size=\normalsize,% 101 | series=\bfseries} 102 | \setbeamerfont*{subtitle}{size=\large} 103 | \setbeamerfont{frametitle}{size=\large,% 104 | series=\bfseries} 105 | \setbeamerfont{caption}{size=\small} 106 | \setbeamerfont{caption name}{series=\bfseries} 107 | \setbeamerfont{description item}{series=\bfseries} 108 | \setbeamerfont{page number in head/foot}{size=\scriptsize} 109 | \setbeamerfont{bibliography entry author}{size=\normalsize,% 110 | series=\normalfont} 111 | \setbeamerfont{bibliography entry title}{size=\normalsize,% 112 | series=\bfseries} 113 | \setbeamerfont{bibliography entry location}{size=\normalsize,% 114 | series=\normalfont} 115 | \setbeamerfont{bibliography entry note}{size=\small,% 116 | series=\normalfont} 117 | \setbeamerfont{standout}{size=\Large,% 118 | series=\bfseries} 119 | \pgfkeys{ 120 | /metropolis/font/titleformat title/.cd, 121 | .is choice, 122 | regular/.code={% 123 | \let\metropolis@titleformat\@empty% 124 | \setbeamerfont{title}{shape=\normalfont}% 125 | }, 126 | smallcaps/.code={% 127 | \let\metropolis@titleformat\@empty% 128 | \setbeamerfont{title}{shape=\scshape}% 129 | }, 130 | allsmallcaps/.code={% 131 | \let\metropolis@titleformat\lowercase% 132 | \setbeamerfont{title}{shape=\scshape}% 133 | \PackageWarning{beamerthememetropolis}{% 134 | Be aware that titleformat title=allsmallcaps can lead to problems% 135 | } 136 | }, 137 | allcaps/.code={% 138 | \let\metropolis@titleformat\uppercase% 139 | \setbeamerfont{title}{shape=\normalfont} 140 | \PackageWarning{beamerthememetropolis}{% 141 | Be aware that titleformat title=allcaps can lead to problems% 142 | } 143 | }, 144 | } 145 | \pgfkeys{ 146 | /metropolis/font/titleformat subtitle/.cd, 147 | .is choice, 148 | regular/.code={% 149 | \let\metropolis@subtitleformat\@empty% 150 | \setbeamerfont{subtitle}{shape=\normalfont}% 151 | }, 152 | smallcaps/.code={% 153 | \let\metropolis@subtitleformat\@empty% 154 | \setbeamerfont{subtitle}{shape=\scshape}% 155 | }, 156 | allsmallcaps/.code={% 157 | \let\metropolis@subtitleformat\lowercase% 158 | \setbeamerfont{subtitle}{shape=\scshape}% 159 | \PackageWarning{beamerthememetropolis}{% 160 | Be aware that titleformat subtitle=allsmallcaps can lead to problems% 161 | } 162 | }, 163 | allcaps/.code={% 164 | \let\metropolis@subtitleformat\uppercase% 165 | \setbeamerfont{subtitle}{shape=\normalfont}% 166 | \PackageWarning{beamerthememetropolis}{% 167 | Be aware that titleformat subtitle=allcaps can lead to problems% 168 | } 169 | }, 170 | } 171 | \pgfkeys{ 172 | /metropolis/font/titleformat section/.cd, 173 | .is choice, 174 | regular/.code={% 175 | \let\metropolis@sectiontitleformat\@empty% 176 | \setbeamerfont{section title}{shape=\normalfont}% 177 | }, 178 | smallcaps/.code={% 179 | \let\metropolis@sectiontitleformat\@empty% 180 | \setbeamerfont{section title}{shape=\scshape}% 181 | }, 182 | allsmallcaps/.code={% 183 | \let\metropolis@sectiontitleformat\MakeLowercase% 184 | \setbeamerfont{section title}{shape=\scshape}% 185 | \PackageWarning{beamerthememetropolis}{% 186 | Be aware that titleformat section=allsmallcaps can lead to problems% 187 | } 188 | }, 189 | allcaps/.code={% 190 | \let\metropolis@sectiontitleformat\MakeUppercase% 191 | \setbeamerfont{section title}{shape=\normalfont}% 192 | \PackageWarning{beamerthememetropolis}{% 193 | Be aware that titleformat section=allcaps can lead to problems% 194 | } 195 | }, 196 | } 197 | \pgfkeys{ 198 | /metropolis/font/titleformat frame/.cd, 199 | .is choice, 200 | regular/.code={% 201 | \let\metropolis@frametitleformat\@empty% 202 | \setbeamerfont{frametitle}{shape=\normalfont}% 203 | }, 204 | smallcaps/.code={% 205 | \let\metropolis@frametitleformat\@empty% 206 | \setbeamerfont{frametitle}{shape=\scshape}% 207 | }, 208 | allsmallcaps/.code={% 209 | \let\metropolis@frametitleformat\MakeLowercase% 210 | \setbeamerfont{frametitle}{shape=\scshape}% 211 | \PackageWarning{beamerthememetropolis}{% 212 | Be aware that titleformat frame=allsmallcaps can lead to problems% 213 | } 214 | }, 215 | allcaps/.code={% 216 | \let\metropolis@frametitleformat\MakeUppercase% 217 | \setbeamerfont{frametitle}{shape=\normalfont} 218 | \PackageWarning{beamerthememetropolis}{% 219 | Be aware that titleformat frame=allcaps can lead to problems% 220 | } 221 | }, 222 | } 223 | \pgfkeys{ 224 | /metropolis/font/.cd, 225 | titleformattitle/.code=\pgfkeysalso{titleformat title=#1}, 226 | titleformatsubtitle/.code=\pgfkeysalso{titleformat subtitle=#1}, 227 | titleformatsection/.code=\pgfkeysalso{titleformat section=#1}, 228 | titleformatframe/.code=\pgfkeysalso{titleformat frame=#1}, 229 | } 230 | \newcommand{\metropolis@font@setdefaults}{ 231 | \pgfkeys{/metropolis/font/.cd, 232 | titleformat title=regular, 233 | titleformat subtitle=regular, 234 | titleformat section=regular, 235 | titleformat frame=regular, 236 | } 237 | } 238 | \def\metropolis@titleformat#1{#1} 239 | \def\metropolis@subtitleformat#1{#1} 240 | \def\metropolis@sectiontitleformat#1{#1} 241 | \def\metropolis@frametitleformat#1{#1} 242 | \patchcmd{\beamer@title}% 243 | {\def\inserttitle{#2}}% 244 | {\def\inserttitle{\metropolis@titleformat{#2}}}% 245 | {}% 246 | {\PackageError{beamerfontthememetropolis}{Patching title failed}} 247 | \patchcmd{\beamer@subtitle}% 248 | {\def\insertsubtitle{#2}}% 249 | {\def\insertsubtitle{\metropolis@subtitleformat{#2}}}% 250 | {}% 251 | {\PackageError{beamerfontthememetropolis}{Patching subtitle failed}} 252 | \patchcmd{\sectionentry} 253 | {\def\insertsectionhead{#2}} 254 | {\def\insertsectionhead{\metropolis@sectiontitleformat{#2}}} 255 | {} 256 | {\PackageError{beamerfontthememetropolis}{Patching section title failed}} 257 | \patchcmd{\beamer@section} 258 | {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} 259 | {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{% 260 | \metropolis@sectiontitleformat{#1}}}} 261 | {} 262 | {\PackageError{beamerfontthememetropolis}{Patching section title failed}} 263 | \patchcmd{\beamer@subsection} 264 | {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} 265 | {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{% 266 | \metropolis@sectiontitleformat{#1}}}} 267 | {} 268 | {\PackageError{beamerfontthememetropolis}{Patching section title failed}} 269 | \patchcmd{\beamer@@frametitle} 270 | {\beamer@ifempty{#2}{}{% 271 | \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space% 272 | \usebeamertemplate*{frametitle continuation}\fi}}% 273 | \gdef\beamer@frametitle{#2}% 274 | \gdef\beamer@shortframetitle{#1}% 275 | }} 276 | {\beamer@ifempty{#2}{}{% 277 | \gdef\insertframetitle{{\metropolis@frametitleformat{#2}\ifnum% 278 | \beamer@autobreakcount>0\relax{}\space% 279 | \usebeamertemplate*{frametitle continuation}\fi}}% 280 | \gdef\beamer@frametitle{#2}% 281 | \gdef\beamer@shortframetitle{#1}% 282 | }} 283 | {} 284 | {\PackageError{beamerfontthememetropolis}{Patching frame title failed}} 285 | \metropolis@font@setdefaults 286 | \ProcessPgfPackageOptions{/metropolis/font} 287 | \endinput 288 | %% 289 | %% End of file `beamerfontthememetropolis.sty'. 290 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/Style/beamerfontthememetropolis.sty: -------------------------------------------------------------------------------- 1 | %% 2 | %% This is file `beamerfontthememetropolis.sty', 3 | %% generated with the docstrip utility. 4 | %% 5 | %% The original source files were: 6 | %% 7 | %% beamerfontthememetropolis.dtx (with options: `package') 8 | %% --------------------------------------------------------------------------- 9 | %% Copyright 2015 Matthias Vogelgesang and the LaTeX community. A full list of 10 | %% contributors can be found at 11 | %% 12 | %% https://github.com/matze/mtheme/graphs/contributors 13 | %% 14 | %% and the original template was based on the HSRM theme by Benjamin Weiss. 15 | %% 16 | %% This work is licensed under a Creative Commons Attribution-ShareAlike 4.0 17 | %% International License (https://creativecommons.org/licenses/by-sa/4.0/). 18 | %% --------------------------------------------------------------------------- 19 | \NeedsTeXFormat{LaTeX2e} 20 | \ProvidesPackage{beamerfontthememetropolis}[2016/03/14 Metropolis font theme] 21 | \RequirePackage{etoolbox} 22 | \RequirePackage{ifxetex} 23 | \RequirePackage{ifluatex} 24 | \RequirePackage{pgfopts} 25 | \ifboolexpr{bool {xetex} or bool {luatex}}{ 26 | \RequirePackage[no-math]{fontspec} 27 | \newcounter{fontsnotfound} 28 | \newcommand{\checkfont}[1]{% 29 | \suppressfontnotfounderror=1% 30 | \font\x = "#1" at 10pt 31 | \selectfont 32 | \ifx\x\nullfont% 33 | \stepcounter{fontsnotfound}% 34 | \fi% 35 | \suppressfontnotfounderror=0% 36 | } 37 | 38 | \newcommand{\iffontsavailable}[3]{% 39 | \setcounter{fontsnotfound}{0}% 40 | \expandafter\forcsvlist\expandafter% 41 | \checkfont\expandafter{#1}% 42 | \ifnum\value{fontsnotfound}=0% 43 | #2% 44 | \else% 45 | #3% 46 | \fi% 47 | } 48 | \iffontsavailable{Fira Sans Light,% 49 | Fira Sans Light Italic,% 50 | Fira Sans,% 51 | Fira Sans Italic}% 52 | {% 53 | \setsansfont[ItalicFont={Fira Sans Light Italic},% 54 | BoldFont={Fira Sans},% 55 | BoldItalicFont={Fira Sans Italic}]% 56 | {Fira Sans Light}% 57 | }{% 58 | \iffontsavailable{Fira Sans Light OT,% 59 | Fira Sans Light Italic OT,% 60 | Fira Sans OT,% 61 | Fira Sans Italic OT}% 62 | {% 63 | \setsansfont[ItalicFont={Fira Sans Light Italic OT},% 64 | BoldFont={Fira Sans OT},% 65 | BoldItalicFont={Fira Sans Italic OT}]% 66 | {Fira Sans Light OT}% 67 | }{% 68 | \PackageWarning{beamerthememetropolis}{% 69 | Could not find Fira Sans fonts% 70 | } 71 | } 72 | } 73 | \iffontsavailable{Fira Mono, Fira Mono Bold}{% 74 | \setmonofont[BoldFont={Fira Mono Medium}]{Fira Mono}% 75 | }{% 76 | \iffontsavailable{Fira Mono OT, Fira Mono Bold OT}{% 77 | \setmonofont[BoldFont={Fira Mono Medium OT}]{Fira Mono OT}% 78 | }{% 79 | \PackageWarning{beamerthememetropolis}{% 80 | Could not find Fira Mono fonts% 81 | } 82 | } 83 | } 84 | \AtBeginEnvironment{tabular}{% 85 | \addfontfeature{Numbers={Monospaced}}% 86 | } 87 | }{% 88 | \PackageWarning{beamerthememetropolis}{% 89 | You need to compile with XeLaTeX or LuaLaTeX to use the Fira fonts% 90 | } 91 | } 92 | \setbeamerfont{title}{size=\Large,% 93 | series=\bfseries} 94 | \setbeamerfont{author}{size=\small} 95 | \setbeamerfont{date}{size=\small} 96 | \setbeamerfont{section title}{size=\Large,% 97 | series=\bfseries} 98 | \setbeamerfont{block title}{size=\normalsize,% 99 | series=\bfseries} 100 | \setbeamerfont{block title alerted}{size=\normalsize,% 101 | series=\bfseries} 102 | \setbeamerfont*{subtitle}{size=\large} 103 | \setbeamerfont{frametitle}{size=\large,% 104 | series=\bfseries} 105 | \setbeamerfont{caption}{size=\small} 106 | \setbeamerfont{caption name}{series=\bfseries} 107 | \setbeamerfont{description item}{series=\bfseries} 108 | \setbeamerfont{page number in head/foot}{size=\scriptsize} 109 | \setbeamerfont{bibliography entry author}{size=\normalsize,% 110 | series=\normalfont} 111 | \setbeamerfont{bibliography entry title}{size=\normalsize,% 112 | series=\bfseries} 113 | \setbeamerfont{bibliography entry location}{size=\normalsize,% 114 | series=\normalfont} 115 | \setbeamerfont{bibliography entry note}{size=\small,% 116 | series=\normalfont} 117 | \setbeamerfont{standout}{size=\Large,% 118 | series=\bfseries} 119 | \pgfkeys{ 120 | /metropolis/font/titleformat title/.cd, 121 | .is choice, 122 | regular/.code={% 123 | \let\metropolis@titleformat\@empty% 124 | \setbeamerfont{title}{shape=\normalfont}% 125 | }, 126 | smallcaps/.code={% 127 | \let\metropolis@titleformat\@empty% 128 | \setbeamerfont{title}{shape=\scshape}% 129 | }, 130 | allsmallcaps/.code={% 131 | \let\metropolis@titleformat\lowercase% 132 | \setbeamerfont{title}{shape=\scshape}% 133 | \PackageWarning{beamerthememetropolis}{% 134 | Be aware that titleformat title=allsmallcaps can lead to problems% 135 | } 136 | }, 137 | allcaps/.code={% 138 | \let\metropolis@titleformat\uppercase% 139 | \setbeamerfont{title}{shape=\normalfont} 140 | \PackageWarning{beamerthememetropolis}{% 141 | Be aware that titleformat title=allcaps can lead to problems% 142 | } 143 | }, 144 | } 145 | \pgfkeys{ 146 | /metropolis/font/titleformat subtitle/.cd, 147 | .is choice, 148 | regular/.code={% 149 | \let\metropolis@subtitleformat\@empty% 150 | \setbeamerfont{subtitle}{shape=\normalfont}% 151 | }, 152 | smallcaps/.code={% 153 | \let\metropolis@subtitleformat\@empty% 154 | \setbeamerfont{subtitle}{shape=\scshape}% 155 | }, 156 | allsmallcaps/.code={% 157 | \let\metropolis@subtitleformat\lowercase% 158 | \setbeamerfont{subtitle}{shape=\scshape}% 159 | \PackageWarning{beamerthememetropolis}{% 160 | Be aware that titleformat subtitle=allsmallcaps can lead to problems% 161 | } 162 | }, 163 | allcaps/.code={% 164 | \let\metropolis@subtitleformat\uppercase% 165 | \setbeamerfont{subtitle}{shape=\normalfont}% 166 | \PackageWarning{beamerthememetropolis}{% 167 | Be aware that titleformat subtitle=allcaps can lead to problems% 168 | } 169 | }, 170 | } 171 | \pgfkeys{ 172 | /metropolis/font/titleformat section/.cd, 173 | .is choice, 174 | regular/.code={% 175 | \let\metropolis@sectiontitleformat\@empty% 176 | \setbeamerfont{section title}{shape=\normalfont}% 177 | }, 178 | smallcaps/.code={% 179 | \let\metropolis@sectiontitleformat\@empty% 180 | \setbeamerfont{section title}{shape=\scshape}% 181 | }, 182 | allsmallcaps/.code={% 183 | \let\metropolis@sectiontitleformat\MakeLowercase% 184 | \setbeamerfont{section title}{shape=\scshape}% 185 | \PackageWarning{beamerthememetropolis}{% 186 | Be aware that titleformat section=allsmallcaps can lead to problems% 187 | } 188 | }, 189 | allcaps/.code={% 190 | \let\metropolis@sectiontitleformat\MakeUppercase% 191 | \setbeamerfont{section title}{shape=\normalfont}% 192 | \PackageWarning{beamerthememetropolis}{% 193 | Be aware that titleformat section=allcaps can lead to problems% 194 | } 195 | }, 196 | } 197 | \pgfkeys{ 198 | /metropolis/font/titleformat frame/.cd, 199 | .is choice, 200 | regular/.code={% 201 | \let\metropolis@frametitleformat\@empty% 202 | \setbeamerfont{frametitle}{shape=\normalfont}% 203 | }, 204 | smallcaps/.code={% 205 | \let\metropolis@frametitleformat\@empty% 206 | \setbeamerfont{frametitle}{shape=\scshape}% 207 | }, 208 | allsmallcaps/.code={% 209 | \let\metropolis@frametitleformat\MakeLowercase% 210 | \setbeamerfont{frametitle}{shape=\scshape}% 211 | \PackageWarning{beamerthememetropolis}{% 212 | Be aware that titleformat frame=allsmallcaps can lead to problems% 213 | } 214 | }, 215 | allcaps/.code={% 216 | \let\metropolis@frametitleformat\MakeUppercase% 217 | \setbeamerfont{frametitle}{shape=\normalfont} 218 | \PackageWarning{beamerthememetropolis}{% 219 | Be aware that titleformat frame=allcaps can lead to problems% 220 | } 221 | }, 222 | } 223 | \pgfkeys{ 224 | /metropolis/font/.cd, 225 | titleformattitle/.code=\pgfkeysalso{titleformat title=#1}, 226 | titleformatsubtitle/.code=\pgfkeysalso{titleformat subtitle=#1}, 227 | titleformatsection/.code=\pgfkeysalso{titleformat section=#1}, 228 | titleformatframe/.code=\pgfkeysalso{titleformat frame=#1}, 229 | } 230 | \newcommand{\metropolis@font@setdefaults}{ 231 | \pgfkeys{/metropolis/font/.cd, 232 | titleformat title=regular, 233 | titleformat subtitle=regular, 234 | titleformat section=regular, 235 | titleformat frame=regular, 236 | } 237 | } 238 | \def\metropolis@titleformat#1{#1} 239 | \def\metropolis@subtitleformat#1{#1} 240 | \def\metropolis@sectiontitleformat#1{#1} 241 | \def\metropolis@frametitleformat#1{#1} 242 | \patchcmd{\beamer@title}% 243 | {\def\inserttitle{#2}}% 244 | {\def\inserttitle{\metropolis@titleformat{#2}}}% 245 | {}% 246 | {\PackageError{beamerfontthememetropolis}{Patching title failed}} 247 | \patchcmd{\beamer@subtitle}% 248 | {\def\insertsubtitle{#2}}% 249 | {\def\insertsubtitle{\metropolis@subtitleformat{#2}}}% 250 | {}% 251 | {\PackageError{beamerfontthememetropolis}{Patching subtitle failed}} 252 | \patchcmd{\sectionentry} 253 | {\def\insertsectionhead{#2}} 254 | {\def\insertsectionhead{\metropolis@sectiontitleformat{#2}}} 255 | {} 256 | {\PackageError{beamerfontthememetropolis}{Patching section title failed}} 257 | \patchcmd{\beamer@section} 258 | {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} 259 | {\def\insertsectionhead{\hyperlink{Navigation\the\c@page}{% 260 | \metropolis@sectiontitleformat{#1}}}} 261 | {} 262 | {\PackageError{beamerfontthememetropolis}{Patching section title failed}} 263 | \patchcmd{\beamer@subsection} 264 | {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{#1}}} 265 | {\def\insertsubsectionhead{\hyperlink{Navigation\the\c@page}{% 266 | \metropolis@sectiontitleformat{#1}}}} 267 | {} 268 | {\PackageError{beamerfontthememetropolis}{Patching section title failed}} 269 | \patchcmd{\beamer@@frametitle} 270 | {\beamer@ifempty{#2}{}{% 271 | \gdef\insertframetitle{{#2\ifnum\beamer@autobreakcount>0\relax{}\space% 272 | \usebeamertemplate*{frametitle continuation}\fi}}% 273 | \gdef\beamer@frametitle{#2}% 274 | \gdef\beamer@shortframetitle{#1}% 275 | }} 276 | {\beamer@ifempty{#2}{}{% 277 | \gdef\insertframetitle{{\metropolis@frametitleformat{#2}\ifnum% 278 | \beamer@autobreakcount>0\relax{}\space% 279 | \usebeamertemplate*{frametitle continuation}\fi}}% 280 | \gdef\beamer@frametitle{#2}% 281 | \gdef\beamer@shortframetitle{#1}% 282 | }} 283 | {} 284 | {\PackageError{beamerfontthememetropolis}{Patching frame title failed}} 285 | \metropolis@font@setdefaults 286 | \ProcessPgfPackageOptions{/metropolis/font} 287 | \endinput 288 | %% 289 | %% End of file `beamerfontthememetropolis.sty'. 290 | -------------------------------------------------------------------------------- /Slides/English/Tex/d_simplexAlgorithmInit.tex: -------------------------------------------------------------------------------- 1 | \documentclass[32pt, aspectratio = 169]{beamer} 2 | 3 | \usepackage[utf8]{inputenc} % Character encoding. 4 | 5 | \pdfinfo{ 6 | /Author (Bashar Dudin) 7 | /Title (Simplex Algorithm Pre-Treatment) 8 | /Subject (Linear Programs) 9 | } 10 | 11 | 12 | \usepackage{./Style/linearProgramsBeamer} % This is extra styling for Beamer environments. 13 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 14 | 15 | %------------------------------------------------------------------------------- 16 | % TITLE PAGE 17 | %------------------------------------------------------------------------------- 18 | 19 | \author[BD]{Bashar Dudin} 20 | 21 | \institute[]{EPITA} 22 | 23 | \title{Linear Programs} % 24 | \subtitle{Initializing The Simplex Algorithm} 25 | 26 | %------------------------------------------------------------------------------- 27 | % DOCUMENT BODY 28 | %------------------------------------------------------------------------------- 29 | 30 | \begin{document} 31 | 32 | \begin{frame}[plain] 33 | \titlepage % Print the title page as the first slide 34 | \end{frame} 35 | 36 | \begin{frame}{Where We Stand, What We Face?} 37 | 38 | We now have an algorithm \textsc{Simplex} (\textit{Restricted}), 39 | which is conjectured to solve linear programs. For the time being 40 | we've shown that it terminates either by specifying that we have an 41 | unbounded linear program, or by returning a finite value 42 | \textit{expected} to be the maximum we are looking for. 43 | 44 | Uptill now, we've been working under the following two assumptions : 45 | \begin{itemize} 46 | \item 47 | Our linear program is \emph{feasible} ; meaning that it has at 48 | least one feasible solution 49 | \item 50 | The basic solution of the initial slack form is feasible. 51 | \end{itemize} 52 | 53 | \pause 54 | During this lecture, we are going to build a function 55 | \mintinline{python}{init_simplex} taking in a linear program 56 | $(\bs{A}, \bs{b}, \bs{c}, \nu)$ and either returning back the fact 57 | it is \emph{not} feasible or a linear program 58 | $(N, B, \underline{\bs{A}}, \underline{\bs{b}}, \underline{\bs{c}}, 59 | \nu)$ in slack form having feasible basic solution. 60 | \end{frame} 61 | 62 | \section{Feasibility} 63 | 64 | \begin{frame}{Deciding On Feasibility} 65 | \begin{columns}[T] 66 | \begin{column}{.5\textwidth} 67 | Let $L$ be the linear program, given in standard form: 68 | \begin{figure} 69 | \begin{linearProgG}{ 70 | ${\displaystyle z = \nu + \sum_{j=1}^n c_jx_j}$ 71 | }{ 72 | ${\displaystyle \forall i \in \{1, \ldots, m\}, \quad \sum_{j=1}^n a_{ij}x_j \leq b_i}$ 73 | }{ 74 | $\forall j \in N, \quad x_j \geq 0$ 75 | } 76 | \end{linearProgG} 77 | \end{figure} 78 | \end{column} 79 | \begin{column}{.58\textwidth} 80 | \pause 81 | \begin{tcolorbox}[ 82 | enhanced, 83 | parbox = true, 84 | colback = mLightBrown!30!white, 85 | colframe = mLightBrown!30!white, 86 | arc = 0mm, 87 | ] 88 | Out of $L$ we build the following auxiliary linear program $L_{m}$: 89 | \vspace{-1em} 90 | \begin{figure} 91 | \begin{linearProgG}{ 92 | ${\displaystyle z = - x_0}$ 93 | }{ 94 | ${\displaystyle \forall i \in \{1, \ldots, m\}, \quad \sum_{j=1}^n a_{ij}x_j - x_0\leq b_i}$ 95 | }{ 96 | $\forall j \in N\cup \{0\}, \quad x_j \geq 0$ 97 | } 98 | \end{linearProgG} 99 | \end{figure} 100 | \end{tcolorbox} 101 | \end{column} 102 | \end{columns} 103 | \end{frame} 104 | 105 | \begin{frame}{Deciding On Feasibility} 106 | \begin{prop} 107 | $L$ is feasible if, and only if, the optimal objective value of 108 | $L_{m}$ is $0$. 109 | \end{prop} 110 | \begin{overlayarea}{\textwidth}{.8\textheight} 111 | \vspace{.2\baselineskip} 112 | \begin{onlyenv}<2-4> 113 | \setlength\columnseprule{.1pt} 114 | \begin{multicols}{2} 115 | \begin{demo} 116 | Notice first that the optimal objective value of 117 | $L_{m}$ is $0$. Therefore, if we show that $0$ is an 118 | objective value of $L_{m}$ it is necessarily the 119 | optimal one.\pause[3] 120 | 121 | If $L$ is feasible then there is a tuple 122 | $(t_1, \ldots, t_n)$ of non-negative real numbers satisfying 123 | all linear constraints of $L$. The tuple 124 | $(0, t_1, \ldots, t_n)$ does thus satisfy $L_{m}$ and 125 | $0$ is then an objective value of $L_{m}$, i.e. the 126 | optimal one.\pause[4] 127 | 128 | Conversely, if $L_{m}$ has objective value $0$ (thus 129 | optimal) it is of the form $(0, t_1, \ldots, t_n)$. Plugging 130 | this tuple in the linear constraints of $L_{m}$ it 131 | implies $(t_1, \ldots, t_n)$ is a solution of $L$. 132 | \end{demo} 133 | \end{multicols} 134 | \end{onlyenv} 135 | \begin{onlyenv}<5> 136 | The difference between $L$ and $L_{m}$ is that $L_{m}$ is always feasible : 137 | \begin{center} 138 | \begin{minipage}{.7\textwidth} 139 | \begin{tcolorbox}[ 140 | enhanced, 141 | parbox = true, 142 | colback = mLightBrown!30!white, 143 | colframe = mLightBrown!30!white, 144 | arc = 0mm, 145 | ] 146 | If $b_{min}$ is the smallest negative $b_i$ for 147 | $i \in B$, the tuple $(-b_{min}, 0, \ldots, 0)$ is a 148 | feasible solution of $L_{m}$. 149 | \end{tcolorbox} 150 | \end{minipage} 151 | \end{center} 152 | Thus, temporarily admitting validity of the 153 | \textit{restricted} simplex algorithm, if we're able to find a 154 | linear program equivalent to $L_{m}$ which has \alert{feasible 155 | basic solution} then we can decide on the feasibilty of $L$. 156 | \end{onlyenv} 157 | \end{overlayarea} 158 | \end{frame} 159 | 160 | \begin{frame}{Deciding On Feasibility} 161 | \setlength\columnseprule{.1pt} 162 | \begin{multicols}{2} 163 | Consider the slack form of $L_{m}$ 164 | \begin{figure} 165 | \begin{linearProgG}{ 166 | ${\displaystyle z = -x_0}$ 167 | }{ 168 | ${\displaystyle \forall i \quad x_{i + m} + \sum_{j=1}^n a_{ij}x_j - x_0 = b_i}$ 169 | }{ 170 | $\forall j \in N\cup B \cup\{0 \}, \quad x_j \geq 0$ 171 | } 172 | \end{linearProgG} 173 | \end{figure} 174 | \pause 175 | Basic solution of $L_{m}$ is not feasible as soon as $L$ is 176 | not, i.e. as soon as a $b_i$ is negative. \alert{\textbf{We 177 | assume this is the case}}. 178 | 179 | \pause 180 | Let $b_{min}$ be the minimal $b_i$ coefficient. We already 181 | know that 182 | $(-b_{min}, 0, \ldots, 0, \bs{b} - b_{min})$ 183 | is a feasible solution of 184 | $L_{m}$. 185 | 186 | \pause 187 | Let's now use \mintinline{python}{pivot} with entering 188 | variable $0$ and leaving one $min$. The \alert{\textbf{same}} 189 | previous feasible solution of $L_{m}$ is now the basic 190 | solution of the linear program we got after pivoting. 191 | \vspace{.5\baselineskip} 192 | 193 | \pause 194 | \textbf{We got an equivalent linear program to $\bs{L_{m}}$ 195 | having feasible basic solution !} 196 | \end{multicols} 197 | \end{frame} 198 | 199 | \begin{frame} 200 | \frametitle{Tableau of Auxiliary Linear Program} 201 | The tableau \mintinline{python}{T_m} of $L_m$ is obtained out of the 202 | one for $L$ (\mintinline{python}{T}) by adding column 203 | $(1, -1, \ldots, -1)^T$ to tableau before column $\bs{b}^T$ and 204 | putting old coefficients of first row to $0$. 205 | \begin{figure} 206 | \begin{tabular}{c|ccc|ccccc|c|} 207 | & \alert{$\bs{x_1}$} & \alert{$\cdots$} & \alert{$\bs{x_n}$} & \alert{$\bs{x_{n+1}}$} & \alert{$\bs{x_{n+2}}$} & \alert{$\cdots$} & \alert{$\bs{x_{n+m}}$} & \alert{$\bs{x_0}$} & \\ 208 | \hline 209 | & $0$ & $\cdots$ & $0$ & $0$ & $0$ & $\cdots$ & $0$ & $1$ & $0$ \\ 210 | \hline 211 | \alert{$\bs{n+1}$} & $a_{11}$ & $\cdots$ & $a_{1n}$ & $1$ & $0$ & $\cdots$ & $0$ & $-1$ & $b_1$ \\ 212 | \alert{$\bs{n+2}$}& $a_{21}$ & $\cdots$ & $a_{2n}$ & $0$ & $1$ & $\cdots$ & $0$ & $-1$ & $b_2$ \\ 213 | \alert{$\vdots$}& $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$ & $\vdots$ \\ 214 | \alert{$\bs{n+m}$} & $a_{m1}$ & $\cdots$ & $a_{mn}$ & $0$ & $\cdots$ & $\cdots$ & $1$ & $-1$ & $b_m$ 215 | \end{tabular} 216 | \end{figure} 217 | \end{frame} 218 | 219 | \begin{frame}[fragile]{Testing Feasibility} 220 | \begin{overlayarea}{1.05\textwidth}{.6\textheight} 221 | \setlength\columnseprule{.1pt} 222 | \begin{multicols}{2} 223 | \scriptsize{ 224 | \begin{minted}[autogobble, linenos, breaklines]{python} 225 | def is_feasible(N, B, T): 226 | """Testing feasibility of linear program. 227 | 228 | Args: 229 | N, B (list[int]): lists of non-basic and 230 | basic variables. 231 | T (ndarray[float]): numpy array for 232 | tableau of linear program. 233 | Output: 234 | (bool) True if program is feasible 235 | False otherwise. 236 | """ 237 | p, q = T.shape[0], T.shape[1] 238 | c = T[0, :] 239 | T[0, :] = [0]*q 240 | new_c = np.array([1] + [-1]*(p-1), dtype=float) 241 | T = np.insert(T, -1, new_c, axis=1) 242 | N.append(0) 243 | # pivoting to be basic feasible 244 | i_min = np.argmin(T[1: ,-1]) 245 | pivot(N, B, T, i_min, 0) 246 | V = _simplex(N, B, T) 247 | return math.isclose(V[0], 0) 248 | # Possibly slightly modifying the 249 | # optimisation problem ... 250 | \end{minted} 251 | } 252 | \end{multicols} 253 | \end{overlayarea} 254 | \pause 255 | \begin{tcolorbox}[ 256 | enhanced, 257 | parbox = false, 258 | colback = mLightBrown!30!white, 259 | colframe = mLightBrown!30!white, 260 | arc = 0mm, 261 | ] 262 | Not an equivalent LP to L there! Need to understand boundary effects. 263 | \end{tcolorbox} 264 | \end{frame} 265 | 266 | \section{Get A Feasible Basic Solution} 267 | 268 | \begin{frame}{Getting a Feasible Basic Solution} 269 | \begin{halfshyblock}{Assumption} 270 | We assume \mintinline{python}{is_feasible(N, B, T)} returns 271 | \mintinline{python}{True}. 272 | \end{halfshyblock} 273 | \vspace{.5\baselineskip} 274 | \begin{overlayarea}{\textwidth}{.6\textheight} 275 | \begin{onlyenv}<2> 276 | Under the previous assumption \mintinline{python}{is_feasible} 277 | transforms $L_m$ into an equivalent linear program $P$ which has 278 | feasible basic solution with objective value $0$. 279 | \end{onlyenv} 280 | \begin{onlyenv}<3-> 281 | \begin{itemize} 282 | \item<3-> Replace the objective value of $P$ with the original one of $L$. 283 | \item<4-> Make of it a proper LP $Q$ in slack form by replacing 284 | possible basic variables of the objective value with their 285 | expressions in terms of non-basic variables of $P$. 286 | \item<5-> Ensure $x_0$ is no more a basic variable $Q$ by 287 | pivoting with leaving variable $0$ and entering one any 288 | variable having non-zero coefficient. 289 | \end{itemize} 290 | \pause[6] 291 | \vspace{.5\baselineskip} 292 | \begin{halfshyblock}{Fact} 293 | Putting $x_0$ to $0$ in $Q$ gives back an equivalent LP to $L$ 294 | having feasible basic solution. 295 | \end{halfshyblock} 296 | \end{onlyenv} 297 | \end{overlayarea} 298 | \end{frame} 299 | 300 | \begin{frame}[fragile]{The \mintinline{python}{is_feasible} function} 301 | \begin{overlayarea}{1.05\textwidth}{.75\textheight} 302 | \setlength\columnseprule{.1pt} 303 | \begin{multicols}{2} 304 | \scriptsize{ 305 | \begin{minted}[autogobble, linenos, breaklines]{python} 306 | def is_feasible(N, B, T): 307 | """Testing feasibility of linear program. 308 | 309 | Args: 310 | N, B (list[int]): lists of non-basic and 311 | basic variables. 312 | T (ndarray[float]): numpy array for 313 | tableau of linear program. 314 | Output: 315 | (bool) True if program is feasible 316 | False otherwise. 317 | Boundary effect: 318 | Transforms T into an equivalent LP having 319 | basic feasible solution if T is feasible. 320 | """ 321 | p, q = T.shape[0], T.shape[1] 322 | c = T[0, :] 323 | T[0, :] = [0]*q 324 | new_c = np.array([1] + [-1]*(p-1), dtype=float) 325 | T = np.insert(T, -1, new_c, axis=1) 326 | N.append(0) 327 | # pivoting to be basic feasible 328 | i_min = np.argmin(T[1: ,-1]) 329 | pivot(N, B, T, i_min, 0) 330 | V = _simplex(N, B, T) 331 | if 0 in B: 332 | l, e = B.index(0), 0 333 | while T[l, e] == 0 or e == l: 334 | e += 1 335 | pivot(N, B, T, l, e) 336 | for i in B: 337 | c -= c[i]*T[B.index(i), :] 338 | T[0, :] = c 339 | return math.isclose(V[0], 0) 340 | # Possibly slightly modifying the 341 | # optimisation problem ... 342 | \end{minted} 343 | } 344 | \end{multicols} 345 | \end{overlayarea} 346 | \end{frame} 347 | 348 | \begin{frame}{Where We Stand?} 349 | We are now able to 350 | \begin{itemize} 351 | \item<1-> 352 | know whether a linear program is feasible or not using 353 | \mintinline{python}{is_feasible} 354 | \item<2-> 355 | if it is feasible we can build up an equivalent linear program 356 | which has feasible basic solution using boundary effect of 357 | \mintinline{python}{is_feasible} 358 | \item<3-> 359 | once we get a linear program having feasible basic solution we can 360 | check whether our linear program is unbounded or has a 361 | \textit{hopefully} optimal finite solution using the 362 | \textit{restricted} \mintinline{python}{_simplex}. 363 | \end{itemize} 364 | \pause[4] 365 | We are left with showing validity of \textit{restricted} 366 | \mintinline{python}{_simplex}! 367 | \begin{tcolorbox}[ 368 | enhanced, 369 | parbox = false, 370 | colback = mLightBrown!30!white, 371 | colframe = mLightBrown!30!white, 372 | arc = 0mm, 373 | ] 374 | We call \mintinline{python}{simplex} the algorithm globally going 375 | through all previous steps. 376 | \end{tcolorbox} 377 | \end{frame} 378 | 379 | \begin{frame} 380 | \centering 381 | {\huge \textbf{That's it for today !}} 382 | \end{frame} 383 | 384 | \end{document} 385 | 386 | %%% Local Variables: 387 | %%% mode: latex 388 | %%% TeX-master: t 389 | %%% End: 390 | -------------------------------------------------------------------------------- /Slides/Francais/Tex/d_simplexAlgorithmInit.tex: -------------------------------------------------------------------------------- 1 | \documentclass[32pt, aspectratio = 169]{beamer} 2 | 3 | \usepackage[utf8]{inputenc} % Character encoding. 4 | 5 | \pdfinfo{ 6 | /Author (Bashar Dudin) 7 | /Title (Simplex Algorithm Pre-Treatment) 8 | /Subject (Linear Programs) 9 | } 10 | 11 | 12 | \usepackage{./Style/linearProgramsBeamer} % This is extra styling for Beamer environments. 13 | \usepackage{./Style/linearProgramsStyle} % This is a set of commands for maths content. 14 | 15 | %------------------------------------------------------------------------------- 16 | % TITLE PAGE 17 | %------------------------------------------------------------------------------- 18 | 19 | \author[BD]{Bashar Dudin} 20 | 21 | \institute[]{EPITA} 22 | 23 | \title{Linear Programs} % 24 | \subtitle{Initializing The Simplex Algorithm} 25 | 26 | %------------------------------------------------------------------------------- 27 | % DOCUMENT BODY 28 | %------------------------------------------------------------------------------- 29 | 30 | \begin{document} 31 | 32 | \begin{frame}[plain] 33 | \titlepage % Print the title page as the first slide 34 | \end{frame} 35 | 36 | \begin{frame}{Where We Stand, What We Face?} 37 | 38 | We now have an algorithm \textsc{Simplex} (\textit{Restricted}), 39 | which is conjectured to solve linear programs. For the time being 40 | we've shown that it terminates either by specifying that we have an 41 | unbounded linear program, or by returning a finite value 42 | \textit{expected} to be the maximum we are looking for. 43 | 44 | Uptill now, we've been working under the following two assumptions : 45 | \begin{itemize} 46 | \item 47 | Our linear program is \emph{feasible} ; meaning that it has at 48 | least one feasible solution 49 | \item 50 | The basic solution of the initial slack form is feasible. 51 | \end{itemize} 52 | 53 | \pause 54 | During this lecture, we are going to build a function 55 | \mintinline{python}{init_simplex} taking in a linear program 56 | $(\bs{A}, \bs{b}, \bs{c}, \nu)$ and either returning back the fact 57 | it is \emph{not} feasible or a linear program 58 | $(N, B, \underline{\bs{A}}, \underline{\bs{b}}, \underline{\bs{c}}, 59 | \nu)$ in slack form having feasible basic solution. 60 | \end{frame} 61 | 62 | \section{Feasibility} 63 | 64 | \begin{frame}{Deciding On Feasibility} 65 | \begin{columns}[T] 66 | \begin{column}{.5\textwidth} 67 | Let $L$ be the linear program, given in standard form: 68 | \begin{figure} 69 | \begin{linearProgG}{ 70 | ${\displaystyle z = \nu + \sum_{j=1}^n c_jx_j}$ 71 | }{ 72 | ${\displaystyle \forall i \in \{1, \ldots, m\}, \quad \sum_{j=1}^n a_{ij}x_j \leq b_i}$ 73 | }{ 74 | $\forall j \in N, \quad x_j \geq 0$ 75 | } 76 | \end{linearProgG} 77 | \end{figure} 78 | \end{column} 79 | \begin{column}{.58\textwidth} 80 | \pause 81 | \begin{tcolorbox}[ 82 | enhanced, 83 | parbox = true, 84 | colback = mLightBrown!30!white, 85 | colframe = mLightBrown!30!white, 86 | arc = 0mm, 87 | ] 88 | Out of $L$ we build the following auxiliary linear program $L_{m}$: 89 | \vspace{-1em} 90 | \begin{figure} 91 | \begin{linearProgG}{ 92 | ${\displaystyle z = - x_0}$ 93 | }{ 94 | ${\displaystyle \forall i \in \{1, \ldots, m\}, \quad \sum_{j=1}^n a_{ij}x_j - x_0\leq b_i}$ 95 | }{ 96 | $\forall j \in N\cup \{0\}, \quad x_j \geq 0$ 97 | } 98 | \end{linearProgG} 99 | \end{figure} 100 | \end{tcolorbox} 101 | \end{column} 102 | \end{columns} 103 | \end{frame} 104 | 105 | \begin{frame}{Deciding On Feasibility} 106 | \begin{prop} 107 | $L$ is feasible if, and only if, the optimal objective value of 108 | $L_{m}$ is $0$. 109 | \end{prop} 110 | \begin{overlayarea}{\textwidth}{.8\textheight} 111 | \vspace{.2\baselineskip} 112 | \begin{onlyenv}<2-4> 113 | \setlength\columnseprule{.1pt} 114 | \begin{multicols}{2} 115 | \begin{demo} 116 | Notice first that the optimal objective value of 117 | $L_{m}$ is $0$. Therefore, if we show that $0$ is an 118 | objective value of $L_{m}$ it is necessarily the 119 | optimal one.\pause[3] 120 | 121 | If $L$ is feasible then there is a tuple 122 | $(t_1, \ldots, t_n)$ of non-negative real numbers satisfying 123 | all linear constraints of $L$. The tuple 124 | $(0, t_1, \ldots, t_n)$ does thus satisfy $L_{m}$ and 125 | $0$ is then an objective value of $L_{m}$, i.e. the 126 | optimal one.\pause[4] 127 | 128 | Conversely, if $L_{m}$ has objective value $0$ (thus 129 | optimal) it is of the form $(0, t_1, \ldots, t_n)$. Plugging 130 | this tuple in the linear constraints of $L_{m}$ it 131 | implies $(t_1, \ldots, t_n)$ is a solution of $L$. 132 | \end{demo} 133 | \end{multicols} 134 | \end{onlyenv} 135 | \begin{onlyenv}<5> 136 | The difference between $L$ and $L_{m}$ is that $L_{m}$ is always feasible : 137 | \begin{center} 138 | \begin{minipage}{.7\textwidth} 139 | \begin{tcolorbox}[ 140 | enhanced, 141 | parbox = true, 142 | colback = mLightBrown!30!white, 143 | colframe = mLightBrown!30!white, 144 | arc = 0mm, 145 | ] 146 | If $b_{min}$ is the smallest negative $b_i$ for 147 | $i \in B$, the tuple $(-b_{min}, 0, \ldots, 0)$ is a 148 | feasible solution of $L_{m}$. 149 | \end{tcolorbox} 150 | \end{minipage} 151 | \end{center} 152 | Thus, temporarily admitting validity of the 153 | \textit{restricted} simplex algorithm, if we're able to find a 154 | linear program equivalent to $L_{m}$ which has \alert{feasible 155 | basic solution} then we can decide on the feasibilty of $L$. 156 | \end{onlyenv} 157 | \end{overlayarea} 158 | \end{frame} 159 | 160 | \begin{frame}{Deciding On Feasibility} 161 | \setlength\columnseprule{.1pt} 162 | \begin{multicols}{2} 163 | Consider the slack form of $L_{m}$ 164 | \begin{figure} 165 | \begin{linearProgG}{ 166 | ${\displaystyle z = -x_0}$ 167 | }{ 168 | ${\displaystyle \forall i \quad x_{i + m} + \sum_{j=1}^n a_{ij}x_j - x_0 = b_i}$ 169 | }{ 170 | $\forall j \in N\cup B \cup\{0 \}, \quad x_j \geq 0$ 171 | } 172 | \end{linearProgG} 173 | \end{figure} 174 | \pause 175 | Basic solution of $L_{m}$ is not feasible as soon as $L$ is 176 | not, i.e. as soon as a $b_i$ is negative. \alert{\textbf{We 177 | assume this is the case}}. 178 | 179 | \pause 180 | Let $b_{min}$ be the minimal $b_i$ coefficient. We already 181 | know that 182 | $(-b_{min}, 0, \ldots, 0, \bs{b} - b_{min})$ 183 | is a feasible solution of 184 | $L_{m}$. 185 | 186 | \pause 187 | Let's now use \mintinline{python}{pivot} with entering 188 | variable $0$ and leaving one $min$. The \alert{\textbf{same}} 189 | previous feasible solution of $L_{m}$ is now the basic 190 | solution of the linear program we got after pivoting. 191 | \vspace{.5\baselineskip} 192 | 193 | \pause 194 | \textbf{We got an equivalent linear program to $\bs{L_{m}}$ 195 | having feasible basic solution !} 196 | \end{multicols} 197 | \end{frame} 198 | 199 | \begin{frame} 200 | \frametitle{Tableau of Auxiliary Linear Program} 201 | The tableau \mintinline{python}{T_m} of $L_m$ is obtained out of the 202 | one for $L$ (\mintinline{python}{T}) by adding column 203 | $(-1, 1, \ldots, 1)^T$ to tableau before column $\bs{b}^T$ and 204 | putting old coefficients of first row to $0$. 205 | \begin{figure} 206 | \begin{tabular}{c|ccc|ccccc|c|} 207 | & \alert{$\bs{x_1}$} & \alert{$\cdots$} & \alert{$\bs{x_n}$} & \alert{$\bs{x_{n+1}}$} & \alert{$\bs{x_{n+2}}$} & \alert{$\cdots$} & \alert{$\bs{x_{n+m}}$} & \alert{$\bs{x_0}$} & \\ 208 | \hline 209 | & $0$ & $\cdots$ & $0$ & $0$ & $0$ & $\cdots$ & $0$ & $1$ & $0$ \\ 210 | \hline 211 | \alert{$\bs{n+1}$} & $a_{11}$ & $\cdots$ & $a_{1n}$ & $1$ & $0$ & $\cdots$ & $0$ & $-1$ & $b_1$ \\ 212 | \alert{$\bs{n+2}$}& $a_{21}$ & $\cdots$ & $a_{2n}$ & $0$ & $1$ & $\cdots$ & $0$ & $-1$ & $b_2$ \\ 213 | \alert{$\vdots$}& $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$ & $\vdots$ & $\ddots$ & $\vdots$ & $\vdots$ & $\vdots$ \\ 214 | \alert{$\bs{n+m}$} & $a_{m1}$ & $\cdots$ & $a_{mn}$ & $0$ & $\cdots$ & $\cdots$ & $1$ & $-1$ & $b_m$ 215 | \end{tabular} 216 | \end{figure} 217 | \end{frame} 218 | 219 | \begin{frame}[fragile]{Testing Feasibility} 220 | \begin{overlayarea}{1.05\textwidth}{.6\textheight} 221 | \setlength\columnseprule{.1pt} 222 | \begin{multicols}{2} 223 | \scriptsize{ 224 | \begin{minted}[autogobble, linenos, breaklines]{python} 225 | def is_feasible(N, B, T): 226 | """Testing feasibility of linear program. 227 | 228 | Args: 229 | N, B (list[int]): lists of non-basic and 230 | basic variables. 231 | T (ndarray[float]): numpy array for 232 | tableau of linear program. 233 | Output: 234 | (bool) True if program is feasible 235 | False otherwise. 236 | """ 237 | p, q = T.shape[0], T.shape[1] 238 | c = T[0, :] 239 | T[0, :] = [0]*q 240 | new_c = np.array([1] + [-1]*(p-1), dtype=float) 241 | T = np.insert(T, -1, new_c, axis=1) 242 | N.append(0) 243 | # pivoting to be basic feasible 244 | i_min = np.argmin(T[1: ,-1]) 245 | pivot(N, B, T, i_min, 0) 246 | V = _simplex(N, B, T) 247 | return math.isclose(V[0], 0) 248 | # Possibly slightly modifying the 249 | # optimisation problem ... 250 | \end{minted} 251 | } 252 | \end{multicols} 253 | \end{overlayarea} 254 | \pause 255 | \begin{tcolorbox}[ 256 | enhanced, 257 | parbox = false, 258 | colback = mLightBrown!30!white, 259 | colframe = mLightBrown!30!white, 260 | arc = 0mm, 261 | ] 262 | Not an equivalent LP to L there! Need to understand boundary effects. 263 | \end{tcolorbox} 264 | \end{frame} 265 | 266 | \section{Get A Feasible Basic Solution} 267 | 268 | \begin{frame}{Getting a Feasible Basic Solution} 269 | \begin{halfshyblock}{Assumption} 270 | We assume \mintinline{python}{is_feasible(N, B, T)} returns 271 | \mintinline{python}{True}. 272 | \end{halfshyblock} 273 | \vspace{.5\baselineskip} 274 | \begin{overlayarea}{\textwidth}{.6\textheight} 275 | \begin{onlyenv}<2> 276 | Under the previous assumption \mintinline{python}{is_feasible} 277 | transforms $L_m$ into an equivalent linear program $P$ which has 278 | feasible basic solution with objective value $0$. 279 | \end{onlyenv} 280 | \begin{onlyenv}<3-> 281 | \begin{itemize} 282 | \item<3-> Replace the objective value of $P$ with the original one of $L$. 283 | \item<4-> Make of it a proper LP $Q$ in slack form by replacing 284 | possible basic variables of the objective value with their 285 | expressions in terms of non-basic variables of $P$. 286 | \item<5-> Ensure $x_0$ is no more a basic variable $Q$ by 287 | pivoting with leaving variable $0$ and entering one any 288 | variable having non-zero coefficient. 289 | \end{itemize} 290 | \pause[6] 291 | \vspace{.5\baselineskip} 292 | \begin{halfshyblock}{Fact} 293 | Putting $x_0$ to $0$ in $Q$ gives back an equivalent LP to $L$ 294 | having feasible basic solution. 295 | \end{halfshyblock} 296 | \end{onlyenv} 297 | \end{overlayarea} 298 | \end{frame} 299 | 300 | \begin{frame}[fragile]{The \mintinline{python}{is_feasible} function} 301 | \begin{overlayarea}{1.05\textwidth}{.75\textheight} 302 | \setlength\columnseprule{.1pt} 303 | \begin{multicols}{2} 304 | \scriptsize{ 305 | \begin{minted}[autogobble, linenos, breaklines]{python} 306 | def is_feasible(N, B, T): 307 | """Testing feasibility of linear program. 308 | 309 | Args: 310 | N, B (list[int]): lists of non-basic and 311 | basic variables. 312 | T (ndarray[float]): numpy array for 313 | tableau of linear program. 314 | Output: 315 | (bool) True if program is feasible 316 | False otherwise. 317 | Boundary effect: 318 | Transforms T into an equivalent LP having 319 | basic feasible solution if T is feasible. 320 | """ 321 | p, q = T.shape[0], T.shape[1] 322 | c = T[0, :] 323 | T[0, :] = [0]*q 324 | new_c = np.array([1] + [-1]*(p-1), dtype=float) 325 | T = np.insert(T, -1, new_c, axis=1) 326 | N.append(0) 327 | # pivoting to be basic feasible 328 | i_min = np.argmin(T[1: ,-1]) 329 | pivot(N, B, T, i_min, 0) 330 | V = _simplex(N, B, T) 331 | if 0 in B: 332 | l, e = B.index(0), 0 333 | while T[l, e] == 0 or e == l: 334 | e += 1 335 | pivot(N, B, T, l, e) 336 | for i in B: 337 | c -= c[i]*T[B.index(i), :] 338 | T[0, :] = c 339 | return math.isclose(V[0], 0) 340 | # Possibly slightly modifying the 341 | # optimisation problem ... 342 | \end{minted} 343 | } 344 | \end{multicols} 345 | \end{overlayarea} 346 | \end{frame} 347 | 348 | \begin{frame}{Where We Stand?} 349 | We are now able to 350 | \begin{itemize} 351 | \item<1-> 352 | know whether a linear program is feasible or not using 353 | \mintinline{python}{is_feasible} 354 | \item<2-> 355 | if it is feasible we can build up an equivalent linear program 356 | which has feasible basic solution using boundary effect of 357 | \mintinline{python}{is_feasible} 358 | \item<3-> 359 | once we get a linear program having feasible basic solution we can 360 | check whether our linear program is unbounded or has a 361 | \textit{hopefully} optimal finite solution using the 362 | \textit{restricted} \mintinline{python}{_simplex}. 363 | \end{itemize} 364 | \pause[4] 365 | We are left with showing validity of \textit{restricted} 366 | \mintinline{python}{_simplex}! 367 | \begin{tcolorbox}[ 368 | enhanced, 369 | parbox = false, 370 | colback = mLightBrown!30!white, 371 | colframe = mLightBrown!30!white, 372 | arc = 0mm, 373 | ] 374 | We call \mintinline{python}{simplex} the algorithm globally going 375 | through all previous steps. 376 | \end{tcolorbox} 377 | \end{frame} 378 | 379 | \begin{frame} 380 | \centering 381 | {\huge \textbf{That's it for today !}} 382 | \end{frame} 383 | 384 | \end{document} 385 | 386 | %%% Local Variables: 387 | %%% mode: latex 388 | %%% TeX-master: t 389 | %%% End: 390 | -------------------------------------------------------------------------------- /Python/linprog_for_dummies.ipynb: -------------------------------------------------------------------------------- 1 | { 2 | "cells": [ 3 | { 4 | "cell_type": "markdown", 5 | "metadata": { 6 | "collapsed": true 7 | }, 8 | "source": [ 9 | "# A quick readme for linprog module" 10 | ] 11 | }, 12 | { 13 | "cell_type": "markdown", 14 | "metadata": {}, 15 | "source": [ 16 | "This is a very short readme containing elementary usage of local module linprog. The module linprog is an implementation of the simplex algorithm for linear programs having rational coefficients. The point is to avoid having to deal with floats and subsequent issues related to testing feasibility. We made the choice of sticking to the point of view presented in related course. \n", 17 | "\n", 18 | "**This implementation is aimed at students following a first course on linear programming, it's not advised to use it professionally as it is certainly not optimized.** " 19 | ] 20 | }, 21 | { 22 | "cell_type": "code", 23 | "execution_count": 1, 24 | "metadata": { 25 | "collapsed": true 26 | }, 27 | "outputs": [], 28 | "source": [ 29 | "import numpy as np\n", 30 | "import fractions as frac" 31 | ] 32 | }, 33 | { 34 | "cell_type": "markdown", 35 | "metadata": { 36 | "collapsed": true 37 | }, 38 | "source": [ 39 | "If your python is well configured, this notebook sees linprog. One can import it simply typing " 40 | ] 41 | }, 42 | { 43 | "cell_type": "code", 44 | "execution_count": 2, 45 | "metadata": {}, 46 | "outputs": [], 47 | "source": [ 48 | "from linprog import linprogs as lp, simplex as spx" 49 | ] 50 | }, 51 | { 52 | "cell_type": "markdown", 53 | "metadata": {}, 54 | "source": [ 55 | "Linear program constructor takes in three parameters as numpy arrays, all upcoming definitions need the linear program to be in *standard* form: \n", 56 | "- Second is the set of constants appearing in the program's constraints.\n", 57 | "- First is the matrix corresponding to non-constant terms.\n", 58 | "- Lastly the objectve function. \n", 59 | "The constant term of the objective is by default at zero, one can specify it as fourth argument if needed.\n", 60 | "\n", 61 | "The following entries correspond to a linear program having feasible basic solution. " 62 | ] 63 | }, 64 | { 65 | "cell_type": "code", 66 | "execution_count": 3, 67 | "metadata": {}, 68 | "outputs": [], 69 | "source": [ 70 | "a = np.array([[frac.Fraction(2, 1), frac.Fraction(-1, 1), frac.Fraction(2, 1)],\n", 71 | " [frac.Fraction(2, 1), frac.Fraction(-4, 1), frac.Fraction(0, 1)],\n", 72 | " [frac.Fraction(-4, 1), frac.Fraction(3, 1), frac.Fraction(8, 1)]])\n", 73 | "b = np.array([[frac.Fraction(7, 1)], [frac.Fraction(12, 1)], [frac.Fraction(10, 1)]])\n", 74 | "c = np.array([frac.Fraction(2, 1), frac.Fraction(1, 1) , frac.Fraction(1, 1)])" 75 | ] 76 | }, 77 | { 78 | "cell_type": "code", 79 | "execution_count": 4, 80 | "metadata": {}, 81 | "outputs": [ 82 | { 83 | "data": { 84 | "text/plain": [ 85 | "(3, 3)" 86 | ] 87 | }, 88 | "execution_count": 4, 89 | "metadata": {}, 90 | "output_type": "execute_result" 91 | } 92 | ], 93 | "source": [ 94 | "a.shape" 95 | ] 96 | }, 97 | { 98 | "cell_type": "code", 99 | "execution_count": 5, 100 | "metadata": {}, 101 | "outputs": [ 102 | { 103 | "data": { 104 | "text/plain": [ 105 | "(3, 1)" 106 | ] 107 | }, 108 | "execution_count": 5, 109 | "metadata": {}, 110 | "output_type": "execute_result" 111 | } 112 | ], 113 | "source": [ 114 | "b.shape" 115 | ] 116 | }, 117 | { 118 | "cell_type": "code", 119 | "execution_count": 6, 120 | "metadata": {}, 121 | "outputs": [ 122 | { 123 | "data": { 124 | "text/plain": [ 125 | "(3,)" 126 | ] 127 | }, 128 | "execution_count": 6, 129 | "metadata": {}, 130 | "output_type": "execute_result" 131 | } 132 | ], 133 | "source": [ 134 | "c.shape" 135 | ] 136 | }, 137 | { 138 | "cell_type": "code", 139 | "execution_count": 7, 140 | "metadata": { 141 | "collapsed": true 142 | }, 143 | "outputs": [], 144 | "source": [ 145 | "lProgram = lp.LinearProgram(a, b, c)" 146 | ] 147 | }, 148 | { 149 | "cell_type": "markdown", 150 | "metadata": {}, 151 | "source": [ 152 | "lProgram has three attributes:\n", 153 | "\n", 154 | "- basic : it corresponds to the basic set;\n", 155 | "- shape : it correspond to the couple (number of lines, number of columns) of the linear program in *slack* form;\n", 156 | "- table : it's a matrix having representing *minus* the objective function in first row, the set of constants as last column with objective value at head and lastly the programs matrix from second row on and till the column before the last. This is commonly called a **tableau** in linear programming jargon.\n", 157 | "\n", 158 | "You are free to play with each one of them" 159 | ] 160 | }, 161 | { 162 | "cell_type": "code", 163 | "execution_count": 8, 164 | "metadata": {}, 165 | "outputs": [ 166 | { 167 | "data": { 168 | "text/plain": [ 169 | "[3, 4, 5]" 170 | ] 171 | }, 172 | "execution_count": 8, 173 | "metadata": {}, 174 | "output_type": "execute_result" 175 | } 176 | ], 177 | "source": [ 178 | "lProgram.basic" 179 | ] 180 | }, 181 | { 182 | "cell_type": "code", 183 | "execution_count": 9, 184 | "metadata": {}, 185 | "outputs": [ 186 | { 187 | "data": { 188 | "text/plain": [ 189 | "(3, 6)" 190 | ] 191 | }, 192 | "execution_count": 9, 193 | "metadata": {}, 194 | "output_type": "execute_result" 195 | } 196 | ], 197 | "source": [ 198 | "lProgram.shape" 199 | ] 200 | }, 201 | { 202 | "cell_type": "markdown", 203 | "metadata": {}, 204 | "source": [ 205 | "In order to have a closely to nice print of lProgram linprogs contains a quick formatting method." 206 | ] 207 | }, 208 | { 209 | "cell_type": "code", 210 | "execution_count": 10, 211 | "metadata": {}, 212 | "outputs": [ 213 | { 214 | "name": "stdout", 215 | "output_type": "stream", 216 | "text": [ 217 | " -2 -1 -1 0 0 0 0 \n", 218 | "\n", 219 | "3 | 2 -1 2 1 0 0 7 \n", 220 | "4 | 2 -4 0 0 1 0 12 \n", 221 | "5 | -4 3 8 0 0 1 10 \n", 222 | "\n" 223 | ] 224 | } 225 | ], 226 | "source": [ 227 | "print(lProgram)" 228 | ] 229 | }, 230 | { 231 | "cell_type": "markdown", 232 | "metadata": {}, 233 | "source": [ 234 | "On the let hand one sees the index in the basic set corresponding to each line. \n", 235 | "\n", 236 | "Now the **class** LinearProgram has a number of methods: has_feasible_basic, basic_solution, pivot and dual. As you can imagine, pivot takes in a couple corresponding to entering and leaving indices of the linear program, they are respectively composed of an index of column (starting at 0) and one of row (also starting at 0 at the first row of the **matrix** of constraints). It is called within the simplex algorithm.\n", 237 | "\n", 238 | "Here is an example of using the first two methods. " 239 | ] 240 | }, 241 | { 242 | "cell_type": "code", 243 | "execution_count": 11, 244 | "metadata": {}, 245 | "outputs": [ 246 | { 247 | "data": { 248 | "text/plain": [ 249 | "True" 250 | ] 251 | }, 252 | "execution_count": 11, 253 | "metadata": {}, 254 | "output_type": "execute_result" 255 | } 256 | ], 257 | "source": [ 258 | "lProgram.has_feasible_basic()" 259 | ] 260 | }, 261 | { 262 | "cell_type": "code", 263 | "execution_count": 12, 264 | "metadata": {}, 265 | "outputs": [ 266 | { 267 | "data": { 268 | "text/plain": [ 269 | "array([0, 0, 0, Fraction(7, 1), Fraction(12, 1), Fraction(10, 1)], dtype=object)" 270 | ] 271 | }, 272 | "execution_count": 12, 273 | "metadata": {}, 274 | "output_type": "execute_result" 275 | } 276 | ], 277 | "source": [ 278 | "lProgram.basic_solution()" 279 | ] 280 | }, 281 | { 282 | "cell_type": "markdown", 283 | "metadata": {}, 284 | "source": [ 285 | "To build an instance of the simplex algorithm here is the thing to do:" 286 | ] 287 | }, 288 | { 289 | "cell_type": "code", 290 | "execution_count": 13, 291 | "metadata": { 292 | "collapsed": true 293 | }, 294 | "outputs": [], 295 | "source": [ 296 | "simplex = spx.Simplex()" 297 | ] 298 | }, 299 | { 300 | "cell_type": "markdown", 301 | "metadata": {}, 302 | "source": [ 303 | "There are two optional parameters, leaving_index and entering_index. Both correspond to functions respectively computing leaving and entering variables. By default they correspond to first maximal choice for the entering one and first minimal choice for the leaving one. \n", 304 | "\n", 305 | "Instances of Simplex **class** are *callable* and take in this case an extra parameter (by default set at 100) for the recursion limit. " 306 | ] 307 | }, 308 | { 309 | "cell_type": "code", 310 | "execution_count": 14, 311 | "metadata": {}, 312 | "outputs": [ 313 | { 314 | "name": "stdout", 315 | "output_type": "stream", 316 | "text": [ 317 | " ### Checking feasibility of linear program\n", 318 | "\n", 319 | " -2 -1 -1 0 0 0 0 \n", 320 | "\n", 321 | "3 | 2 -1 2 1 0 0 7 \n", 322 | "4 | 2 -4 0 0 1 0 12 \n", 323 | "5 | -4 3 8 0 0 1 10 \n", 324 | "\n", 325 | " ### Input linear program has feasible basic solution\n", 326 | "\n", 327 | " ### Getting back to linear program equivalent to input with feasible basic solution\n", 328 | "\n", 329 | "Basic solution = (31/2, 24, 0, 0, 77, 0) with objective value = 55.\n", 330 | "\n" 331 | ] 332 | }, 333 | { 334 | "data": { 335 | "text/plain": [ 336 | "(array([Fraction(31, 2), Fraction(24, 1), 0, 0, Fraction(77, 1), 0], dtype=object),\n", 337 | " Fraction(55, 1))" 338 | ] 339 | }, 340 | "execution_count": 14, 341 | "metadata": {}, 342 | "output_type": "execute_result" 343 | } 344 | ], 345 | "source": [ 346 | "simplex(lProgram)" 347 | ] 348 | }, 349 | { 350 | "cell_type": "markdown", 351 | "metadata": {}, 352 | "source": [ 353 | "Here is a last example in the case of linear program not having a feasible basic solution. It is the example we've started with during the course on *voters*. " 354 | ] 355 | }, 356 | { 357 | "cell_type": "code", 358 | "execution_count": 31, 359 | "metadata": {}, 360 | "outputs": [], 361 | "source": [ 362 | "A = np.array([[frac.Fraction(2, 1), frac.Fraction(-8, 1), frac.Fraction(0, 1), frac.Fraction(-10, 1)],\n", 363 | " [frac.Fraction(-5, 1), frac.Fraction(-2, 1), frac.Fraction(0, 1), frac.Fraction(0, 1)],\n", 364 | " [frac.Fraction(-3, 1), frac.Fraction(5, 1), frac.Fraction(-10, 1), frac.Fraction(2, 1)]])\n", 365 | "B = np.array([[frac.Fraction(-50, 1)], [frac.Fraction(-100, 1)], [frac.Fraction(-25, 1)]])\n", 366 | "C = np.array([frac.Fraction(-1, 1), frac.Fraction(-1, 1) , frac.Fraction(-1, 1), frac.Fraction(-1, 1)])" 367 | ] 368 | }, 369 | { 370 | "cell_type": "code", 371 | "execution_count": 32, 372 | "metadata": {}, 373 | "outputs": [], 374 | "source": [ 375 | "mProgram = lp.LinearProgram(A, B, C)" 376 | ] 377 | }, 378 | { 379 | "cell_type": "code", 380 | "execution_count": 33, 381 | "metadata": {}, 382 | "outputs": [ 383 | { 384 | "name": "stdout", 385 | "output_type": "stream", 386 | "text": [ 387 | " 1 1 1 1 0 0 0 0 \n", 388 | "\n", 389 | "4 | 2 -8 0 -10 1 0 0 -50 \n", 390 | "5 | -5 -2 0 0 0 1 0 -100 \n", 391 | "6 | -3 5 -10 2 0 0 1 -25 \n", 392 | "\n" 393 | ] 394 | } 395 | ], 396 | "source": [ 397 | "print(mProgram)" 398 | ] 399 | }, 400 | { 401 | "cell_type": "code", 402 | "execution_count": 34, 403 | "metadata": {}, 404 | "outputs": [ 405 | { 406 | "data": { 407 | "text/plain": [ 408 | "array([0, 0, 0, 0, Fraction(-50, 1), Fraction(-100, 1), Fraction(-25, 1)], dtype=object)" 409 | ] 410 | }, 411 | "execution_count": 34, 412 | "metadata": {}, 413 | "output_type": "execute_result" 414 | } 415 | ], 416 | "source": [ 417 | "mProgram.basic_solution()" 418 | ] 419 | }, 420 | { 421 | "cell_type": "code", 422 | "execution_count": 35, 423 | "metadata": {}, 424 | "outputs": [ 425 | { 426 | "name": "stdout", 427 | "output_type": "stream", 428 | "text": [ 429 | " ### Checking feasibility of linear program\n", 430 | "\n", 431 | " 1 1 1 1 0 0 0 0 \n", 432 | "\n", 433 | "4 | 2 -8 0 -10 1 0 0 -50 \n", 434 | "5 | -5 -2 0 0 0 1 0 -100 \n", 435 | "6 | -3 5 -10 2 0 0 1 -25 \n", 436 | "\n", 437 | " ### Basic solution is not feasible: using auxiliary linear program in next step\n", 438 | "\n", 439 | "Basic solution = (0, 20, 0, 0, 9, 0, 0, 17) with objective value = 0.\n", 440 | "\n", 441 | " ### Input linear program is thus feasible\n", 442 | "\n", 443 | " ### Getting back to linear program equivalent to input with feasible basic solution\n", 444 | "\n", 445 | "Basic solution = (2050/111, 425/111, 0, 625/111, 0, 0, 0) with objective value = 3338/111.\n", 446 | "\n" 447 | ] 448 | }, 449 | { 450 | "data": { 451 | "text/plain": [ 452 | "(array([Fraction(2050, 111), Fraction(425, 111), 0, Fraction(625, 111), 0,\n", 453 | " 0, 0], dtype=object), Fraction(3338, 111))" 454 | ] 455 | }, 456 | "execution_count": 35, 457 | "metadata": {}, 458 | "output_type": "execute_result" 459 | } 460 | ], 461 | "source": [ 462 | "simplex(mProgram)" 463 | ] 464 | }, 465 | { 466 | "cell_type": "code", 467 | "execution_count": 36, 468 | "metadata": {}, 469 | "outputs": [ 470 | { 471 | "data": { 472 | "text/plain": [ 473 | "30.07207207207207" 474 | ] 475 | }, 476 | "execution_count": 36, 477 | "metadata": {}, 478 | "output_type": "execute_result" 479 | } 480 | ], 481 | "source": [ 482 | "float(frac.Fraction(3338, 111))" 483 | ] 484 | }, 485 | { 486 | "cell_type": "markdown", 487 | "metadata": { 488 | "collapsed": true 489 | }, 490 | "source": [ 491 | "It would have been hard to guess. Those who managed to find that 27 corresponded to a feasible solution were the closest. Know that 29 also corresponds to a feasible solution. " 492 | ] 493 | } 494 | ], 495 | "metadata": { 496 | "kernelspec": { 497 | "display_name": "Python 3", 498 | "language": "python", 499 | "name": "python3" 500 | }, 501 | "language_info": { 502 | "codemirror_mode": { 503 | "name": "ipython", 504 | "version": 3 505 | }, 506 | "file_extension": ".py", 507 | "mimetype": "text/x-python", 508 | "name": "python", 509 | "nbconvert_exporter": "python", 510 | "pygments_lexer": "ipython3", 511 | "version": "3.5.2" 512 | } 513 | }, 514 | "nbformat": 4, 515 | "nbformat_minor": 1 516 | } 517 | --------------------------------------------------------------------------------