Closed juliacaria closed 6 years ago
Hi,
is it possible to post a working example? It is hard to help you otherwise.
Regards.
I got the same problem I'll post my working example:
\usepackage{optidef}
\begin{document}
\title{}
\author{}
\date{}
\maketitle
\begin{abstract}
\end{abstract}
\section{Section}
\begin{doublespace}
\begin{mini!}
{\delta^-,\delta^+}{w^\star_1(\sum_{i=1}^{I} \sum_{j=1}^{J} \sum_{k=1}^{K} \sum_{q=1}^{Q0} \sum_{i=1}^{I} \delta^+_{ijkqi}) + }{}{}
\breakObjective{w^\star_2(\sum_{i=1}^{I} \delta^+_{i} + \sum_{j=1}^{J} \delta^+_{j} + \sum_{k=1}^{K} \delta^+_{k} + \sum_{q=1}^{Q0} \delta^+_{q} + \sum_{i=1}^{I} \delta^+_{i}) + }
\breakObjective{w^\star_3(\sum_{k=1}^{K} \tilde{\delta^-_k}) + }
\breakObjective{w^\star_4(\sum_{q=1}^{Q0} \delta^-_q) + }
\breakObjective{w^\star_5(\sum_{i=1}^{I} \delta^+_i) + }
\addConstraint{\sum_{i=1}^{I}\sum_{j=1}^{J}\sum_{k=1}^{K} c^f_{ijk} x^f_{ijk} - \delta^+_{ijk}}{=0}{}
\addConstraint{\sum_{k=1}^{K}\sum_{q=1}^{Q0}\sum_{i=1}^{I} c^r_{kqi} x^r_{kqi}, - \delta^+_{kqi}}{=0}{}
\addConstraint{(o^f_i \cdot x^f_i) - \delta^+_i}{=0,}{\forall i \in I}
\addConstraint{(o_j \cdot x^f_j) - \delta^+_j}{=0,}{\forall j \in J}
\addConstraint{(o_k \cdot x^f_k) - \delta^+_k}{=0,}{\forall k \in K}
\addConstraint{(o_q \cdot x^r_q) - \delta^+_q}{=0,}{\forall q \in Q0}
\addConstraint{(o^r_i \cdot x^r_i) - \delta^+_i}{=0,}{\forall i \in I}
\addConstraint{x_k + \tilde{\delta^-_k}}{= EV[d_{k}],}{\forall k \in K}
\addConstraint{x_q + \delta^-_q}{= b_{k},}{\forall q \in Q0}
\addConstraint{\mu_q + \frac{\delta^-_q}{n_{max}}}{= 1,}{\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} (x^r_{k} - x^r_{i}) - \delta^+_i}{= w_i,}{\forall i \in I}
\addConstraint{\sum_{i=1}^{I} x_{i}^f - \sum_{j=1}^{J} x_{j}^f =0 }{,\sum_{k=1}^{K} x_{k}^r - \sum_{q=1}^{Q0} x_{q}^r=0,}{\sum_{q=1}^{Q0} x_{q}^r - \sum_{i=1}^{I} x_{i}^r}
\addConstraint{\lambda \sum_{i=1}^{I} x^r_{kqi}}{\leq x^r_{iq},}{\forall k \in K ,\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} \sum_{j=1}^{J} r_k x^f_{kji}}{\leq \sum_{k=1}^{K} d_k,}{\forall i \in I}
\addConstraint{r_k x^f_{k}}{=x^r_{k}}{\forall k \in K}
\addConstraint{x \in \varmathbb{R}^+, \mu \in [1,0] }{,}{}
\end{mini!}
\end{doublespace}
\end{document}
It overflows without going to the next page
Starting from Optidef 3.0 (to be released in the coming days), the package will support breaking equations across multiple pages. To get this feature before version 3.0, download the optidef.sty file from the repository and add it to your directory. For the details on how to use this new feature, scroll down to https://github.com/jeslago/optidef/issues/12#issuecomment-405655368.
Breaking equations will be done automatically for for the following environments: mini*
,argmini*
,maxi*
,argmaxi*
, mini!
,argmini!
,maxi!
,argmaxi!
.
For the mini
,maxi
, argmini
, and argmaxi
, breaking the problem is possible but it has to be done manually. In particular, instead of using mini
,maxi
, argmini
, or argmaxi
, the *
version should be used, e.g. mini*
. Then, the equation that should be uniquely numbered with a label should include the new command \labelOP{eq:label}
.
In addition to automatic breaking equations, manual breaks at selected locations can also be done using the \displaybreak
command.
Thank you very much! :-)
Marco Repetto Inviato da iPhone
Il giorno 17 lug 2018, alle ore 17:21, jeslago notifications@github.com ha scritto:
Starting from Optidef 3.0 (to be released in the coming days), the package will support breaking equations across multiple pages. To get this feature before version 3.0, download the optidef.sty file from the repository and add it to your directory.
Breaking equations will be done automatically for for the following environments: mini,argmini,maxi,argmaxi, mini!,argmini!,maxi!,argmaxi!. The following example illustrates this:
\documentclass{article} \usepackage{optidef} \usepackage{amssymb}
\begin{document}
First equation: \begin{equation} x=1 \end{equation}
Optimization problem:
\begin{mini*} {\delta^-,\delta^+}{w^\star1(\sum{i=1}^{I} \sum{j=1}^{J} \sum{k=1}^{K} \sum{q=1}^{Q0} \sum{i=1}^{I} \delta^+_{ijkqi}) + }{}{} \breakObjective{w^\star2(\sum{i=1}^{I} \delta^+{i} + \sum{j=1}^{J} \delta^+{j} + \sum{k=1}^{K} \delta^+{k} + \sum{q=1}^{Q0} \delta^+{q} + \sum{i=1}^{I} \delta^+_{i}) + } \breakObjective{w^\star3(\sum{k=1}^{K} \tilde{\delta^-_k}) + } \breakObjective{w^\star4(\sum{q=1}^{Q0} \delta^-_q) + } \breakObjective{w^\star5(\sum{i=1}^{I} \delta^+i) + } \addConstraint{\sum{i=1}^{I}\sum{j=1}^{J}\sum{k=1}^{K} c^f{ijk} x^f{ijk} - \delta^+{ijk}}{=0}{} \addConstraint{\sum{k=1}^{K}\sum{q=1}^{Q0}\sum{i=1}^{I} c^r{kqi} x^r{kqi}, - \delta^+_{kqi}}{=0}{} \addConstraint{(o^f_i \cdot x^f_i) - \delta^+_i}{=0,}{\forall i \in I} \addConstraint{(o_j \cdot x^f_j) - \delta^+_j}{=0,}{\forall j \in J} \addConstraint{(o_k \cdot x^f_k) - \delta^+_k}{=0,}{\forall k \in K} \addConstraint{(o_q \cdot x^r_q) - \delta^+_q}{=0,}{\forall q \in Q0} \addConstraint{(o^r_i \cdot x^r_i) - \delta^+_i}{=0,}{\forall i \in I} \addConstraint{x_k + \tilde{\delta^-k}}{= EV[d{k}],}{\forall k \in K}
\addConstraint{x_q + \delta^-q}{= b{k},}{\forall q \in Q0} \addConstraint{\mu_q + \frac{\delta^-q}{n{max}}}{= 1,}{\forall q \in Q0} \addConstraint{\sum{k=1}^{K} (x^r{k} - x^r_{i}) - \delta^+_i}{= wi,}{\forall i \in I} \addConstraint{\sum{i=1}^{I} x{i}^f - \sum{j=1}^{J} x{j}^f =0 }{,\sum{k=1}^{K} x{k}^r - \sum{q=1}^{Q0} x{q}^r=0,}{\sum{q=1}^{Q0} x{q}^r - \sum{i=1}^{I} x{i}^r} \addConstraint{\lambda \sum{i=1}^{I} x^r{kqi}}{\leq x^r{iq},}{\forall k \in K ,\forall q \in Q0} \addConstraint{\sum{k=1}^{K} \sum{j=1}^{J} rk x^f{kji}}{\leq \sum_{k=1}^{K} d_k,}{\forall i \in I} \addConstraint{rk x^f{k}}{=x^r_{k}}{\forall k \in K} \addConstraint{x \in \mathbb{R}^+, \mu \in [1,0] }{,}{} \end{mini!}\end{document} For the mini,maxi, argmini, and argmaxi, breaking the problem is possible but it has to be done manually. In particular, instead of using one of them, the version should be used, e.g. mini. Then, the equation that should be uniquely numbered with a label should include the new command \labelOP{eq:label}. For example:
\documentclass{article} \usepackage{optidef} \usepackage{amssymb}
\begin{document}
First equation: \begin{equation} x=1 \end{equation}
Optimization problem:
\begin{mini} {\delta^-,\delta^+}{w^\star1(\sum{i=1}^{I} \sum{j=1}^{J} \sum{k=1}^{K} \sum{q=1}^{Q0} \sum{i=1}^{I} \delta^+_{ijkqi}) + }{}{} \breakObjective{w^\star2(\sum{i=1}^{I} \delta^+{i} + \sum{j=1}^{J} \delta^+{j} + \sum{k=1}^{K} \delta^+{k} + \sum{q=1}^{Q0} \delta^+{q} + \sum{i=1}^{I} \delta^+_{i}) + } \breakObjective{w^\star3(\sum{k=1}^{K} \tilde{\delta^-_k}) + } \breakObjective{w^\star4(\sum{q=1}^{Q0} \delta^-_q) + } \breakObjective{w^\star5(\sum{i=1}^{I} \delta^+i) + } \addConstraint{\sum{i=1}^{I}\sum{j=1}^{J}\sum{k=1}^{K} c^f{ijk} x^f{ijk} - \delta^+{ijk}}{=0}{} \addConstraint{\sum{k=1}^{K}\sum{q=1}^{Q0}\sum{i=1}^{I} c^r{kqi} x^r{kqi}, - \delta^+_{kqi}}{=0}{} \addConstraint{(o^f_i \cdot x^f_i) - \delta^+_i}{=0,}{\forall i \in I \labelOP{myeq1}} \addConstraint{(o_j \cdot x^f_j) - \delta^+_j}{=0,}{\forall j \in J} \addConstraint{(o_k \cdot x^f_k) - \delta^+_k}{=0,}{\forall k \in K} \addConstraint{(o_q \cdot x^r_q) - \delta^+_q}{=0,}{\forall q \in Q0} \addConstraint{(o^r_i \cdot x^r_i) - \delta^+_i}{=0,}{\forall i \in I} \addConstraint{x_k + \tilde{\delta^-k}}{= EV[d{k}],}{\forall k \in K}
\addConstraint{x_q + \delta^-q}{= b{k},}{\forall q \in Q0} \addConstraint{\mu_q + \frac{\delta^-q}{n{max}}}{= 1,}{\forall q \in Q0} \addConstraint{\sum{k=1}^{K} (x^r{k} - x^r_{i}) - \delta^+_i}{= wi,}{\forall i \in I} \addConstraint{\sum{i=1}^{I} x{i}^f - \sum{j=1}^{J} x{j}^f =0 }{,\sum{k=1}^{K} x{k}^r - \sum{q=1}^{Q0} x{q}^r=0,}{\sum{q=1}^{Q0} x{q}^r - \sum{i=1}^{I} x{i}^r} \addConstraint{\lambda \sum{i=1}^{I} x^r{kqi}}{\leq x^r{iq},}{\forall k \in K ,\forall q \in Q0} \addConstraint{\sum{k=1}^{K} \sum{j=1}^{J} rk x^f{kji}}{\leq \sum_{k=1}^{K} d_k,}{\forall i \in I} \addConstraint{rk x^f{k}}{=x^r_{k}}{\forall k \in K} \addConstraint{x \in \mathbb{R}^+, \mu \in [1,0] }{,}{} \end{mini}The optimization problem defined by \eqref{myeq1} is split into two pages. \end{document} — You are receiving this because you commented. Reply to this email directly, view it on GitHub, or mute the thread.
@mrepetto94 Can you confirm that the solution works for you?
I’ll test it ASAP and let you know ;)
Il giorno 17 lug 2018, alle ore 17:27, jeslago notifications@github.com ha scritto:
@mrepetto94 Can you confirm that the solution works for you?
— You are receiving this because you were mentioned. Reply to this email directly, view it on GitHub, or mute the thread.
Doesn't this allow breaking everywhere and not only for optidef-environments?
Maybe you can scope it locally and make an option to enable/disable it, cf. https://tex.stackexchange.com/questions/102173/using-allowdisplaybreaks-locally-for-a-single-chapter-single-equation/102174 ?
Yes indeed it does. I thought about making it optional, but as I didn't see the problem of allowing it globally, I thought it was adding unnecessary complexity to the library.
Can you briefly explain what could be the problem of making it globally?
It may look ugly in some cases :-) as it may break a 10 line equation leaving just 2 on the next page.
Also note that \allowdisplaybreaks
takes optional parameters controlling the strength. Maybe for some \allowdisplaybreaks
may be sufficient while others need \allowdisplaybreaks[4]
.
I see. In that case, I will make an option and document it. It will make more sense.
I have implemented a cleaner solution. I would appreciate some feedback @bonanza123 @mrepetto94. Instructions below:
Breaking equations is now optional for any of the 12 environments using the optional argument <b>
. The following example illustrate this:
\documentclass{article}
\usepackage{optidef}
\usepackage{amssymb}
\begin{document}
First equation:
\begin{equation}
x=1
\end{equation}
Optimization problem:
\begin{mini!}<b>
{\delta^-,\delta^+}{w^\star_1(\sum_{i=1}^{I} \sum_{j=1}^{J} \sum_{k=1}^{K} \sum_{q=1}^{Q0} \sum_{i=1}^{I} \delta^+_{ijkqi}) + }{}{}
\breakObjective{w^\star_2(\sum_{i=1}^{I} \delta^+_{i} + \sum_{j=1}^{J} \delta^+_{j} + \sum_{k=1}^{K} \delta^+_{k} + \sum_{q=1}^{Q0} \delta^+_{q} + \sum_{i=1}^{I} \delta^+_{i}) + }
\breakObjective{w^\star_3(\sum_{k=1}^{K} \tilde{\delta^-_k}) + }
\breakObjective{w^\star_4(\sum_{q=1}^{Q0} \delta^-_q) + }
\breakObjective{w^\star_5(\sum_{i=1}^{I} \delta^+_i) + }
\addConstraint{\sum_{i=1}^{I}\sum_{j=1}^{J}\sum_{k=1}^{K} c^f_{ijk} x^f_{ijk} - \delta^+_{ijk}}{=0}{}
\addConstraint{\sum_{k=1}^{K}\sum_{q=1}^{Q0}\sum_{i=1}^{I} c^r_{kqi} x^r_{kqi}, - \delta^+_{kqi}}{=0}{}
\addConstraint{(o^f_i \cdot x^f_i) - \delta^+_i}{=0,}{\forall i \in I }
\addConstraint{(o_j \cdot x^f_j) - \delta^+_j}{=0,}{\forall j \in J}
\addConstraint{(o_k \cdot x^f_k) - \delta^+_k}{=0,}{\forall k \in K}
\addConstraint{(o_q \cdot x^r_q) - \delta^+_q}{=0,}{\forall q \in Q0}
\addConstraint{(o^r_i \cdot x^r_i) - \delta^+_i}{=0,}{\forall i \in I}
\addConstraint{x_k + \tilde{\delta^-_k}}{= EV[d_{k}],}{\forall k \in K}
\addConstraint{x_q + \delta^-_q}{= b_{k},}{\forall q \in Q0}
\addConstraint{\mu_q + \frac{\delta^-_q}{n_{max}}}{= 1,}{\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} (x^r_{k} - x^r_{i}) - \delta^+_i}{= w_i,}{\forall i \in I}
\addConstraint{\sum_{i=1}^{I} x_{i}^f - \sum_{j=1}^{J} x_{j}^f =0 }{,\sum_{k=1}^{K} x_{k}^r - \sum_{q=1}^{Q0} x_{q}^r=0,}{\sum_{q=1}^{Q0} x_{q}^r - \sum_{i=1}^{I} x_{i}^r}
\addConstraint{\lambda \sum_{i=1}^{I} x^r_{kqi}}{\leq x^r_{iq},}{\forall k \in K ,\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} \sum_{j=1}^{J} r_k x^f_{kji}}{\leq \sum_{k=1}^{K} d_k,}{\forall i \in I}
\addConstraint{r_k x^f_{k}}{=x^r_{k}}{\forall k \in K}
\addConstraint{x \in \mathbb{R}^+, \mu \in [1,0] }{,}{}
\end{mini!}
\end{document}
The output of the code above can be compared with the following example where breaking is not allowed:
\documentclass{article}
\usepackage{optidef}
\usepackage{amssymb}
\begin{document}
First equation:
\begin{equation}
x=1
\end{equation}
Optimization problem:
\begin{mini!}
{\delta^-,\delta^+}{w^\star_1(\sum_{i=1}^{I} \sum_{j=1}^{J} \sum_{k=1}^{K} \sum_{q=1}^{Q0} \sum_{i=1}^{I} \delta^+_{ijkqi}) + }{}{}
\breakObjective{w^\star_2(\sum_{i=1}^{I} \delta^+_{i} + \sum_{j=1}^{J} \delta^+_{j} + \sum_{k=1}^{K} \delta^+_{k} + \sum_{q=1}^{Q0} \delta^+_{q} + \sum_{i=1}^{I} \delta^+_{i}) + }
\breakObjective{w^\star_3(\sum_{k=1}^{K} \tilde{\delta^-_k}) + }
\breakObjective{w^\star_4(\sum_{q=1}^{Q0} \delta^-_q) + }
\breakObjective{w^\star_5(\sum_{i=1}^{I} \delta^+_i) + }
\addConstraint{\sum_{i=1}^{I}\sum_{j=1}^{J}\sum_{k=1}^{K} c^f_{ijk} x^f_{ijk} - \delta^+_{ijk}}{=0}{}
\addConstraint{\sum_{k=1}^{K}\sum_{q=1}^{Q0}\sum_{i=1}^{I} c^r_{kqi} x^r_{kqi}, - \delta^+_{kqi}}{=0}{}
\addConstraint{(o^f_i \cdot x^f_i) - \delta^+_i}{=0,}{\forall i \in I }
\addConstraint{(o_j \cdot x^f_j) - \delta^+_j}{=0,}{\forall j \in J}
\addConstraint{(o_k \cdot x^f_k) - \delta^+_k}{=0,}{\forall k \in K}
\addConstraint{(o_q \cdot x^r_q) - \delta^+_q}{=0,}{\forall q \in Q0}
\addConstraint{(o^r_i \cdot x^r_i) - \delta^+_i}{=0,}{\forall i \in I}
\addConstraint{x_k + \tilde{\delta^-_k}}{= EV[d_{k}],}{\forall k \in K}
\addConstraint{x_q + \delta^-_q}{= b_{k},}{\forall q \in Q0}
\addConstraint{\mu_q + \frac{\delta^-_q}{n_{max}}}{= 1,}{\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} (x^r_{k} - x^r_{i}) - \delta^+_i}{= w_i,}{\forall i \in I}
\addConstraint{\sum_{i=1}^{I} x_{i}^f - \sum_{j=1}^{J} x_{j}^f =0 }{,\sum_{k=1}^{K} x_{k}^r - \sum_{q=1}^{Q0} x_{q}^r=0,}{\sum_{q=1}^{Q0} x_{q}^r - \sum_{i=1}^{I} x_{i}^r}
\addConstraint{\lambda \sum_{i=1}^{I} x^r_{kqi}}{\leq x^r_{iq},}{\forall k \in K ,\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} \sum_{j=1}^{J} r_k x^f_{kji}}{\leq \sum_{k=1}^{K} d_k,}{\forall i \in I}
\addConstraint{r_k x^f_{k}}{=x^r_{k}}{\forall k \in K}
\addConstraint{x \in \mathbb{R}^+, \mu \in [1,0] }{,}{}
\end{mini!}
\end{document}
For the mini
,maxi
, argmini
, and argmaxi
, breaking is possible but it does not automatically set the numbering nor the unique label of the environment. To create the unique label for any of the previous environments the command \labelOP{label}
should be used. In particular, in the equation/constraint of the optimization problem where the label/number should be located, simply add \labelOP{eq:label}
. For example:
\documentclass{article}
\usepackage{optidef}
\usepackage{amssymb}
\begin{document}
First equation:
\begin{equation}
x=1
\end{equation}
Optimization problem:
\begin{mini}<b>
{\delta^-,\delta^+}{w^\star_1(\sum_{i=1}^{I} \sum_{j=1}^{J} \sum_{k=1}^{K} \sum_{q=1}^{Q0} \sum_{i=1}^{I} \delta^+_{ijkqi}) + }{}{}
\breakObjective{w^\star_2(\sum_{i=1}^{I} \delta^+_{i} + \sum_{j=1}^{J} \delta^+_{j} + \sum_{k=1}^{K} \delta^+_{k} + \sum_{q=1}^{Q0} \delta^+_{q} + \sum_{i=1}^{I} \delta^+_{i}) + }
\breakObjective{w^\star_3(\sum_{k=1}^{K} \tilde{\delta^-_k}) + }
\breakObjective{w^\star_4(\sum_{q=1}^{Q0} \delta^-_q) + }
\breakObjective{w^\star_5(\sum_{i=1}^{I} \delta^+_i) + }
\addConstraint{\sum_{i=1}^{I}\sum_{j=1}^{J}\sum_{k=1}^{K} c^f_{ijk} x^f_{ijk} - \delta^+_{ijk}}{=0}{}
\addConstraint{\sum_{k=1}^{K}\sum_{q=1}^{Q0}\sum_{i=1}^{I} c^r_{kqi} x^r_{kqi}, - \delta^+_{kqi}}{=0}{}
\addConstraint{(o^f_i \cdot x^f_i) - \delta^+_i}{=0,}{\forall i \in I \labelOP{myeq1}}
\addConstraint{(o_j \cdot x^f_j) - \delta^+_j}{=0,}{\forall j \in J}
\addConstraint{(o_k \cdot x^f_k) - \delta^+_k}{=0,}{\forall k \in K}
\addConstraint{(o_q \cdot x^r_q) - \delta^+_q}{=0,}{\forall q \in Q0}
\addConstraint{(o^r_i \cdot x^r_i) - \delta^+_i}{=0,}{\forall i \in I}
\addConstraint{x_k + \tilde{\delta^-_k}}{= EV[d_{k}],}{\forall k \in K}
\addConstraint{x_q + \delta^-_q}{= b_{k},}{\forall q \in Q0}
\addConstraint{\mu_q + \frac{\delta^-_q}{n_{max}}}{= 1,}{\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} (x^r_{k} - x^r_{i}) - \delta^+_i}{= w_i,}{\forall i \in I}
\addConstraint{\sum_{i=1}^{I} x_{i}^f - \sum_{j=1}^{J} x_{j}^f =0 }{,\sum_{k=1}^{K} x_{k}^r - \sum_{q=1}^{Q0} x_{q}^r=0,}{\sum_{q=1}^{Q0} x_{q}^r - \sum_{i=1}^{I} x_{i}^r}
\addConstraint{\lambda \sum_{i=1}^{I} x^r_{kqi}}{\leq x^r_{iq},}{\forall k \in K ,\forall q \in Q0}
\addConstraint{\sum_{k=1}^{K} \sum_{j=1}^{J} r_k x^f_{kji}}{\leq \sum_{k=1}^{K} d_k,}{\forall i \in I}
\addConstraint{r_k x^f_{k}}{=x^r_{k}}{\forall k \in K}
\addConstraint{x \in \mathbb{R}^+, \mu \in [1,0] }{,}{}
\end{mini}
The optimization problem defined by \eqref{myeq1} is split into two pages.
\end{document}
In addition to automatic breaking equations, manual breaks at selected locations can also be done using the \displaybreak
command. Just add \displaybreak
between the two constraints that need to be broken.
It works like a charm mate :D thank you very much!
I am closing this issue. Version 3.0 is now released and includes the possibility of breaking the optimization problems.
First of all, congrats and thank you for this wonderful tool! =) I'm having trouble with my equations. I have a mathematical model and I don't want to break it in many \begin{mini!} \end{mini!}, however I can't have a new page, as I wrote an equation it is hidden as the page is over. This also happens in the width of the page.
Thanks.