diff options
author | Karl Berry <karl@freefriends.org> | 2016-06-09 22:53:41 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-06-09 22:53:41 +0000 |
commit | 96152b37515359e17b9cbe19a6186cec57a15eda (patch) | |
tree | 9ea18ed768318e1e1316d77b9940eabde64895cc /Master/texmf-dist/tex | |
parent | 630a0032b5287429446b8ed9f02af719e9aa563e (diff) |
optidef (8jun16)
git-svn-id: svn://tug.org/texlive/trunk@41330 c570f23f-e606-0410-a88d-b1316a301751
Diffstat (limited to 'Master/texmf-dist/tex')
-rw-r--r-- | Master/texmf-dist/tex/latex/optidef/optidef.sty | 383 |
1 files changed, 383 insertions, 0 deletions
diff --git a/Master/texmf-dist/tex/latex/optidef/optidef.sty b/Master/texmf-dist/tex/latex/optidef/optidef.sty new file mode 100644 index 00000000000..47addfa92dc --- /dev/null +++ b/Master/texmf-dist/tex/latex/optidef/optidef.sty @@ -0,0 +1,383 @@ +% optidef - Version 08/06/2016 +% +%Copyright 2016 J. Lago Garcia +% +%This work may be distributed and/or modified under the conditions of the LaTeX Project Public License, either version 1.3 of this license or (at your option) any later version. +%The latest version of this license is in http://www.latex-project.org/lppl.txt and version 1.3 or later is part of all distributions of LaTeX version 2005/12/01 or later. +% +%This work has the LPPL maintenance status 'maintained'. The Current Maintainer of this work is J. Lago Garcia, under the supervision of Prof. Dr. Moritz Diehl and Prof. Dr. Sebastien Gross. +% +%E-mail: jesus.lago.garcia@venus.uni-freiburg.de +% +%This work consists of the file optidef.sty. + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{optidef}[2016/06/06 Package for defining optimization problems] + +\RequirePackage{environ} +\RequirePackage{mathtools} +\RequirePackage{xifthen} + + % Input minimization evironments + + % Macros for objective definition, constraint definition and extra constraint definition + \newcommand{\bodyobj}[4] + { + \ifthenelse{\isempty{#4}} + { + &\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span + } + { + #4 ~~ &\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span + } + } + + + \newcommand{\bodyconst}[2] + {&\mbox{subject to} \quad  & #2\span\span} + + \newcommand{\addConstraint}[2]{&\quad  & #2, \\} + \newcommand{\finalConstraint}[2]{&\quad  & #2} + + + %\newcommand(\breakObjectiveUnconstraint)[1]{\\% + %\bodyobjUn{}{#1}{\phantom{minimize}}{}} + \newcommand{\breakObjectiveOneConstraint}[1]{&&\\} + %\newcommand(\breakObjective)[1]{\bodyobj{}{#4}{\phantom{minimize}}{}\nonumber\\} } + + \newcommand{\bodyconstOne}[2] + {&\text{subject to} \quad & #2} + + % This body of the objective is only valid for + % one constraint problem since there is no need to + % use mathllap to achieve second alignment level + \newcommand{\bodyobjOne}[4] + { + \ifthenelse{\isempty{#4}} + { + &\underset{\displaystyle #1}{\text{#3}} \quad & + } + { + #4 ~~ &\underset{\displaystyle #1}{\text{#3}} \quad &} + } + + + % This body of the objective is only valid for + % no constraint problem since there is no need to + % align + \newcommand{\bodyobjUn}[4] + { + \ifthenelse{\isempty{#4}} + { + } + { + #4~ + } + \underset{\displaystyle #1}{\text{#3}} \quad #2 + } + + %MINIMIZATION ENVIRONMENTS + + \NewEnviron{mini}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation} + #6 + \bodyobjUn{#2}{#3}{minimize}{#7} + \end{equation} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{equation} + #6 + \begin{alignedat}{3} + \bodyobjOne{#2}{#3}{minimize}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignedat} + \end{equation} + }% + {% + \begin{equation} + #6 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{minimize}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignedat} + \end{equation} + }% + }% + } + + \NewEnviron{argmini}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation} + #6 + \bodyobjUn{#2}{#3}{arg min}{#7} + \end{equation} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{equation} + #6 + \begin{alignedat}{3} + \bodyobjOne{#2}{#3}{arg min}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignedat} + \end{equation} + }% + {% + \begin{equation} + #6 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{arg min}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignedat} + \end{equation} + }% + }% + } + + \NewEnviron{mini*}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation*} + \bodyobjUn{#2}{#3}{minimize}{#7} + \end{equation*} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{alignat*}{3} + \bodyobjOne{#2}{#3}{minimize}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat*} + }% + {% + \begin{alignat*}{5} + \bodyobj{#2}{#3}{minimize}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat*} + }% + }% + } + + \NewEnviron{argmini*}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation*} + \bodyobjUn{#2}{#3}{arg min}{#7} + \end{equation*} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{alignat*}{3} + \bodyobjOne{#2}{#3}{arg min}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat*} + }% + {% + \begin{alignat*}{4} + \bodyobj{#2}{#3}{arg min}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat*} + }% + }% + } + + + \NewEnviron{mini!}[7]{% + \ifthenelse{\equal{#1}{1}}{% + \begin{subequations} + #6 + \begin{alignat}{3} + \bodyobjOne{#2}{#3}{minimize}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat} + \end{subequations} + }% + {% + \begin{subequations} + #6 + \begin{alignat}{4} + \bodyobj{#2}{#3}{minimize}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat} + \end{subequations} + }% + } + + \NewEnviron{argmini!}[7]{% + \ifthenelse{\equal{#1}{1}}{% + \begin{subequations} + #6 + \begin{alignat}{3} + \bodyobjOne{#2}{#3}{arg min}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat} + \end{subequations} + }% + {% + \begin{subequations} + #6 + \begin{alignat}{4} + \bodyobj{#2}{#3}{arg min}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat} + \end{subequations} + }% + } + + %MAXIMIZATION ENVIRONMENTS + + \NewEnviron{maxi}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation} + #6 + \bodyobjUn{#2}{#3}{maximize}{#7} + \end{equation} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{equation} + #6 + \begin{alignedat}{3} + \bodyobjOne{#2}{#3}{maximize}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignedat} + \end{equation} + }% + {% + \begin{equation} + #6 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{maximize}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignedat} + \end{equation} + }% + }% + } + + \NewEnviron{argmaxi}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation} + #6 + \bodyobjUn{#2}{#3}{arg max}{#7} + \end{equation} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{equation} + #6 + \begin{alignedat}{3} + \bodyobjOne{#2}{#3}{arg max}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignedat} + \end{equation} + }% + {% + \begin{equation} + #6 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{arg max}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignedat} + \end{equation} + }% + }% + } + + \NewEnviron{maxi*}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation*} + \bodyobjUn{#2}{#3}{maximize}{#7} + \end{equation*} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{alignat*}{3} + \bodyobjOne{#2}{#3}{maximize}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat*} + }% + {% + \begin{alignat*}{5} + \bodyobj{#2}{#3}{maximize}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat*} + }% + }% + } + + \NewEnviron{argmaxi*}[7]{% + \ifthenelse{\equal{#1}{0}}{% + \begin{equation*} + \bodyobjUn{#2}{#3}{arg max}{#7} + \end{equation*} + }% + {% + \ifthenelse{\equal{#1}{1}}{% + \begin{alignat*}{3} + \bodyobjOne{#2}{#3}{arg max}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat*} + }% + {% + \begin{alignat*}{4} + \bodyobj{#2}{#3}{arg max}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat*} + }% + }% + } + + + \NewEnviron{maxi!}[7]{% + \ifthenelse{\equal{#1}{1}}{% + \begin{subequations} + #6 + \begin{alignat}{3} + \bodyobjOne{#2}{#3}{maximize}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat} + \end{subequations} + }% + {% + \begin{subequations} + #6 + \begin{alignat}{4} + \bodyobj{#2}{#3}{maximize}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat} + \end{subequations} + }% + } + + \NewEnviron{argmaxi!}[7]{% + \ifthenelse{\equal{#1}{1}}{% + \begin{subequations} + #6 + \begin{alignat}{3} + \bodyobjOne{#2}{#3}{arg max}{#7}\\ + \bodyconstOne{#4}{#5} + \end{alignat} + \end{subequations} + }% + {% + \begin{subequations} + #6 + \begin{alignat}{4} + \bodyobj{#2}{#3}{arg max}{#7}\\ + \bodyconst{#4}{#5,} \\ + \BODY + \end{alignat} + \end{subequations} + }% + }
\ No newline at end of file |