summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2018-05-23 22:08:18 +0000
committerKarl Berry <karl@freefriends.org>2018-05-23 22:08:18 +0000
commitadb13e8fba22cf7373b081329ba913a6dc0235d7 (patch)
tree85042e1ee85ba8d26f4ad4d27ef56404b1de2380
parent450bfa54886ef9c35469b032209d325cbaf0e590 (diff)
optidef (23may18)
git-svn-id: svn://tug.org/texlive/trunk@47818 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/optidef/README.md2
-rw-r--r--Master/texmf-dist/doc/latex/optidef/optidef.pdfbin285841 -> 242949 bytes
-rw-r--r--Master/texmf-dist/doc/latex/optidef/optidef.tex897
-rw-r--r--Master/texmf-dist/tex/latex/optidef/optidef.sty74
4 files changed, 195 insertions, 778 deletions
diff --git a/Master/texmf-dist/doc/latex/optidef/README.md b/Master/texmf-dist/doc/latex/optidef/README.md
index d39f42d7469..3ade0c2cdbc 100644
--- a/Master/texmf-dist/doc/latex/optidef/README.md
+++ b/Master/texmf-dist/doc/latex/optidef/README.md
@@ -66,7 +66,7 @@ E-mail: J.LagoGarcia(at)tudelft.nl
Github: https://github.com/jeslago/optidef
-## Latest stable version: Optidef 2.6
+## Latest stable version: Optidef 2.7
CTAN: https://www.ctan.org/pkg/optidef
diff --git a/Master/texmf-dist/doc/latex/optidef/optidef.pdf b/Master/texmf-dist/doc/latex/optidef/optidef.pdf
index b0766ded88d..eefab571eeb 100644
--- a/Master/texmf-dist/doc/latex/optidef/optidef.pdf
+++ b/Master/texmf-dist/doc/latex/optidef/optidef.pdf
Binary files differ
diff --git a/Master/texmf-dist/doc/latex/optidef/optidef.tex b/Master/texmf-dist/doc/latex/optidef/optidef.tex
index b9cae13bde5..8a07141985d 100644
--- a/Master/texmf-dist/doc/latex/optidef/optidef.tex
+++ b/Master/texmf-dist/doc/latex/optidef/optidef.tex
@@ -7,7 +7,7 @@
\lstset{basicstyle=\ttfamily,breaklines=true}
% Title Page
-\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 2.6}}
+\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 2.7}}
\author{Jesus Lago}
@@ -43,13 +43,17 @@ The package can be imported by directly adding
\begin{lstlisting}
\usepackage{optidef}
\end{lstlisting}
-to the document preamble. When importing the packages two options can be used, \verb|short| and \verb|nocomma|:
+to the document preamble. When importing the packages three options can be used, \verb|short|, \verb|nocomma|, and either \verb|c1|, \verb|c2|, or \verb|c3|:
\begin{lstlisting}
-\usepackage[short,nocomma]{optidef}
+\usepackage[short,c1|c2|c3,nocomma]{optidef}
\end{lstlisting}
-For an explanation of the \verb|short| option check Section \ref{sec:longshort}. For the \verb|nocomma| option check Section \ref{sec:comma}. For a detailed description of how to use the package keep reading the next section.
+The first option changes the default long format of the optimization problems to a shorter format; for a better explanation (including examples) of the \verb|short| option check Section \ref{sec:longshort}.
+
+The options \verb|c1|, \verb|c2|, and \verb|c3| change the default format of the constraints; the default format is format 0 (as defined in Section \ref{sec:format}); \verb|c1|, \verb|c2|, and \verb|c3| respectively change the default constraint arrangement to format 1, 2, and 3. For a better explanation of the four formats including examples, we refer to Section \ref{sec:format}.
+
+For the \verb|nocomma| option check Section \ref{sec:comma}. For a detailed description of how to use the package keep reading the next section.
\section{Environment Syntax Definition}
\label{sec:syntax}
@@ -115,7 +119,7 @@ Notice that the label for the constraints is always included in the right hand s
\section{Environment Types}
\label{sec:environments}
-There are three basic environments depending on the type of referencing that should be used.
+There are four 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}
@@ -135,7 +139,9 @@ There are three basic environments depending on the type of referencing that sho
{w}{f(w)+ R(w+6x)\label{eq:Ex2}}
{\label{eq:Ex1}}{}
\addConstraint{g(w)}{=0}
- \end{mini!}
+ \end{mini!}
+\item The \textbf{minie} environment: same functionality as the \textbf{mini!} environment and it replaces \textbf{mini!} when using the \texttt{optidef} library with some languages in the babel package. For further details we refer to Section \ref{sec:babel}.
+%in older versions of the package it was the same as the current \textbf{minie} environment. \textbf{mini?} has been re-branded to \textbf{minie} for compatibility issues with some languages in the babel package. While its use is deprecated, it is kept in the package to ensure back-compatibility with old documents.
\end{enumerate}
\noindent Additionally, there are four basic definitions of optimization problems:
@@ -228,16 +234,17 @@ Selected by \verb|sizeFormat|=s. It uses instead the shorter \textit{s.t.} and \
\section{Output Formats for the Constraints}
\label{sec:format}
There are four basic output formats for the location of the constraints. They are controlled by the environment parameter \verb|constraintFormat|.
-\subsection{Standard Format}
- It is the default format and if \verb|constraintFormat| left blank it is used. Alternatively can be also set by selecting \verb|constraintFormat|=0.
-
- By default the constraints are aligned with the objective function, to the right of \textit{subject to} and with a second alignment point at the $=,~\leq,~\geq$:
+\subsection{Alternative 0}
+In this format option, the constraints are located to the right of \textit{subject to} and aligned with the objective function. It also has a second alignment point at the $=,~\leq,~\geq$ signs:
\begin{mini}
{w}{f(w)+ R(w+6x)}
{\label{eq:Ex1}}{}
\addConstraint{g(w)+h(w)}{=0}
\addConstraint{t(w)}{=0.}
\end{mini}
+
+\noindent It is the default format if no format option is provided. Alternatively, it can also be set by selecting \verb|constraintFormat|=0.
+
\subsection{Alternative 1}
Selected by \verb|constraintFormat|=1. It locates the constraints below \textit{subject to} and keeps them aligned at the inequality/equality signs:
\begin{mini}[1]
@@ -263,6 +270,10 @@ There are four basic output formats for the location of the constraints. They ar
\addConstraint{t(w)}{=0.}
\end{mini}
+\begin{lstlisting}
+ \usepackage[c1|c2|c3]{optidef}
+ \end{lstlisting}
+
\subsection{Extra alignment alternative}
\label{sec:extraAlign}
By default, the constraints have 2 aligned elements. However, a third alignment point can be used to set some constraint features. A clear example could be the constraints names:
@@ -282,6 +293,11 @@ This extra alignment point can be added using a third input parameter on the \ve
\addConstraint{l(w_k)}{=5u,\quad}{k=0,\ldots,N-1}
\end{lstlisting}
+
+\subsection{Default format}
+The default format is alternative 0. To change the default format across the whole document, the package can be imported using one of the three options: \verb|c1|, \verb|c2|, \verb|c3|, i.e.:
+
+
\section{Breaking the objective across several lines}
\label{sec:breakObj}
In several cases, people encounter the problem of having an optimization problem which objective function is too long to be set in a single line. In such cases, a line breaking that respects the rest of the problem syntax would be desirable. To account for that, the command \verb|\breakObjective| can be used. The idea is that, if the objective function shall be split in $n$ different functions, e.g.~$f_1,\ldots,f_n$, the default objective parameter would include just $f_1$ and then, we would include $n-1$ statements \verb|\breakObjective|($f_k$), $\forall k=2,\ldots,n$ right before defining the \verb|\addConstraint| commands.
@@ -326,19 +342,93 @@ By default, the algorithms adds a comma at the end of any constraint that is not
\usepackage[nocomma]{optidef}
\end{lstlisting}
+
+
+\section{Long Optimization Variables}
+The standard appearance for long optimization variables is as follows:
+
+\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}}
+ {\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}
+ \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}}
+\end{mini!}
+
+\noindent A possible way to reduce the large variable spacing 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!}
+ {\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}}
+ {\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}
+ \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}}
+\end{mini!}
+
+\section{Compatibility issues with other packages}
+Issues with two different packages have been reported: cleveref and babel.
+\subsection{Cleveref}
+When using the cleveref package in couple with the optidef package two measures have to taken for the packages to work properly:
+
+\begin{enumerate}
+ \item As also indicated in the cleveref documentation, the optidef package has to be loaded before the cleveref package.
+ \item To avoid crashes, the \verb|\label| commands in the optidef environments have to be replaced by the protected counterparts \verb|\protect\label|. This is required because of the standard Latex issue of moving arguments and fragile commands\footnote{\url{goo.gl/wmKbNU}}.
+\end{enumerate}
+
+\noindent A code example taking into account both measures is the following:
+
+\begin{verbatim}
+ \documentclass{article}
+ \usepackage{optidef}
+ \usepackage{cleveref}
+
+ \begin{document}
+
+ \begin{mini!}
+ {w}{f(w)+ R(w+6x) \protect\label{eq:ObjectiveExample1}}
+ {\label{eq:Example1}}{}
+ \addConstraint{g(w)}{=0 \protect\label{eq:C1Example3}}
+ \addConstraint{n(w)}{= 6 \protect\label{eq:C2Example1}}
+ \addConstraint{L(w)+r(x)}{=Kw+p \protect\label{eq:C3Example1}}
+ \end{mini!}
+
+ Example labels: \cref{eq:Example1} and \cref{eq:ObjectiveExample1}.
+
+ \end{document}
+\end{verbatim}
+
+As an alternative to the second step, i.e.~protecting the \verb|\label| command, the command can be robustify in the document preamble and then \verb|\protect| is not longer needed. To robustify the \verb|\label| command, the following has to be added to the preamble:
+
+
+\begin{verbatim}
+\usepackage{etoolbox}
+\robustify{\label}
+\end{verbatim}
+
+\subsection{Babel}
+\label{sec:babel}
+When importing the package babel with some specific languages, e.g.~French, the \verb|mini!| environment clashes because of the exclamation mark.
+
+This issue has been resolved starting from Optidef 2.7, where a working alternative to the \verb|mini!| environment is included: the \verb|minie| enviroment. Both environemnts have the same functionality, but when using the babel package it is recommended to use the \verb|minie| environment to avoid issues.
+
+
\section{Examples}
\subsection{Example 1 - mini environment}
The code:
\begin{verbatim}
\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}
- \addConstraint{h(x)}{=0.}
+{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}
@@ -358,13 +448,13 @@ On the other hand:
\begin{verbatim}
\begin{mini*}
- {w}{f(w)+ R(w+6x)}
- {}{}
+{w}{f(w)+ R(w+6x)}
+{}{}
- \addConstraint{g(w)}{=0}
- \addConstraint{n(w)}{= 6,}
- \addConstraint{L(w)+r(x)}{=Kw+p}
- \addConstraint{h(x)}{=0.}
+\addConstraint{g(w)}{=0}
+\addConstraint{n(w)}{= 6,}
+\addConstraint{L(w)+r(x)}{=Kw+p}
+\addConstraint{h(x)}{=0.}
\end{mini*}
\end{verbatim}
@@ -385,13 +475,13 @@ On the other hand:
\begin{verbatim}
\begin{mini!}
- {w}{f(w)+ R(w+6x) \label{eq:ObjectiveExample1}}
- {\label{eq:Example1}}{}
+{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}}
- \addConstraint{h(x)}{=0. \label{eq:C4Example1}}
+\addConstraint{g(w)}{=0 \label{eq:C1Example3}}
+\addConstraint{n(w)}{= 6 \label{eq:C2Example1}}
+\addConstraint{L(w)+r(x)}{=Kw+p \label{eq:C3Example1}}
+\addConstraint{h(x)}{=0. \label{eq:C4Example1}}
\end{mini!}
\end{verbatim}
@@ -548,10 +638,10 @@ On the other hand:
\subsection{Example 9 - Breaking a long objective}
\begin{lstlisting}
\begin{mini*}
- {w,u}{f(w)+ R(w+6x)+ H(100w-x*w/500)}{}{}
- \breakObjective{-g(w^3-x^2*200+10000*w^5)}
- \addConstraint{g(w_k)+h(w_k)}{=0,}
- \addConstraint{l(w_k)}{=5u,\quad}
+{w,u}{f(w)+ R(w+6x)+ H(100w-x*w/500)}{}{}
+\breakObjective{-g(w^3-x^2*200+10000*w^5)}
+\addConstraint{g(w_k)+h(w_k)}{=0,}
+\addConstraint{l(w_k)}{=5u,\quad}
\end{mini*}
\end{lstlisting}
outputs:
@@ -569,12 +659,12 @@ Adding 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)}}
- \addConstraint{h(x)}{=0,}{ \quad \text{(Path constraint).}}
+{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)}}
+\addConstraint{h(x)}{=0,}{ \quad \text{(Path constraint).}}
\end{mini*}
\end{verbatim}
@@ -637,14 +727,14 @@ Exactly the same syntax and definition as the previous environments, but now for
\subsection{Example 12 - All Possible Parameters}
\begin{verbatim}
-\begin{mini*}|s|[1]
+\begin{mini!}|s|[1]
{w}{f(w)+ R(w+6x)}
{}{w^*=}
\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)}}
\addConstraint{h(x)}{=0,}{ \quad \text{(Path constraint).}}
-\end{mini*}
+\end{mini!}
\end{verbatim}
\begin{mini!}|s|[2]
@@ -657,730 +747,11 @@ Exactly the same syntax and definition as the previous environments, but now for
\addConstraint{h(x)}{=0.\label{eq:C4Example3}}
\end{mini!}
-
-\section{Long Optimization Variables}
-The standard appearance for long optimization variables is as follows:
-
-\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}}
- {\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}
- \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}}
-\end{mini!}
-
-\noindent A possible way to reduce the large variable spacing 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!}
- {\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}}
- {\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}
- \addConstraint{r(x_0,x_N)}{= 0. \label{dOCP:boundary}}
-\end{mini!}
-
-\section{Compatibility issues with other packages}
-When using the cleveref package in couple with the optidef package two measures have to taken for the packages to work properly:
-
-\begin{enumerate}
- \item As also indicated in the cleveref documentation, the optidef package has to be loaded before the cleveref package.
- \item To avoid crashes, the \verb|\label| commands in the optidef environments have to be replaced by the protected counterparts \verb|\protect\label|. This is required because of the standard Latex issue of moving arguments and fragile commands\footnote{\url{goo.gl/wmKbNU}}.
-\end{enumerate}
-
-\noindent A code example taking into account both measures is the following:
-
-\begin{verbatim}
- \documentclass{article}
- \usepackage{optidef}
- \usepackage{cleveref}
-
- \begin{document}
-
- \begin{mini!}
- {w}{f(w)+ R(w+6x) \protect\label{eq:ObjectiveExample1}}
- {\label{eq:Example1}}{}
- \addConstraint{g(w)}{=0 \protect\label{eq:C1Example3}}
- \addConstraint{n(w)}{= 6 \protect\label{eq:C2Example1}}
- \addConstraint{L(w)+r(x)}{=Kw+p \protect\label{eq:C3Example1}}
- \end{mini!}
-
- Example labels: \cref{eq:Example1} and \cref{eq:ObjectiveExample1}.
-
- \end{document}
-\end{verbatim}
-
-
\section{Reporting bugs and feature requests}
To report any bug or request some feature please use the issue section in the github repository: \url{https://github.com/jeslago/optidef/issues}.
-\section{Code definition}
-\begin{lstlisting}
-% optidef - Version 2.6
-%
-%Copyright 2017 Jesus Lago
-%
-%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.
-%
-%E-mail: J.LagoGarcia@tudelft.nl
-%
-%This work consists of the file optidef.sty.
-
-\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{optidef}[2017/11/29 - version=2.6, Package for defining optimization problems]
-
-\RequirePackage{environ}
-\RequirePackage{mathtools}
-\RequirePackage{xifthen}
-\RequirePackage{etoolbox}
-\RequirePackage{xparse}
-\RequirePackage{calc}
-
-%%%%%%%%%%%%%%%%%%%%%%%
-% DEFINING PACKAGE OPTIONS
-%%%%%%%%%%%%%%%%%%%%%%%
-% Default
-\newcommand{\defaultOCPConstraint}{,}
-\newcommand{\defaultProblemFormat}{l}
-
-\DeclareOption{short}{
-\renewcommand{\defaultProblemFormat}{s}
-}
-
-\DeclareOption{long}{
-\renewcommand{\defaultProblemFormat}{l}
-}
-
-\DeclareOption{nocomma}{
-\renewcommand{\defaultOCPConstraint}{}
-}
-
-\ProcessOptions\relax
-
-% This command is required to avoid breakdown of the \equal fragile command. In particular, before I had \equal{#2}{} tp check if argumetn #2 was empty. However, if the argument was a bmatrix object the command was breaking. Now this command is robust.
-\newcommand{\equalsNothing}[3]{%
-\ifthenelse{\equal{\unexpanded{#1}}{}}{#2}{#3}%
-}
-
-%%%%%%%%%%%%%%%%%%%%%%%
-% VARIABLES DEFINITION
-%%%%%%%%%%%%%%%%%%%%%%%
-
-% Toogle to indicate if during the addConstraint command the first constraint should be built together with "subject to"
-\newtoggle{bodyCon}
-\toggletrue{bodyCon}
-
-% If the previous constraints has 3 elements, we avoid setting \span\span at the beginning of the next constraint. If there is no previous third element, \span\span must be included for correct alignment
-\newtoggle{previousThird}
-\togglefalse{previousThird}
-\newcommand{\spanit}{}
-
-% Variable used to define the subject to word for short and long versions
-\newcommand{\bodySubjectTo}{Unset Subject to}
-
-% Variable used for defining if the long problem format or the short problem format is used
-\newcommand{\localProblemFormat}{l}
-
-% Variable to storage which type of of local problem is being solved
-\newcommand{\localProblemType}{minimize}
-
-% Defining variable to storage problem variable
-\newcommand{\localOptimalVariable}{}
-
-\newlength\widthInit
-
-%%%%%%%%%%%%%%%%%%%%%%%
-% OBJECTIVE COMMAND DEFINITION
-%%%%%%%%%%%%%%%%%%%%%%%
-\newcommand{\bodyobj}[4]
-{
-\ifthenelse{\isempty{#4}}
-{
-&\underset{\displaystyle #1}{\mathrlap{\mathrm{#3}}\phantom{\mathrm{subject~to}}} \quad #2\span\span\span\span
-}
-{
-#4~ &\underset{\displaystyle #1}{\mathrlap{\mathrm{#3}}\phantom{\mathrm{subject~to}}} \quad #2\span\span\span\span
-}
-}
-
-
-%% LONG VERSION "minimize" instead of "min"
-\newcommand{\bodyobjLong}[4]
-{
-\ifthenelse{\isempty{#4}}
-{
-&\mathmakebox[\widthof{$\underset{\displaystyle #1}{\mathrm{subject~to}}$}]{\underset{\displaystyle #1}{\mathrm{#3}}} \quad #2\span\span\span\span
-}
-{
-#4~ &\mathmakebox[\widthof{$\underset{\displaystyle #1}{\mathrm{subject~to}}$}]{\underset{\displaystyle #1}{\mathrm{#3}}} \quad #2\span\span\span\span
-}
-}
-
-%% SHORT VERSION "min" instead of "minimize"
-\newcommand{\bodyobjShort}[4]
-{
-\ifthenelse{\isempty{#4}}
-{
-&\underset{\displaystyle #1}{\mathrm{#3}} \quad #2\span\span\span\span
-}
-{
-#4 ~ &\underset{\displaystyle #1}{\mathrm{#3}} \quad #2\span\span\span\span
-}
-}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% DEFINITION DIFFERENT TYPE OF BODY CONSTRAINTS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-%% A BODY CONSTRAINT IS THE INITIAL CONSTRAINT DEFINED WITH THE 'SUBJECT TO', DEPENDING ON THE TYPE OF PROBLEM A DIFFERENT VERSION IS USED
-
-
-% Main command. Dynamically redefined at every new problem definition.
-\DeclareDocumentCommand{\bodyconst}{m G{}}
-{ \equalsNothing{#2}{
-\\ &\underset{\displaystyle \phantom{\localOptimalVariable}}{\mathrm{subject~to}} \quad &&#1 #2
-}{
-\\ &\underset{\displaystyle \phantom{\localOptimalVariable}}{\mathrm{subject~to}} \quad &#1 & #2
-}
-}
-
-\newcommand{\bodySubjectToDefinition}{
-%## If the short version of "subject to", i.e. "s.t.", should be used the command \bodySubjectTo should be modified
-\ifthenelse{\equal{\localProblemFormat}{s}}
-{%%
-\global\def\bodySubjectTo{\mathmakebox[\widthof{$\underset{\displaystyle \phantom{\localOptimalVariable}}{\mathrm{\localProblemType}}$}][c]{\mathmakebox[\widthof{$\mathrm{\localProblemType}$}][l]{\mathrm{\kern 0.1em s.t.}}}}
-}{%%
-\global\def\bodySubjectTo{\mathmakebox[\widthof{$\underset{\displaystyle \phantom{\localOptimalVariable}}{\mathrm{\,subject~to}}$}][c]{\mathmakebox[\widthof{$\mathrm{\localProblemType}$}][l]{\mathrm{subject~to}}}}
-}%%
-%
-}
-
-% Standard version.
-\DeclareDocumentCommand{\bodyconstRight}{m G{} G{}}
-{%%%
-\bodySubjectToDefinition
-%## Set the first constraint according to the format used for "subject to"
-\equalsNothing{#3}{%%
-\equalsNothing{#2}{%
-\\ & \bodySubjectTo \quad &&#1 #2
-}{%
-\\ &\bodySubjectTo \quad &#1 & #2
-}%
-\togglefalse{previousThird}
-}{%%
-\equalsNothing{#2}{%
-\\ &\bodySubjectTo \quad &&#1 #2 &&#3
-}{%
-\\ &\bodySubjectTo \quad &#1 & #2 &&#3
-}%
-\toggletrue{previousThird}
-}%%
-}%%%
-
-
-% Single alignment point but next to subject to
-\DeclareDocumentCommand{\bodyconstOneAlign}{m G{} G{}}
-{
-\bodySubjectToDefinition
-%## Set the first constraint according to the format used for "subject to"
-\equalsNothing{#3}{
-\\ &\bodySubjectTo\quad &&#1 #2 \togglefalse{previousThird}
-}{
-\\ &\bodySubjectTo\quad &&#1 #2 &&#3
-\toggletrue{previousThird}
-}
-}
-
-% Contraints below subject to and with a single alignment point
-\DeclareDocumentCommand{\bodyconstOneAlignBelow}{m G{} G{}}
-{
-\bodySubjectToDefinition
-%## Set the first constraint according to the format used for "subject to"
-\equalsNothing{#3}{
-\\ &\bodySubjectTo \span\span\span\span \\
-&&&#1 #2 \togglefalse{previousThird}
-}{
-\\ &\bodySubjectTo \span\span\span\span \\
-&&&#1 #2 &&#3
-\toggletrue{previousThird}
-}
-}
-
-% Contraints below subject to but with double alignment point
-\DeclareDocumentCommand{\bodyconstBelow}{m G{} G{}}
-{
-\bodySubjectToDefinition
-%## Set the first constraint according to the format used for "subject to"
-\equalsNothing{#3}{
-\equalsNothing{#2}{
-\\ &\bodySubjectTo\span\span\span\span \\
-&&&#1 #2
-}{
-\\ &\bodySubjectTo \span\span\span\span \\
-&&#1 & #2
-}
-\togglefalse{previousThird}
-}{
-\equalsNothing{#2}{
-\\ &\bodySubjectTo \span\span\span\span \\
-&&&#1 #2 &&#3
-}{
-\\ &\bodySubjectTo\span\span\span\span \\
-&&#1 & #2 &&#3
-}
-\toggletrue{previousThird}
-}
-}
-
-% Contraints below subject to for the case of having a reference/label for each individual equation
-\DeclareDocumentCommand{\bodyconstBelowMult}{m G{} G{}}
-{
-\bodySubjectToDefinition
-%## Set the first constraint according to the format used for "subject to"
-\equalsNothing{#3}{
-\equalsNothing{#2}{
-\\ &\bodySubjectTo\span\span\span\span \nonumber \\
-&&&#1 #2
-}{
-\\ &\bodySubjectTo \span\span\span\span \nonumber \\
-&&#1 & #2
-}
-\togglefalse{previousThird}
-}{
-\equalsNothing{#2}{
-\\ &\bodySubjectTo\span\span\span\span \nonumber \\
-&&&#1 #2 &&#3
-}{
-\\ &\bodySubjectTo \span\span\span\span \nonumber \\
-&&#1 & #2 &&#3
-}
-\toggletrue{previousThird}
-}
-}
-
-% Contraints below subject to and with a single alignment point for the case of having a reference/label for each individual equation
-\DeclareDocumentCommand{\bodyconstOneAlignBelowMult}{m G{} G{}}
-{
-\bodySubjectToDefinition
-%## Set the first constraint according to the format used for "subject to"
-\equalsNothing{#3}{
-\\ &\bodySubjectTo\span\span\span\span \nonumber \\
-&&&#1 #2 \togglefalse{previousThird}
-}{
-\\ &\bodySubjectTo\span\span\span\span \nonumber \\
-&&&#1 #2 && #3
-\toggletrue{previousThird}
-}
-}
-
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% DEFINITION DIFFERENT TYPE OF ADDING CONSTRAINTS
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-
-
-% Main command. Dynamically redefined at every problem definiton.
-\DeclareDocumentCommand{\addConstraint}{m G{} G{}}{
-% "If clause" selecting whether a third parameter (#3) defining extra constraint information is used
-\equalsNothing{#3}{
-% Second "If clause" selecting whether two or 1 elements for the constraints are used
-\equalsNothing{#2}{
-\iftoggle{bodyCon}{
-\bodyconst{#1}
-\togglefalse{bodyCon}
-}{
-\defaultOCPConstraint\\&\quad &&#1 #2\span\span
-\togglefalse{bodyCon}
-}
-}{
-\iftoggle{bodyCon}{
-\bodyconst{#1}{#2}
-\togglefalse{bodyCon}
-}{
-\defaultOCPConstraint\\&\quad &#1 & #2\span\span
-\togglefalse{bodyCon}
-}
-}
-\togglefalse{previousThird}
-}{
-\iftoggle{bodyCon}{
-\bodyconst{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#2}{
-\defaultOCPConstraint\\&\quad &&#1 #2 && #3
-}{
-\defaultOCPConstraint\\&\quad &#1 & #2 && #3
-}
-\togglefalse{bodyCon}
-}
-\toggletrue{previousThird}
-}
-}
-
-% Standard version of adding constraints
-% The toggle previousThird indicates if the previous constraint had three arguments or two. According to that it adjust the required spans at the end of the previous contraint. It is needed because the line jump after a constraint it is done at the beginning of the next constraint, not after the constraint itself. That avoid the last jump of the last constraint.
-% The toggle bodyCon indicate that it is the first contraint. The first contraint is different that the rest because it contains "subject to"
-% The commands \equalsNothing checks if the optional arguments exists
-\DeclareDocumentCommand{\standardAddConstraint}{m G{} G{}}{
-\iftoggle{previousThird}
-{
-\renewcommand{\spanit}{}
-}{
-\renewcommand{\spanit}{\span\span}
-}
-\iftoggle{bodyCon}{
-\bodyconstRight{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#2}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\&\quad &&#1 #2
-\togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\&\quad &&#1 #2 && #3
-\toggletrue{previousThird}
-}
-}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\&\quad &#1 & #2
-\togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\&\quad &#1 & #2 && #3
-\toggletrue{previousThird}
-}
-}
-\togglefalse{bodyCon}
-}
-}
-
-
-% Adding constraints below subject to
-\DeclareDocumentCommand{\BelowAddConstraint}{m G{} G{}}{
-\iftoggle{bodyCon}{
-\bodyconstBelow{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#2}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\&&&#1 #2 \togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\&&&#1 #2 && #3
-\toggletrue{previousThird}
-}
-}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\ &&#1 &#2 \togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\ &&#1 &#2 && #3
-\toggletrue{previousThird}
-}
-}
-\togglefalse{bodyCon}
-}
-}
-
-% Adding constraints with a single alignment point but next to subject to
-\DeclareDocumentCommand{\oneAlignAddConstraint}{m G{} G{}}{
-\iftoggle{bodyCon}{
-\bodyconstOneAlign{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\&\quad &&#1 #2 \togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\&\quad &&#1 #2 && #3
-\toggletrue{previousThird}
-}
-\togglefalse{bodyCon}
-}
-}
-
-% Adding constraints for a single alignment point and with the constraints below
-\DeclareDocumentCommand{\oneAlignBelowAddConstraint}{m G{} G{}}{
-\iftoggle{bodyCon}{
-\bodyconstOneAlignBelow{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\& &&#1 #2\togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\& &&#1 #2 && #3
-\toggletrue{previousThird}
-}
-\togglefalse{bodyCon}
-}
-}
-
-% Adding constraints below "subject to" for multiple references
-\DeclareDocumentCommand{\BelowAddConstraintMult}{m G{} G{}}{
-\iftoggle{bodyCon}{
-\bodyconstBelowMult{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#3}{
-\equalsNothing{#2}{
-\defaultOCPConstraint\spanit\\&&&#1 #2
-}{
-\defaultOCPConstraint\spanit\\ &&#1 &#2
-}
-\togglefalse{previousThird}
-}{
-\equalsNothing{#2}{
-\defaultOCPConstraint\spanit\\&&&#1 #2 && #3
-}{
-\defaultOCPConstraint\spanit\\ &&#1 &#2&& #3}
-\toggletrue{previousThird}
-}
-\togglefalse{bodyCon}
-}
-}
-
-% Adding constraints for a single alignment point and with the constraints below for multiple references
-\DeclareDocumentCommand{\oneAlignBelowAddConstraintMult}{m G{} G{}}{
-\iftoggle{bodyCon}{
-\bodyconstOneAlignBelowMult{#1}{#2}{#3}
-\togglefalse{bodyCon}
-}{
-\equalsNothing{#3}{
-\defaultOCPConstraint\spanit\\& &&#1 #2 \togglefalse{previousThird}
-}{
-\defaultOCPConstraint\spanit\\& &&#1 #2 && #3
-\toggletrue{previousThird}
-}
-\togglefalse{bodyCon}
-}
-}
-%%%%%%%%%%%%%%%%%%%%
-% ADDING EXTRA LINE
-%%%%%%%%%%%%%%%%%%%%
-\newcommand{\breakObjective}[1]
-{
-\\&\mathmakebox[\widthInit]{\phantom{\underset{}{}}}#1\span\span\span\span
-}
-
-
-%%%%%%%%%%%%%%%%%%%%
-% SELECTING TYPE OF FORMAT
-%%%%%%%%%%%%%%%%%%%%
-\newcommand{\selectConstraint}[1]{
-\ifthenelse{\equal{#1}{1}}{
-\let\addConstraint\BelowAddConstraint
-}{
-\ifthenelse{\equal{#1}{2}}{
-\let\addConstraint\oneAlignAddConstraint
-}{
-\ifthenelse{\equal{#1}{3}}{
-\let\addConstraint\oneAlignBelowAddConstraint
-}{
-\let\addConstraint\standardAddConstraint}
-}
-}
-}
-
-% Selecting for multiple references
-\newcommand{\selectConstraintMult}[1]{
-\ifthenelse{\equal{#1}{1}}{
-\let\addConstraint\BelowAddConstraintMult
-}{
-\ifthenelse{\equal{#1}{2}}{
-\let\addConstraint\oneAlignAddConstraint
-}{
-\ifthenelse{\equal{#1}{3}}{
-\let\addConstraint\oneAlignBelowAddConstraintMult
-}{
-\let\addConstraint\standardAddConstraint}
-}
-}
-}
-
-%%%%%%%%%%%%%%%%%%%
-% SETTING DEFAULT FORMAT
-%%%%%%%%%%%%%%%%%%%
-% Originally, \toggletrue{bodyCon} was inside this function, however, spacing issues after environment made me remove it.
-\newcommand{\setStandardMini}{
-\let\addConstraint\standardAddConstraint
-}
-
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-% COMMANDS TO DEFINE ALL REQUIRED PROPERTIES TO CHOOSE SHORT/LONG FORMAT
-%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%%
-\newcommand{\setFormatShort}[2]{\global\def\localProblemFormat{s} \let\bodyobj\bodyobjShort \renewcommand{\localProblemType}{#1}
-\setlength{\widthInit}{\widthof{$\underset{\displaystyle #2}{\mathrm{#1}}$\quad}}
-}
-
-\newcommand{\setFormatLong}[2]{\global\def\localProblemFormat{l} \let\bodyobj\bodyobjLong \renewcommand{\localProblemType}{#1}
-\setlength{\widthInit}{\widthof{$\underset{\displaystyle #2}{\mathrm{subject~to}}$ \quad}}
-}
-
-%%%%%%%%%%%%%%%%%%%%%
-%MINIMIZATION ENVIRONMENTS
-%%%%%%%%%%%%%%%%%%%%
-
-
-% BASE ENVIRONMENTS
-% Base environment for the three possible types of referencing: 1 label, no label or multilabel
-% Base environment defined using NewEnviron package because of \BODY command
-\NewEnviron{BaseMini}[6]{%
-\selectConstraint{#1}
-\renewcommand{\localOptimalVariable}{#2}
-\begin{equation}
-#4
-\begin{alignedat}{5}
-\bodyobj{#2}{#3}{#6}{#5}
-\BODY
-\end{alignedat}
-\end{equation}
-\setStandardMini
-}
-
-\NewEnviron{BaseMiniStar}[5]{%
-\selectConstraint{#1}
-\renewcommand{\localOptimalVariable}{#2}
-\begin{alignat*}{5}
-\bodyobj{#2}{#3}{#5}{#4}
-\BODY
-\end{alignat*}
-\setStandardMini
-}
-
-
-\NewEnviron{BaseMiniExclam}[6]{%
-\selectConstraintMult{#1}
-\renewcommand{\localOptimalVariable}{#2}
-\begin{subequations}
-#4
-\begin{alignat}{5}
-\bodyobj{#2}{#3}{#6}{#5}
-\BODY
-\end{alignat}
-\end{subequations}
-\setStandardMini
-}
-
-
-% INDIVIDUAL AND SPECIFIC ENVIRONMENTS (mini, maxi, argmini*...)
-% Specific environments defined with xparse package due to arguments options
-
-%MINIMIZATION ENVIRONMENTS
-% In the below definitions, \toggletrue{bodyCon} has to be added once the definition of the environment is finished. I tried to do inside the environment itself using \setStandardMini, but it produced some ugly text displacemente.
-
-% Single reference probems
-\DeclareDocumentEnvironment{mini}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{min}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{min}}
-% Long version problem
-{\setFormatLong{minimize}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{minimize}}
-}{\endBaseMini\toggletrue{bodyCon}}
-
-\DeclareDocumentEnvironment{argmini}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{arg~min}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{arg~min}}
-% Long version problem
-{\setFormatLong{arg~min}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{arg~min}}
-}{\endBaseMini\toggletrue{bodyCon}}
-
-
-% No reference
-\DeclareDocumentEnvironment{mini*}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{min}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{min}}
-% Long version problem
-{\setFormatLong{minimize}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{minimize}}
-}{\endBaseMiniStar\toggletrue{bodyCon}}
-
-\DeclareDocumentEnvironment{argmini*}{D||{l} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{arg~min}{#2}\BaseMiniStar{#2}{#3}{#4}{#6}{arg~min}}
-% Long version problem
-{\setFormatLong{arg~min}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{arg~min}}
-}{\endBaseMiniStar\toggletrue{bodyCon}}
-
-
-% Multiple reference
-\DeclareDocumentEnvironment{mini!}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{min}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{min}}
-% Long version problem
-{\setFormatLong{minimize}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{minimize}}
-}{\endBaseMiniExclam\toggletrue{bodyCon}}
-
-\DeclareDocumentEnvironment{argmini!}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{arg~min}{#2}\BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~min}}
-% Long version problem
-{\setFormatLong{arg~min}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~min}}
-}{\endBaseMiniExclam\toggletrue{bodyCon}}
-
-
-
-
-%MAXIMIZATION ENVIRONMENTS
-
-% Single reference probems
-\DeclareDocumentEnvironment{maxi}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{max}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{max}}
-% Long version problem
-{\setFormatLong{maximize}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{maximize}}
-}{\endBaseMini\toggletrue{bodyCon}}
-
-\DeclareDocumentEnvironment{argmaxi}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{arg~max}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{arg~max}}
-% Long version problem
-{\setFormatLong{arg~max}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{arg~max}}
-}{\endBaseMini\toggletrue{bodyCon}}
-
-
-% No reference
-\DeclareDocumentEnvironment{maxi*}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{max}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{max}}
-% Long version problem
-{\setFormatLong{maximize}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{maximize}}
-}{\endBaseMiniStar\toggletrue{bodyCon}}
-
-\DeclareDocumentEnvironment{argmaxi*}{D||{l} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{arg~max}{#2}\BaseMiniStar{#2}{#3}{#4}{#6}{arg~max}}
-% Long version problem
-{\setFormatLong{arg~max}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{arg~max}}
-}{\endBaseMiniStar\toggletrue{bodyCon}}
-
-
-% Multiple reference
-\DeclareDocumentEnvironment{maxi!}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{max}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{max}}
-% Long version problem
-{\setFormatLong{maximize}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{maximize}}
-}{\endBaseMiniExclam\toggletrue{bodyCon}}
-
-\DeclareDocumentEnvironment{argmaxi!}{D||{\defaultProblemFormat} O{0} m m m m}
-{\ifthenelse{\equal{#1}{s}}
-% Short version problem
-{\setFormatShort{arg~max}{#2}\BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~max}}
-% Long version problem
-{\setFormatLong{arg~max}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~max}}
-}{\endBaseMiniExclam\toggletrue{bodyCon}}
-\end{lstlisting}
+%\section{Code definition}
+%\begin{lstlisting}
+%\end{lstlisting}
\end{document}
diff --git a/Master/texmf-dist/tex/latex/optidef/optidef.sty b/Master/texmf-dist/tex/latex/optidef/optidef.sty
index d01c65beb36..e1e114f313c 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 2.6
+% optidef - Version 2.7
%
%Copyright 2017 Jesus Lago
%
@@ -12,10 +12,11 @@
%This work consists of the file optidef.sty.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{optidef}[2017/11/29 - version=2.6, Package for defining optimization problems]
+\ProvidesPackage{optidef}[2018/05/23 - version=2.7, Package for defining optimization problems]
\RequirePackage{environ}
\RequirePackage{mathtools}
+
\RequirePackage{xifthen}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
@@ -27,6 +28,7 @@
% Default
\newcommand{\defaultOCPConstraint}{,}
\newcommand{\defaultProblemFormat}{l}
+\newcommand{\defaultConstraintFormat}{0}
\DeclareOption{short}{
\renewcommand{\defaultProblemFormat}{s}
@@ -40,6 +42,16 @@
\renewcommand{\defaultOCPConstraint}{}
}
+\DeclareOption{c1}{
+ \renewcommand{\defaultConstraintFormat}{1}
+}
+\DeclareOption{c2}{
+ \renewcommand{\defaultConstraintFormat}{2}
+}
+\DeclareOption{c3}{
+ \renewcommand{\defaultConstraintFormat}{3}
+}
+
\ProcessOptions\relax
% This command is required to avoid breakdown of the \equal fragile command. In particular, before I had \equal{#2}{} tp check if argumetn #2 was empty. However, if the argument was a bmatrix object the command was breaking. Now this command is robust.
@@ -551,7 +563,7 @@
% In the below definitions, \toggletrue{bodyCon} has to be added once the definition of the environment is finished. I tried to do inside the environment itself using \setStandardMini, but it produced some ugly text displacemente.
% Single reference probems
-\DeclareDocumentEnvironment{mini}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{mini}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{min}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{min}}
@@ -559,7 +571,7 @@
{\setFormatLong{minimize}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{minimize}}
}{\endBaseMini\toggletrue{bodyCon}}
-\DeclareDocumentEnvironment{argmini}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{argmini}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{arg~min}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{arg~min}}
@@ -569,7 +581,7 @@
% No reference
-\DeclareDocumentEnvironment{mini*}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{mini*}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{min}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{min}}
@@ -577,7 +589,7 @@
{\setFormatLong{minimize}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{minimize}}
}{\endBaseMiniStar\toggletrue{bodyCon}}
-\DeclareDocumentEnvironment{argmini*}{D||{l} O{0} m m m m}
+\DeclareDocumentEnvironment{argmini*}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{arg~min}{#2}\BaseMiniStar{#2}{#3}{#4}{#6}{arg~min}}
@@ -587,7 +599,7 @@
% Multiple reference
-\DeclareDocumentEnvironment{mini!}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{mini!}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{min}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{min}}
@@ -595,7 +607,7 @@
{\setFormatLong{minimize}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{minimize}}
}{\endBaseMiniExclam\toggletrue{bodyCon}}
-\DeclareDocumentEnvironment{argmini!}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{argmini!}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{arg~min}{#2}\BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~min}}
@@ -605,11 +617,28 @@
+\DeclareDocumentEnvironment{minie}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
+{\ifthenelse{\equal{#1}{s}}
+ % Short version problem
+ {\setFormatShort{min}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{min}}
+ % Long version problem
+ {\setFormatLong{minimize}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{minimize}}
+}{\endBaseMiniExclam\toggletrue{bodyCon}}
+
+\DeclareDocumentEnvironment{argminie}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
+{\ifthenelse{\equal{#1}{s}}
+ % Short version problem
+ {\setFormatShort{arg~min}{#2}\BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~min}}
+ % Long version problem
+ {\setFormatLong{arg~min}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~min}}
+}{\endBaseMiniExclam\toggletrue{bodyCon}}
+
+
%MAXIMIZATION ENVIRONMENTS
% Single reference probems
-\DeclareDocumentEnvironment{maxi}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{maxi}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{max}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{max}}
@@ -617,7 +646,7 @@
{\setFormatLong{maximize}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{maximize}}
}{\endBaseMini\toggletrue{bodyCon}}
-\DeclareDocumentEnvironment{argmaxi}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{argmaxi}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{arg~max}{#2} \BaseMini{#2}{#3}{#4}{#5}{#6}{arg~max}}
@@ -627,7 +656,7 @@
% No reference
-\DeclareDocumentEnvironment{maxi*}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{maxi*}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{max}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{max}}
@@ -635,7 +664,7 @@
{\setFormatLong{maximize}{#2} \BaseMiniStar{#2}{#3}{#4}{#6}{maximize}}
}{\endBaseMiniStar\toggletrue{bodyCon}}
-\DeclareDocumentEnvironment{argmaxi*}{D||{l} O{0} m m m m}
+\DeclareDocumentEnvironment{argmaxi*}{D||{l} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{arg~max}{#2}\BaseMiniStar{#2}{#3}{#4}{#6}{arg~max}}
@@ -645,7 +674,24 @@
% Multiple reference
-\DeclareDocumentEnvironment{maxi!}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{maxi!}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
+{\ifthenelse{\equal{#1}{s}}
+ % Short version problem
+ {\setFormatShort{max}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{max}}
+ % Long version problem
+ {\setFormatLong{maximize}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{maximize}}
+}{\endBaseMiniExclam\toggletrue{bodyCon}}
+
+\DeclareDocumentEnvironment{argmaxi!}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
+{\ifthenelse{\equal{#1}{s}}
+ % Short version problem
+ {\setFormatShort{arg~max}{#2}\BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~max}}
+ % Long version problem
+ {\setFormatLong{arg~max}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~max}}
+}{\endBaseMiniExclam\toggletrue{bodyCon}}
+
+% Multiple reference
+\DeclareDocumentEnvironment{maxie}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{max}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{max}}
@@ -653,7 +699,7 @@
{\setFormatLong{maximize}{#2} \BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{maximize}}
}{\endBaseMiniExclam\toggletrue{bodyCon}}
-\DeclareDocumentEnvironment{argmaxi!}{D||{\defaultProblemFormat} O{0} m m m m}
+\DeclareDocumentEnvironment{argmaxie}{D||{\defaultProblemFormat} O{\defaultConstraintFormat} m m m m}
{\ifthenelse{\equal{#1}{s}}
% Short version problem
{\setFormatShort{arg~max}{#2}\BaseMiniExclam{#2}{#3}{#4}{#5}{#6}{arg~max}}