summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorKarl Berry <karl@freefriends.org>2016-09-26 20:52:50 +0000
committerKarl Berry <karl@freefriends.org>2016-09-26 20:52:50 +0000
commit0aeb54ea38eda4571b93e571228e81a29444730c (patch)
tree332c9a60c51b8725486caa2eb8c8e1398a0538bd
parent1302eeeb3978a70f34e873a949d47684c8d5a534 (diff)
optidef (26sep16)
git-svn-id: svn://tug.org/texlive/trunk@42154 c570f23f-e606-0410-a88d-b1316a301751
-rw-r--r--Master/texmf-dist/doc/latex/optidef/README.md4
-rw-r--r--Master/texmf-dist/doc/latex/optidef/optidef.pdfbin279131 -> 263646 bytes
-rw-r--r--Master/texmf-dist/doc/latex/optidef/optidef.tex90
-rw-r--r--Master/texmf-dist/tex/latex/optidef/optidef.sty55
4 files changed, 91 insertions, 58 deletions
diff --git a/Master/texmf-dist/doc/latex/optidef/README.md b/Master/texmf-dist/doc/latex/optidef/README.md
index 27b97b66675..fcb4a93c217 100644
--- a/Master/texmf-dist/doc/latex/optidef/README.md
+++ b/Master/texmf-dist/doc/latex/optidef/README.md
@@ -60,11 +60,11 @@ Finally note that \begin{mini#} can be substituted by \begin{maxi#}, \begin{argm
## Contact for issue reporting or suggestions
-E-mail: jesus.lago.garcia@venus.uni-freiburg.de
+E-mail: j.lagogarcia@tudelft.nl
Github: https://github.com/jeslago/optidef
-## Latest stable version: Optidef 2.0
+## Latest stable version: Optidef 2.1
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 1e53a7209ee..3f7749a2f57 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 067cb104208..73c1e667126 100644
--- a/Master/texmf-dist/doc/latex/optidef/optidef.tex
+++ b/Master/texmf-dist/doc/latex/optidef/optidef.tex
@@ -1,16 +1,13 @@
\documentclass[a4paper]{article}
\usepackage{remreset}
-\usepackage{optidef}
+\usepackage[short]{optidef}
\usepackage{listings}
\usepackage{enumitem}
\usepackage{hyperref}
-\lstset{
- language=TeX,
- breaklines=true,
-}
+\lstset{basicstyle=\ttfamily,breaklines=true}
% Title Page
-\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 2.0}}
+\title{\textit{\textbf{Optidef}} \\ A Latex library for optimization problems\\ \textnormal{Version - 2.1}}
\author{Jesus Lago Garcia}
@@ -40,6 +37,19 @@ This Latex library provides a standard set of environments for writing optimizat
\item Four different type of problems: \textit{minimize}, \textit{maximize}, \textit{arg min} and \textit{arg max}.
\end{enumerate}
+\section{Using the package}
+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|:
+
+\begin{lstlisting}
+\usepackage[short,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.
+
\section{Environment Syntax Definition}
Considering that \verb|Const.i| stands for constraint $i$, \verb|LHS.i| stands for the left-hand-side of constraint $i$, and \verb|RHS.i| for the right-hand-side counterpart, the basic structure to define a general optimization problem with $N$ constraints is:
\begin{verbatim}
@@ -171,6 +181,12 @@ Selected by \verb|sizeFormat|=s. It uses instead the shorter \textit{s.t.} and \
\addConstraint{g(w)}{=0}
\end{mini*}
+\noindent By the default the long format is used. To change the default to the short format the package must be imported with the \verb|short| option:
+
+\begin{lstlisting}
+\usepackage[short]{optidef}
+\end{lstlisting}
+
\section{Alignment of Equations}
\label{sec:alignment}
@@ -244,6 +260,13 @@ There are four basic output formats for the location of the constraints. They ar
\addConstraint{t(w)}{=0.}
\end{mini}
+\section{Default comma at the end of the constraint}
+\label{sec:comma}
+By default, the algorithms adds a comma at the end of any constraint that is not the last one. This feature was implemented due to correctness of mathematical notation. However, this behavior can be removed by adding the option \verb|nocomma| when importing the package:
+
+\begin{lstlisting}
+\usepackage[nocomma]{optidef}
+\end{lstlisting}
\section{Examples}
\subsection{Example 1 - mini environment}
@@ -586,7 +609,7 @@ The standard appearance for long optimization variables is as follows:
\section{Code definition}
\begin{lstlisting}
-% optidef - Version 2.0
+% optidef - Version 2.1
%
%Copyright 2016 J. Lago Garcia
%
@@ -600,11 +623,11 @@ The standard appearance for long optimization variables is as follows:
%This work consists of the file optidef.sty.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{optidef}[2016/08/07 - version=2.0, Package for defining optimization problems]
+\ProvidesPackage{optidef}[2016/09/25 - version=2.1, Package for defining optimization problems]
\RequirePackage{environ}
\RequirePackage{mathtools}
-\RequirePackage{xifthen}
+\RequirePackage{xifthen}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\RequirePackage{calc}
@@ -613,6 +636,7 @@ The standard appearance for long optimization variables is as follows:
% DEFINING PACKAGE OPTIONS
%%%%%%%%%%%%%%%%%%%%%%%
% Default
+\newcommand{\defaultOCPConstraint}{,}
\newcommand{\defaultProblemFormat}{l}
\DeclareOption{short}{
@@ -623,6 +647,10 @@ The standard appearance for long optimization variables is as follows:
\renewcommand{\defaultProblemFormat}{l}
}
+\DeclareOption{nocomma}{
+\renewcommand{\defaultOCPConstraint}{}
+}
+
\ProcessOptions\relax
%%%%%%%%%%%%%%%%%%%%%%%
@@ -852,7 +880,7 @@ The standard appearance for long optimization variables is as follows:
\bodyconst{#1}
\togglefalse{bodyCon}
}{
-,\\&\quad &&#1 #2\span\span
+\defaultOCPConstraint\\&\quad &&#1 #2\span\span
\togglefalse{bodyCon}
}
}{
@@ -860,7 +888,7 @@ The standard appearance for long optimization variables is as follows:
\bodyconst{#1}{#2}
\togglefalse{bodyCon}
}{
-,\\&\quad &#1 & #2\span\span
+\defaultOCPConstraint\\&\quad &#1 & #2\span\span
\togglefalse{bodyCon}
}
}
@@ -871,9 +899,9 @@ The standard appearance for long optimization variables is as follows:
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#2}{}}{
-,\\&\quad &&#1 #2 && #3
+\defaultOCPConstraint\\&\quad &&#1 #2 && #3
}{
-,\\&\quad &#1 & #2 && #3
+\defaultOCPConstraint\\&\quad &#1 & #2 && #3
}
\togglefalse{bodyCon}
}
@@ -892,18 +920,18 @@ The standard appearance for long optimization variables is as follows:
}{
\ifthenelse{\equal{#2}{}}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\&\quad &&#1 #2
+\defaultOCPConstraint\spanit\\&\quad &&#1 #2
\togglefalse{previousThird}
}{
-,\spanit\\&\quad &&#1 #2 && #3
+\defaultOCPConstraint\spanit\\&\quad &&#1 #2 && #3
\toggletrue{previousThird}
}
}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\&\quad &#1 & #2
+\defaultOCPConstraint\spanit\\&\quad &#1 & #2
\togglefalse{previousThird}
}{
-,\spanit\\&\quad &#1 & #2 && #3
+\defaultOCPConstraint\spanit\\&\quad &#1 & #2 && #3
\toggletrue{previousThird}
}
}
@@ -919,16 +947,16 @@ The standard appearance for long optimization variables is as follows:
}{
\ifthenelse{\equal{#2}{}}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\&&&#1 #2 \togglefalse{previousThird}
+\defaultOCPConstraint\spanit\\&&&#1 #2 \togglefalse{previousThird}
}{
-,\spanit\\&&&#1 #2 && #3
+\defaultOCPConstraint\spanit\\&&&#1 #2 && #3
\toggletrue{previousThird}
}
}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\ &&#1 &#2 \togglefalse{previousThird}
+\defaultOCPConstraint\spanit\\ &&#1 &#2 \togglefalse{previousThird}
}{
-,\spanit\\ &&#1 &#2 && #3
+\defaultOCPConstraint\spanit\\ &&#1 &#2 && #3
\toggletrue{previousThird}
}
}
@@ -943,9 +971,9 @@ The standard appearance for long optimization variables is as follows:
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\&\quad &&#1 #2 \togglefalse{previousThird}
+\defaultOCPConstraint\spanit\\&\quad &&#1 #2 \togglefalse{previousThird}
}{
-,\spanit\\&\quad &&#1 #2 && #3
+\defaultOCPConstraint\spanit\\&\quad &&#1 #2 && #3
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
@@ -959,9 +987,9 @@ The standard appearance for long optimization variables is as follows:
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\& &&#1 #2\togglefalse{previousThird}
+\defaultOCPConstraint\spanit\\& &&#1 #2\togglefalse{previousThird}
}{
-,\spanit\\& &&#1 #2 && #3
+\defaultOCPConstraint\spanit\\& &&#1 #2 && #3
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
@@ -976,16 +1004,16 @@ The standard appearance for long optimization variables is as follows:
}{
\ifthenelse{\equal{#3}{}}{
\ifthenelse{\equal{#2}{}}{
-,\spanit\\&&&#1 #2
+\defaultOCPConstraint\spanit\\&&&#1 #2
}{
-,\spanit\\ &&#1 &#2
+\defaultOCPConstraint\spanit\\ &&#1 &#2
}
\togglefalse{previousThird}
}{
\ifthenelse{\equal{#2}{}}{
-,\spanit\\&&&#1 #2 && #3
+\defaultOCPConstraint\spanit\\&&&#1 #2 && #3
}{
-,\spanit\\ &&#1 &#2&& #3}
+\defaultOCPConstraint\spanit\\ &&#1 &#2&& #3}
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
@@ -999,9 +1027,9 @@ The standard appearance for long optimization variables is as follows:
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#3}{}}{
-,\spanit\\& &&#1 #2 \togglefalse{previousThird}
+\defaultOCPConstraint\spanit\\& &&#1 #2 \togglefalse{previousThird}
}{
-,\spanit\\& &&#1 #2 && #3
+\defaultOCPConstraint\spanit\\& &&#1 #2 && #3
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
diff --git a/Master/texmf-dist/tex/latex/optidef/optidef.sty b/Master/texmf-dist/tex/latex/optidef/optidef.sty
index 796992d5d22..b52ee18762e 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.0
+% optidef - Version 2.1
%
%Copyright 2016 J. Lago Garcia
%
@@ -12,11 +12,11 @@
%This work consists of the file optidef.sty.
\NeedsTeXFormat{LaTeX2e}
-\ProvidesPackage{optidef}[2016/08/07 - version=2.0, Package for defining optimization problems]
+\ProvidesPackage{optidef}[2016/09/25 - version=2.1, Package for defining optimization problems]
\RequirePackage{environ}
\RequirePackage{mathtools}
-\RequirePackage{xifthen}
+\RequirePackage{xifthen}
\RequirePackage{etoolbox}
\RequirePackage{xparse}
\RequirePackage{calc}
@@ -25,6 +25,7 @@
% DEFINING PACKAGE OPTIONS
%%%%%%%%%%%%%%%%%%%%%%%
% Default
+\newcommand{\defaultOCPConstraint}{,}
\newcommand{\defaultProblemFormat}{l}
\DeclareOption{short}{
@@ -35,6 +36,10 @@
\renewcommand{\defaultProblemFormat}{l}
}
+\DeclareOption{nocomma}{
+ \renewcommand{\defaultOCPConstraint}{}
+}
+
\ProcessOptions\relax
%%%%%%%%%%%%%%%%%%%%%%%
@@ -264,7 +269,7 @@
\bodyconst{#1}
\togglefalse{bodyCon}
}{
- ,\\&\quad &&#1 #2\span\span
+ \defaultOCPConstraint\\&\quad &&#1 #2\span\span
\togglefalse{bodyCon}
}
}{
@@ -272,7 +277,7 @@
\bodyconst{#1}{#2}
\togglefalse{bodyCon}
}{
- ,\\&\quad &#1 & #2\span\span
+ \defaultOCPConstraint\\&\quad &#1 & #2\span\span
\togglefalse{bodyCon}
}
}
@@ -283,9 +288,9 @@
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#2}{}}{
- ,\\&\quad &&#1 #2 && #3
+ \defaultOCPConstraint\\&\quad &&#1 #2 && #3
}{
- ,\\&\quad &#1 & #2 && #3
+ \defaultOCPConstraint\\&\quad &#1 & #2 && #3
}
\togglefalse{bodyCon}
}
@@ -304,18 +309,18 @@
}{
\ifthenelse{\equal{#2}{}}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\&\quad &&#1 #2
+ \defaultOCPConstraint\spanit\\&\quad &&#1 #2
\togglefalse{previousThird}
}{
- ,\spanit\\&\quad &&#1 #2 && #3
+ \defaultOCPConstraint\spanit\\&\quad &&#1 #2 && #3
\toggletrue{previousThird}
}
}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\&\quad &#1 & #2
+ \defaultOCPConstraint\spanit\\&\quad &#1 & #2
\togglefalse{previousThird}
}{
- ,\spanit\\&\quad &#1 & #2 && #3
+ \defaultOCPConstraint\spanit\\&\quad &#1 & #2 && #3
\toggletrue{previousThird}
}
}
@@ -331,16 +336,16 @@
}{
\ifthenelse{\equal{#2}{}}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\&&&#1 #2 \togglefalse{previousThird}
+ \defaultOCPConstraint\spanit\\&&&#1 #2 \togglefalse{previousThird}
}{
- ,\spanit\\&&&#1 #2 && #3
+ \defaultOCPConstraint\spanit\\&&&#1 #2 && #3
\toggletrue{previousThird}
}
}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\ &&#1 &#2 \togglefalse{previousThird}
+ \defaultOCPConstraint\spanit\\ &&#1 &#2 \togglefalse{previousThird}
}{
- ,\spanit\\ &&#1 &#2 && #3
+ \defaultOCPConstraint\spanit\\ &&#1 &#2 && #3
\toggletrue{previousThird}
}
}
@@ -355,9 +360,9 @@
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\&\quad &&#1 #2 \togglefalse{previousThird}
+ \defaultOCPConstraint\spanit\\&\quad &&#1 #2 \togglefalse{previousThird}
}{
- ,\spanit\\&\quad &&#1 #2 && #3
+ \defaultOCPConstraint\spanit\\&\quad &&#1 #2 && #3
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
@@ -371,9 +376,9 @@
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\& &&#1 #2\togglefalse{previousThird}
+ \defaultOCPConstraint\spanit\\& &&#1 #2\togglefalse{previousThird}
}{
- ,\spanit\\& &&#1 #2 && #3
+ \defaultOCPConstraint\spanit\\& &&#1 #2 && #3
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
@@ -388,16 +393,16 @@
}{
\ifthenelse{\equal{#3}{}}{
\ifthenelse{\equal{#2}{}}{
- ,\spanit\\&&&#1 #2
+ \defaultOCPConstraint\spanit\\&&&#1 #2
}{
- ,\spanit\\ &&#1 &#2
+ \defaultOCPConstraint\spanit\\ &&#1 &#2
}
\togglefalse{previousThird}
}{
\ifthenelse{\equal{#2}{}}{
- ,\spanit\\&&&#1 #2 && #3
+ \defaultOCPConstraint\spanit\\&&&#1 #2 && #3
}{
- ,\spanit\\ &&#1 &#2&& #3}
+ \defaultOCPConstraint\spanit\\ &&#1 &#2&& #3}
\toggletrue{previousThird}
}
\togglefalse{bodyCon}
@@ -411,9 +416,9 @@
\togglefalse{bodyCon}
}{
\ifthenelse{\equal{#3}{}}{
- ,\spanit\\& &&#1 #2 \togglefalse{previousThird}
+ \defaultOCPConstraint\spanit\\& &&#1 #2 \togglefalse{previousThird}
}{
- ,\spanit\\& &&#1 #2 && #3
+ \defaultOCPConstraint\spanit\\& &&#1 #2 && #3
\toggletrue{previousThird}
}
\togglefalse{bodyCon}