diff options
author | Karl Berry <karl@freefriends.org> | 2016-06-10 21:47:45 +0000 |
---|---|---|
committer | Karl Berry <karl@freefriends.org> | 2016-06-10 21:47:45 +0000 |
commit | 66681cce466f39f0fc76a55d7a0b1d9c6142c660 (patch) | |
tree | 8a3827a9997518b00affd8d114863a0073c8c14e | |
parent | 632693bc68c5f9d12b8c4d13428ee05b3e3dba64 (diff) |
optidef (10jun16)
git-svn-id: svn://tug.org/texlive/trunk@41347 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r-- | Master/texmf-dist/doc/latex/optidef/README.md | 60 | ||||
-rw-r--r-- | Master/texmf-dist/doc/latex/optidef/optidef.pdf | bin | 194434 -> 90198 bytes | |||
-rw-r--r-- | Master/texmf-dist/doc/latex/optidef/optidef.tex | 869 | ||||
-rw-r--r-- | Master/texmf-dist/tex/latex/optidef/optidef.sty | 568 |
4 files changed, 612 insertions, 885 deletions
diff --git a/Master/texmf-dist/doc/latex/optidef/README.md b/Master/texmf-dist/doc/latex/optidef/README.md index d45c533de0a..69c9ae4fc04 100644 --- a/Master/texmf-dist/doc/latex/optidef/README.md +++ b/Master/texmf-dist/doc/latex/optidef/README.md @@ -1,30 +1,19 @@ -# optidef - Version 08/06/2016 +# optidef +Optidef is a small library that provides a standard set of environments for writing optimization problems. -Copyright 2016 J. Lago Garcia +## Features: -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. - ----------- -FEATURES -Optidef is a small library that provides a standard set of environments for writing optimization problems. The most important features are: - -- It automatically aligns the problems in three points with an optional fourth: +The most important features are: +- It automatically aligns the problems in the most convenient way allowing even two different output formats: * Beginning of the words "minimize/argmin" and "subject to" - * The objective function and the longest left hand side of the constraints + * Double format for the location of the constraints: either to the right of subject to aligned with the objective function or below subject to. * The $= | > | <$ signs of the constraints. * Optionally, the user can add manually a double align character \&\& to align some common constraints feature. A clear example could be the constraints names, e.g. (boundary constraint) alignment with (dynamic constraint), or the index of the constraints, e.g. in the case of having something like $h(x_k,u_k)\leq 0,\quad k=0,\ldots,N$, align the indexes $k=0,\ldots,N$ across constraint lines. -- It provides an easy interface to define optimization problem for three different reference situations: +- It provides an easy interface to define optimization problem for three different reference situations: * Where no equation is referenced/numbered. * Where the problem is referenced with a single number. * Where each equation has an individual reference. @@ -32,30 +21,26 @@ Optidef is a small library that provides a standard set of environments for writ - It also allows a definition of any optimization problem without a limitless number of constraints. - It defines four types of optimization problems: - * minimize * maximize * arg mini * arg maxi ------- -# Syntax +## Syntax: The syntax to define an optimization problem is given by: - >\begin{mini#} - {Number of constraints} + >\begin{mini#}[Format] {Optimization variable} {Objective function \label{Objective function referece}} - {LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}} {\label{Global referece of Optimization Problem}} {Result of the optimization problem or any expression on the left of the minimize word} - \addConstraint{LHS Constraint 2}{RHS Constraint 2 \label{Reference Constraint 2}} - \addConstraint{LHS Constraint 3}{RHS Constraint 3 \label{Reference Constraint 3}} + \addConstraint{LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}} + \addConstraint{LHS Constraint 2}{RHS Constraint 2 \label{Reference Constraint 2}} . . - \finalConstraint{LHS N} {RHSConstraint N \label{Reference Constraint N}} + \addConstraint{LHS N} {RHSConstraint N \label{Reference Constraint N}} \end{mini#} @@ -65,9 +50,24 @@ where mini# takes any of the following values: - mini! for referencing each equation - mini for referencing with a single label the whole problem. -Notice that only the first three will be really necessary in every definition, nevertheless and for the sake of having homogeneous definitions, we opted for requiring the 7 parameters in every definition and expecting empty parameters definitions, i.e. \{\}, when they are not needed. +Notice that only the first two parameters will be really necessary in every definition, nevertheless and for the sake of having homogeneous definitions, we opted for requiring the 4 parameters in every definition and expecting empty parameters definitions, i.e. \{\}, when they are not needed. -After the definition of this parameters, the environment accepts the definition of an infinite number of constraints. Notice that the last constraint has to be defined using the \finalConstraint command, instead of the \addConstraint. +After the definition of this parameters, the environment accepts the definition of an infinite number of constraints. -Finally note that \begin{mini#} can be substituted by \begin{maxi#}, \begin{argmini#} or \begin{argmaxi#}.
\ No newline at end of file +Finally note that \begin{mini#} can be substituted by \begin{maxi#}, \begin{argmini#} or \begin{argmaxi#}. + +## Contact: + +E-mail: jesus.lago.garcia@venus.uni-freiburg.de + +## Licensing: + +Copyright 2016 Jesus 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. + +This work consists of the file optidef.sty.
\ No newline at end of file diff --git a/Master/texmf-dist/doc/latex/optidef/optidef.pdf b/Master/texmf-dist/doc/latex/optidef/optidef.pdf Binary files differindex a82e8c09b8f..801d5d6faee 100644 --- a/Master/texmf-dist/doc/latex/optidef/optidef.pdf +++ b/Master/texmf-dist/doc/latex/optidef/optidef.pdf diff --git a/Master/texmf-dist/doc/latex/optidef/optidef.tex b/Master/texmf-dist/doc/latex/optidef/optidef.tex index a5147d46c1a..746870c3cdb 100644 --- a/Master/texmf-dist/doc/latex/optidef/optidef.tex +++ b/Master/texmf-dist/doc/latex/optidef/optidef.tex @@ -3,7 +3,7 @@ \usepackage{optidef} % Title Page -\title{\textit{\textbf{Optidef}} \\ A Latex library for minimization/maximization problems definition} +\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 1.0}} \author{Jesus Lago Garcia} @@ -20,11 +20,11 @@ This small library provides a standard set of environments for writing minimization problems. The most important features are: \begin{enumerate} - \item It automatically aligns the problems in three points with an optional fourth: + \item It automatically aligns the problems in the most convenient way allowing even two different output formats: \begin{enumerate} - \item Beginning of the words "minimize/argmin" and "subject to" - \item The objective function and the longest left hand side of the constraints - \item The $= | > | <$ signs of the constraints. + \item Alignment at the beginning of the words \textit{minimize/argmin} and \textit{subject to}. + \item Double format for the location of the constraints: either to the right of \textit{subject to} aligned with the objective function or below \textit{subject to}. + \item Alignment at the $=,~>,~<$ signs of the constraints. \item Optionally, the user can add manually a double align character \&\& to align some common constraints feature. A clear example could be the constraints names, e.g. (boundary constraint) alignment with (dynamic constraint), or the index of the constraints, e.g. in the case of having something like $h(x_k,u_k)\leq 0,\quad k=0,\ldots,N$, align the indexes $k=0,\ldots,N$ across constraint lines. \end{enumerate} @@ -43,70 +43,89 @@ This small library provides a standard set of environments for writing minimizat There are three basic environments depending on the type of referencing that should be used. \begin{enumerate} \item The \textbf{mini} environment for defining problems with a single reference label: - \begin{mini}{1} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} + \begin{mini} + {w}{f(w)+ R(w+6x)} {\label{eq:Ex1}}{} + \addConstraint{g(w)}{=0} \end{mini} \item The \textbf{mini*} environment if the problem does not have to be referenced: - \begin{mini*}{1} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} + \begin{mini*} + {w}{f(w)+ R(w+6x)} {}{} + \addConstraint{g(w)}{=0} \end{mini*} \item The \textbf{mini!} environment if each equation should be referenced: - \begin{mini!}{1} - {w}{f(w)+ R(w+6x) + \nabla_w R \label{eq:Ex2}} - {g(w)}{=0} + \begin{mini!} + {w}{f(w)+ R(w+6x)\label{eq:Ex2}} {\label{eq:Ex1}}{} + \addConstraint{g(w)}{=0} \end{mini!} \end{enumerate} +\section{Environment types} +There are two basic output formats. By default the constraints are aligned with the objective function and to the right of \textit{subject to}. However the user can choose to locate them below \textit{subject to}. +\begin{enumerate} + \item Standard format: + \begin{mini} + {w}{f(w)+ R(w+6x)} + {\label{eq:Ex1}}{} + \addConstraint{g(w)}{=0} + \end{mini} + \item Alternative format: + \begin{mini}[1] + {w}{f(w)+ R(w+6x)} + {\label{eq:Ex1}}{} + \addConstraint{g(w)}{=0} + \end{mini} +\end{enumerate} + \section{Environment Syntaxes} The three environments use the same syntax with the same number of parameters. In particular, considering that LHS stands for Left-hand-side and RHS for Right-hand-side, the basic structure to define a general optimization problem is: \begin{verbatim} -\begin{mini#}{Number of constraints} +\begin{mini#}[Format] {Optimization variable} {Objective function \label{Objective function referece}} - {LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}} {\label{Global referece of Optimization Problem}} {Result of the optimization problem or any expression on the left of the minimize word} + \addConstraint{LHS Constraint 1}{RHS Constraint 1 \label{Reference Constraint 1}} \addConstraint{LHS Constraint 2}{RHS Constraint 2 \label{Reference Constraint 2}} - \addConstraint{LHS Constraint 3}{RHS Constraint 3 \label{Reference Constraint 3}} . . - \finalConstraint{LHS N} {RHSConstraint N \label{Reference Constraint N}} + \addConstraint{LHS N}{RHSConstraint N \label{Reference Constraint N}} \end{mini#} \end{verbatim} \noindent where \# $\in \{*, !, ~ \}$. \subsection{Parameters definition} -The number of parameters that the environment uses is 7: +The number of parameters that the environment uses is 6: \begin{enumerate} - \item \verb|Number of constraints|, e.g. 0,1,2,3,4... \item \verb|Optimization variable|, e.g. $w \in \Re^N$. \item \verb|Objective function|, e.g. $\|w\|_2$. - \item \verb|LHS Constraint 1| (optional): the left-hand side of the first constraint, e.g. $3w^\top w$. For unconstrained problems leave it blank, i.e. \{\} - \item \verb|RHS Constraint 1| (optional): the right-hand side of the first constraints including the equal, less and greater signs, e.g. $\leq \|w\|_\infty$. For unconstrained problems leave it blank, i.e. \{\} \item \verb|\label{Global referece of Optimization Problem}|: it defines the main and general reference for the optimization problem. It is used for the \verb|mini| and \verb|mini!| enviroments. In the \verb|mini*| environment leave it blank, i.e. \{\}. \item \verb|Result of the optimization problem|: optionally a term expressing the result of the optimization problem, e.g. $J(w^*)~=$. + \item \verb|Format|: optional parameter if the user want to start the constraints right below \textit{subject to}, instead to the default location on the right of \textit{subject to}. \end{enumerate} -\noindent Notice that only the first three will be really necessary in every definition, nevertheless and for the sake of having homogeneous definitions, we opted for requiring the 7 parameters in every definition and expecting empty parameters definitions, i.e. \{\}, when they are not needed. +\noindent Notice that only the first two mandatory parameters (variable and objective) will be really necessary in every definition, nevertheless and for the sake of having homogeneous definitions, we opted for requiring the 4 parameters in every definition and expecting empty parameters definitions, i.e. \{\}, when they are not needed. + After the definition of this parameters, the environment accepts the definition of an infinite number of constraints. For this definitions the command: +~\\ \verb|\addConstraint{LHS Constraint k}| \verb|{RHS Constraint k \label{Reference Constraint k}}| +~\\ -\noindent has to be used, where the left hand side and right hand side syntax is the same as used for the mandatory third and fourth environment parameters. - -Notice that the last constraint has to be defined using the \verb|\finalConstraint| command, instead of the \verb|\addConstraint|. +\noindent has to be used, where: +\begin{enumerate} + \item \verb|LHS Constraint|: the left-hand side of the any constraint, e.g. $3w^\top w$. + \item \verb|RHS Constraint|: the right-hand side of the first constraints including the equal, less and greater signs, e.g. $\leq \|w\|_\infty$, as well as the constraint label. +\end{enumerate} \subsubsection{Constraints referencing} Notice that the label for the constraints is always included in the right hand side expression and it only makes sense for the case of using the \verb|mini!| enviroment. The label of the objective function can also be included in a similar way. @@ -115,56 +134,52 @@ Notice that the label for the constraints is always included in the right hand s The code: \begin{verbatim} -\begin{mini}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} - - {\label{eq:Example1}} - {} +\begin{mini} + {w}{f(w)+ R(w+6x)} + {\label{eq:Example1}}{} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{mini} \end{verbatim} \noindent outputs: -\begin{mini}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} - {\label{eq:Ex1}}{} +\begin{mini} + {w}{f(w)+ R(w+6x)} + {\label{eq:Ex11}}{} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{mini} \subsubsection{Example 2 - mini* environment} - On the other hand: \begin{verbatim} -\begin{mini*}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0,} - +\begin{mini*} + {w}{f(w)+ R(w+6x)} {}{} - + + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6,} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{mini*} \end{verbatim} \noindent it is almost the same but removing the reference: -\begin{mini*}{3} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0,} +\begin{mini*} + {w}{f(w)+ R(w+6x)} {}{} - \addConstraint{n(w)}{= 6, } - \addConstraint{L(w)+r(x)}{=Kw+p, } - \finalConstraint{h(x)}{=0.} + \addConstraint{g(w)}{=0} + \addConstraint{n(w)}{= 6} + \addConstraint{L(w)+r(x)}{=Kw+p} + \addConstraint{h(x)}{=0.} \end{mini*} \subsubsection{Example 3 - mini! environment} @@ -172,27 +187,25 @@ On the other hand: \noindent Finally, the multireferencing environment outputs: \begin{verbatim} -\begin{mini!}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R \label{eq:ObjectiveExample1}} - {g(w)}{=0 \label{eq:C1Example1}} - - {\label{eq:Example1}} - {} +\begin{mini!} + {w}{f(w)+ R(w+6x) \label{eq:ObjectiveExample1}} + {\label{eq:Example1}}{} + \addConstraint{g(w)}{=0 \label{eq:C1Example3}} \addConstraint{n(w)}{= 6 \label{eq:C2Example1}} \addConstraint{L(w)+r(x)}{=Kw+p \label{eq:C3Example1}} - \finalConstraint{h(x)}{=0. \label{eq:C4Example1}} + \addConstraint{h(x)}{=0. \label{eq:C4Example1}} \end{mini!} \end{verbatim} -\begin{mini!}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R\label{eq:ObjectiveExample3}} - {g(w)}{=0 \label{eq:C1Example3}} +\begin{mini!} + {w}{f(w)+ R(w+6x)\label{eq:ObjectiveExample3}} {\label{eq:Example3}} {} + \addConstraint{g(w)}{=0 \label{eq:C1Example3}} \addConstraint{n(w)}{= 6 \label{eq:C2Example3}} \addConstraint{L(w)+r(x)}{=Kw+p \label{eq:C3Example3}} - \finalConstraint{h(x)}{=0. \label{eq:C4Example3}} + \addConstraint{h(x)}{=0. \label{eq:C4Example3}} \end{mini!} \subsubsection{Example 4 - mini + problem result} @@ -200,65 +213,90 @@ On the other hand: \noindent Adding the problem result: \begin{verbatim} -\begin{mini}{4} -{w}{f(w)+ R(w+6x) + \nabla_w R} -{g(w)}{=0} - +\begin{mini} +{w}{f(w)+ R(w+6x)} {\label{eq:Example1}} {J(w^*)=} +\addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} -\finalConstraint{h(x)}{=0.} +\addConstraint{h(x)}{=0.} \end{mini} \end{verbatim} \noindent outputs: -\begin{mini}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} +\begin{mini} + {w}{f(w)+ R(w+6x)} {\label{eq:Ex1}}{J(w^*)~=~} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{mini} -\subsubsection{Example 5 - mini* + extra constraint alignment} -Adding the fourth optional alignment to add constraint names: +\subsubsection{Example 5 - second format} + +\noindent If including a 1 as optional parameter, the first constraint will appear aligned to the left right below \textit{subject to}. \begin{verbatim} -\begin{mini*}{4} -{w}{f(w)+ R(w+6x) + \nabla_w R} -{g(w)}{=0, \quad && \text{(Dynamic constraint)}} +\begin{mini}[1] +{w}{f(w)+ R(w+6x)} +{\label{eq:Example1}} +{} +\addConstraint{g(w)}{=0} +\addConstraint{n(w)}{= 6} +\addConstraint{L(w)+r(x)}{=Kw+p} +\addConstraint{h(x)}{=0.} +\end{mini} +\end{verbatim} + +\noindent outputs: + +\begin{mini}[1] + {w}{f(w)+ R(w+6x)} + {\label{eq:Ex1}}{} + \addConstraint{g(w)}{=0} + \addConstraint{n(w)}{= 6} + \addConstraint{L(w)+r(x)}{=Kw+p} + \addConstraint{h(x)}{=0.} +\end{mini} + + +\subsubsection{Example 6 - mini* + extra constraint alignment} +Adding the fourth optional alignment to add constraint names: + +\begin{verbatim} +\begin{mini*} +{w}{f(w)+ R(w+6x)} {}{} +\addConstraint{g(w)}{=0, \quad && \text{(Dynamic constraint)}} \addConstraint{n(w)}{= 6, \quad && \text{(Boundary constraint)}} \addConstraint{L(w)+r(x)}{=Kw+p, \quad && \text{(Random constraint)}} -\finalConstraint{h(x)}{=0.\quad && \text{(Path constraint)}} +\addConstraint{h(x)}{=0.\quad && \text{(Path constraint)}} \end{mini*} \end{verbatim} -\begin{mini*}{3} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0, \quad && \text{(Dynamic constraint)}} +\begin{mini*} + {w}{f(w)+ R(w+6x)} {}{} + \addConstraint{g(w)}{=0, \quad && \text{(Dynamic constraint)}} \addConstraint{n(w)}{= 6, \quad && \text{(Boundary constraint)}} \addConstraint{L(w)+r(x)}{=Kw+p, \quad && \text{(Random constraint)}} - \finalConstraint{h(x)}{=0. \quad && \text{(Path constraint).}} + \addConstraint{h(x)}{=0. \quad && \text{(Path constraint).}} \end{mini*} -\subsubsection{Example 6 - mini environment on the unconstrained case} +\subsubsection{Example 7 - mini environment on the unconstrained case} \begin{verbatim} -\begin{mini}{0} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {}{} - {}{} +\begin{mini} + {w}{f(w)+ R(w+6x)} {\label{eq:Ex4}} {} \end{mini} @@ -266,90 +304,91 @@ Adding the fourth optional alignment to add constraint names: \noindent outputs: -\begin{mini}{0} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {}{} +\begin{mini} + {w}{f(w)+ R(w+6x)} {\label{eq:Ex4}}{} \end{mini} + \section{The \textit{argmini} environment} Similar to the \verb|mini|, \verb|mini*| and \verb|mini!| environments, the environments \verb|argmini|, \verb|argmini*| and \verb|argmini!| are very similar environments that use the same syntax but the output is slightly different. The following code serves for illustration: \begin{verbatim} -\begin{argmini}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} +\begin{argmini} + {w}{f(w)+ R(w+6x)} {\label{eq:Example1}}{w^*=} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{argmini} \end{verbatim} \noindent outputs: -\begin{argmini}{3} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} +\begin{argmini} + {w}{f(w)+ R(w+6x)} {\label{eq:Ex1}}{w^*~=~} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{argmini} \section{The \textit{maxi} and \textit{argmaxi} environments} Exactly the same syntax and definition as the previous environments, but now for defining maximization environments. The following code serves for illustration: \begin{verbatim} -\begin{maxi}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} +\begin{maxi} + {w}{f(w)+ R(w+6x)} {g(w)}{=0} {\label{eq:Example1}}{} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{maxi} \end{verbatim} \noindent outputs: -\begin{maxi}{4} - {w}{f(w)+ R(w+6x) + \nabla_w R} - {g(w)}{=0} +\begin{maxi} + {w}{f(w)+ R(w+6x)} {\label{eq:Example1}}{} + \addConstraint{g(w)}{=0} \addConstraint{n(w)}{= 6} \addConstraint{L(w)+r(x)}{=Kw+p} - \finalConstraint{h(x)}{=0.} + \addConstraint{h(x)}{=0.} \end{maxi} \section{Problems and limitations} One current limitation is that the size of the optimization variables must be smaller than the word minimize, otherwise, the output is not properly aligned. Example: -\begin{mini!}{3} +\begin{mini!} {x_0,u_0,x_1,\hdots,u_{N-1},x_N} {\sum_{k=0}^{N-1} L(x_k,u_k)\!\!+\!\!E(x_N)\label{OCPobj}} - {x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} {\label{eq:OCP}}{} + \addConstraint{x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} \addConstraint{h(x_k,u_k)}{\leq 0, \quad k=0,\dots,N-1} - \finalConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}} + \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}} \end{mini!} \noindent A possible way to avoid this is to stack them with the command: \begin{verbatim} \substack{x_0,u_0,x_1,\hdots,\\u_{N-1},x_N} \end{verbatim} -\begin{mini!}{3} +\begin{mini!} {\substack{x_0,u_0,x_1,\hdots,\\ u_{N-1},x_N}} {\sum_{k=0}^{N-1} L(x_k,u_k)\!\!+\!\!E(x_N)\label{OCPobj}} - {x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} {\label{eq:OCP}}{} + \addConstraint{x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} \addConstraint{h(x_k,u_k)}{\leq 0, \quad k=0,\dots,N-1} - \finalConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}} + \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}} \end{mini!} \noindent If you want to increase the size of the optimization variables: @@ -357,26 +396,15 @@ One current limitation is that the size of the optimization variables must be sm \substack{\displaystyle x_0,u_0,x_1,\hdots,\\ \displaystyle u_{N-1},x_N} \end{verbatim} -\begin{mini!}{3} +\begin{mini!} {\substack{\displaystyle x_0,u_0,x_1,\hdots,\\ \displaystyle u_{N-1},x_N}} {\sum_{k=0}^{N-1} L(x_k,u_k)\!\!+\!\!E(x_N)\label{OCPobj}} - {x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} {\label{eq:OCP}}{} + \addConstraint{x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} \addConstraint{h(x_k,u_k)}{\leq 0, \quad k=0,\dots,N-1} - \finalConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}} + \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}} \end{mini!} -The other option is to define the set of variables before the problem definition as a single variable, i.e. $w = [x_0,u_0,x_1,\hdots,u_{N-1},x_N]$ and: - -%\begin{mini3!} -% {w} -% {\sum_{k=0}^{N-1} L(x_k,u_k)\!\!+\!\!E(x_N)}{\label{OCPobj}} -% {x_{k+1}-f(x_k,u_k)}{= 0, \label{dOCP:modelc}\quad k=0,\dots,N-1} -% {h(x_k,u_k)} {\leq 0, \quad k=0,\dots,N-1} -% {r(x_0,x_N)}{= 0. \label{dOCP:boundary}} -% \label{eq:OCP} -%\end{mini3!} - \section{Code definition} \begin{verbatim} % optidef - Version 08/06/2016 @@ -391,378 +419,227 @@ The other option is to define the set of variables before the problem definition %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{ifthen} - \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} - }% - } + +\NeedsTeXFormat{LaTeX2e} +\ProvidesPackage{optidef}[2016/06/06 Package for defining optimization problems] + +\RequirePackage{environ} +\RequirePackage{mathtools} +\RequirePackage{xifthen} +\RequirePackage{etoolbox} +\newtoggle{bodyCon} +\toggletrue{bodyCon} + +% 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] +{\\ &\text{subject to} \quad  & #2} + +\newcommand{\bodyconstRight}[2] +{\\ &\text{subject to} \quad  & #2} + +\newcommand{\bodyconstBelow}[2] +{\\ &\text{subject to} \span\span \\ +&\quad & #2} + +\newcommand{\bodyconstBelowMult}[2] +{\\ &\text{subject to} \span\span\span\span \nonumber \\ +&\quad & #2} + +\newcommand{\addConstraint}[2]{ +\iftoggle{bodyCon}{ +\bodyconst{#1}{#2} +\togglefalse{bodyCon} +}{ +,\\&\quad  & #2 +\togglefalse{bodyCon} +} +} + +\newcommand{\breakObjectiveOneConstraint}[1]{&&\\} + + + +%MINIMIZATION ENVIRONMENTS + +\NewEnviron{mini}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{minimize}{#5} +\BODY +\end{alignedat} +\end{equation} +\toggletrue{bodyCon} +\let\bodyconst\bodyconstRight +} + +\NewEnviron{argmini}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{arg min}{#5} +\BODY +\end{alignedat} +\end{equation} +} + +\NewEnviron{mini*}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation*} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{minimize}{#5} +\BODY +\end{alignedat} +\end{equation*} +\toggletrue{bodyCon} +\let\bodyconst\bodyconstRight +} + +\NewEnviron{argmini*}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation*} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{arg min}{#5} +\BODY +\end{alignedat} +\end{equation*} +} + + +\NewEnviron{mini!}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelowMult +}{} +\begin{subequations} +#4 +\begin{alignat}{4} +\bodyobj{#2}{#3}{minimize}{#5} +\BODY +\end{alignat} +\end{subequations} +\toggletrue{bodyCon} +\let\bodyconst\bodyconstRight +} + +\NewEnviron{argmini!}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelowMult +}{} +\begin{subequations} +#4 +\begin{alignat}{4} +\bodyobj{#2}{#3}{arg min}{#5} +\BODY +\end{alignat} +\end{subequations} +} + +%MAXIMIZATION ENVIRONMENTS + +\NewEnviron{maxi}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{maximize}{#5} +\BODY +\end{alignedat} +\end{equation} +} + +\NewEnviron{argmaxi}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{arg maxi}{#5} +\BODY +\end{alignedat} +\end{equation} +} + +\NewEnviron{maxi*}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation*} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{maximize}{#5} +\BODY +\end{alignedat} +\end{equation*} +} + +\NewEnviron{argmaxi*}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelow +}{} +\begin{equation*} +#4 +\begin{alignedat}{4} +\bodyobj{#2}{#3}{arg maxi}{#5} +\BODY +\end{alignedat} +\end{equation*} +} + + +\NewEnviron{maxi!}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelowMult +}{} +\begin{subequations} +#4 +\begin{alignat}{4} +\bodyobj{#2}{#3}{maximize}{#5} +\BODY +\end{alignat} +\end{subequations} +} + +\NewEnviron{argmaxi!}[5][]{% +\ifthenelse{\equal{#1}{1}}{ +\let\bodyconst\bodyconstBelowMult +}{} +\begin{subequations} +#4 +\begin{alignat}{4} +\bodyobj{#2}{#3}{arg maxi}{#5} +\BODY +\end{alignat} +\end{subequations} +} \end{verbatim} \end{document} diff --git a/Master/texmf-dist/tex/latex/optidef/optidef.sty b/Master/texmf-dist/tex/latex/optidef/optidef.sty index 47addfa92dc..9967b8919ad 100644 --- a/Master/texmf-dist/tex/latex/optidef/optidef.sty +++ b/Master/texmf-dist/tex/latex/optidef/optidef.sty @@ -1,4 +1,4 @@ -% optidef - Version 08/06/2016 +% optidef - Version 1.0 % %Copyright 2016 J. Lago Garcia % @@ -17,367 +17,217 @@ \RequirePackage{environ} \RequirePackage{mathtools} \RequirePackage{xifthen} +\RequirePackage{etoolbox} +\newtoggle{bodyCon} +\toggletrue{bodyCon} - % Input minimization evironments - - % Macros for objective definition, constraint definition and extra constraint definition - \newcommand{\bodyobj}[4] +% Input minimization evironments + +% Macros for objective definition, constraint definition and extra constraint definition +\newcommand{\bodyobj}[4] +{ + \ifthenelse{\isempty{#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 - } + &\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} - }% - }% + #4 ~~ &\underset{\displaystyle #1}{\mbox{#3}} \quad #2\span\span\span\span } - - \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} - }% +} + + +\newcommand{\bodyconst}[2] +{\\ &\text{subject to} \quad  & #2} + +\newcommand{\bodyconstRight}[2] +{\\ &\text{subject to} \quad  & #2} + +\newcommand{\bodyconstBelow}[2] +{\\ &\text{subject to} \span\span \\ + &\quad & #2} + +\newcommand{\bodyconstBelowMult}[2] +{\\ &\text{subject to} \span\span\span\span \nonumber \\ + &\quad & #2} + +\newcommand{\addConstraint}[2]{ + \iftoggle{bodyCon}{ + \bodyconst{#1}{#2} + \togglefalse{bodyCon} + }{ + ,\\&\quad  & #2 + \togglefalse{bodyCon} } - - \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 +} + +\newcommand{\breakObjectiveOneConstraint}[1]{&&\\} + + + +%MINIMIZATION ENVIRONMENTS + +\NewEnviron{mini}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{minimize}{#5} + \BODY + \end{alignedat} + \end{equation} +\toggletrue{bodyCon} +\let\bodyconst\bodyconstRight +} + +\NewEnviron{argmini}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{arg min}{#5} + \BODY + \end{alignedat} + \end{equation} +} + +\NewEnviron{mini*}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation*} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{minimize}{#5} + \BODY + \end{alignedat} +\end{equation*} +\toggletrue{bodyCon} +\let\bodyconst\bodyconstRight +} + +\NewEnviron{argmini*}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation*} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{arg min}{#5} + \BODY + \end{alignedat} + \end{equation*} +} + + +\NewEnviron{mini!}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelowMult + }{} + \begin{subequations} + #4 + \begin{alignat}{4} + \bodyobj{#2}{#3}{minimize}{#5} + \BODY + \end{alignat} + \end{subequations} + \toggletrue{bodyCon} +\let\bodyconst\bodyconstRight +} + +\NewEnviron{argmini!}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelowMult + }{} + \begin{subequations} + #4 + \begin{alignat}{4} + \bodyobj{#2}{#3}{arg min}{#5} + \BODY + \end{alignat} + \end{subequations} +} + +%MAXIMIZATION ENVIRONMENTS + +\NewEnviron{maxi}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{maximize}{#5} + \BODY + \end{alignedat} + \end{equation} +} + +\NewEnviron{argmaxi}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{arg maxi}{#5} + \BODY + \end{alignedat} + \end{equation} +} + +\NewEnviron{maxi*}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation*} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{maximize}{#5} + \BODY + \end{alignedat} + \end{equation*} +} + +\NewEnviron{argmaxi*}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelow + }{} + \begin{equation*} + #4 + \begin{alignedat}{4} + \bodyobj{#2}{#3}{arg maxi}{#5} + \BODY + \end{alignedat} + \end{equation*} +} + + +\NewEnviron{maxi!}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelowMult + }{} + \begin{subequations} + #4 + \begin{alignat}{4} + \bodyobj{#2}{#3}{maximize}{#5} + \BODY + \end{alignat} + \end{subequations} +} + +\NewEnviron{argmaxi!}[5][]{% + \ifthenelse{\equal{#1}{1}}{ + \let\bodyconst\bodyconstBelowMult + }{} + \begin{subequations} + #4 + \begin{alignat}{4} + \bodyobj{#2}{#3}{arg maxi}{#5} + \BODY + \end{alignat} + \end{subequations} +}
\ No newline at end of file |