1

I am writing an optimisation problem with 50 constraints. My code is below.

\begin{equation*}
\begin{aligned}
{\underset{x_{i}}{\textnormal{minimise}}} \quad  
&800\left(\sum_{i=1}^{89}x_i\right)+99\left(x_{34}+x_{81}\right)  \\
\mathllap{\text{subject to} \quad} 
&x_{11}+x{12}\geq 1 \\
&x_{13}+x{14}\geq 1 \\
&x_{18}+x{19}\geq 1 \\
....
\end{aligned}
\end{equation*}

For convenience, I have denoted the remaining constraints by the ellipsis "...". For some reason, the whole optimisation problem begins on a new page once the contraints reach the bottom of the existing page. Not only this, but the constraints that do not fit on this single page are not displayed.

Is there a way to intelligently format this optimisation problem?

Edit

I am using the packages

\usepackage[english]{babel}
\usepackage[utf8x]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins \usepackage[a4paper,top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm,marginparwidth=1.75cm]{geometry}

\usepackage{amsmath} \usepackage{amsfonts} \usepackage{amssymb} \usepackage{amsthm} \usepackage{mathtools} \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode}

imnothere
  • 14,215
M B
  • 152
  • 3
    Have you tried inserting the instruction \allowdisplaybreaks before begin{equation*}? – Mico Nov 17 '20 at 05:52
  • Off-topic: What's the purpose of the \mathllap "wrapper"? I'd get rid of it. – Mico Nov 17 '20 at 05:58
  • @Mico I tried \allowdisplaybreaks, but it did not work (does it require a particular package?) I removed \mathllap (I took that from a previous example that I wrote using rcases). – M B Nov 17 '20 at 06:00
  • 2
    Please clarify what "it did not work" entails. \allowdisplaybreaks is a macro provided by the amsmath package -- the same package that provides the equation* and aligned environments. The purpose of \allowdisplaybreaks is to, well, allow page breaks in multi-line displayed equation environments. (As you've discovered, such page breaks are not allowed by default.) – Mico Nov 17 '20 at 06:12
  • 2
    I don't know about your other code, but here \mathllap does nothing except create code clutter. – Mico Nov 17 '20 at 06:13
  • @Mico Apologies for not being specific. There was no change in my document after I inserted \allowdisplaybreaks before \begin{equation*}. That is, it did not change anything. – M B Nov 17 '20 at 06:16
  • @Mico I have edited my original post, including the packages that I am using in my document. As for the the equation* itself, this has been copied and pasted into my post. The only difference is that I have left out all of the constraints for simplicity (in my post I have included the first three constraints, namely: x_{11}+x{12}\geq 1, x_{13}+x{14}\geq 1, and x_{18}+x{19}\geq 1 ... I did not think it would be necesary to include all 50 constraints). – M B Nov 17 '20 at 06:23
  • Please see the answer I posted a short while ago. – Mico Nov 17 '20 at 06:33

2 Answers2

2

The command \allowdisplaybreaks, provided by the amsmath package, is supposed to allow page breaks inside multi-line diplayed equations. However, as is explained in subsection 3.9, "Vertical spacing and page breaks in multiline displays", of the user guide of the amsmath package, \allowdisplaybreaks does not operate on the contents of split, aligned, gathered, and alignedat environments.

To fix this, I suggest you place all equations in a single align* environment instead of nesting an aligned environment inside an equation* environment.

enter image description here

\documentclass{article} % choose a suitable document class
\usepackage[english]{babel}
\usepackage[utf8]{inputenc}
\usepackage[T1]{fontenc}

%% Sets page size and margins \usepackage[a4paper, %top=2.5cm,bottom=2.5cm,left=2.5cm,right=2.5cm, margin=2.5cm, marginparwidth=1.75cm]{geometry}

%\usepackage{amsmath} % is loaded automatically by 'mathtools' %\usepackage{amsfonts} % is loaded automatically by 'amssymb' \usepackage{amssymb} \usepackage{amsthm} \usepackage{mathtools} % \usepackage[framed,numbered,autolinebreaks,useliterate]{mcode} % I don't have this package

\begin{document} \allowdisplaybreaks

\begin{align} \underset{x_{i}}{\textnormal{minimise}}\quad
&800\biggl(,\sum_{i=1}^{89}x_i\biggr)+99(x_{34}+x_{81}) \ \textnormal{subject to} \quad &x_{11}+x_{12}\geq 1 \ &x_{13}+x_{14}\geq 1 \ &x_{18}+x_{19}\geq 1 \ &\dots \end{align
}

\end{document}

Mico
  • 506,678
  • 1
    This worked brilliantly. My optimisation problem does not begin on a new page and all constraints are displayed over multiple pages. Thank you. – M B Nov 17 '20 at 06:55
2

Let me mention there exists a dedicated package: optidef, which defines several optimisation environments, with various layouts, which accept a <b> optional argument to break the environment across pages. Here is a code using the mini* environment:

\documentclass{article}
\usepackage[english]{babel}
\usepackage[T1]{fontenc}
\usepackage[a4paper, margin=2.5cm, marginparwidth=1.75cm]{geometry}
\usepackage{amssymb}
\usepackage{amsthm}
\usepackage{mathtools}
\usepackage{optidef} % dedicated package

\begin{document}

\begin{mini}<b> {x_{i}}{800\biggl(,\sum_{i=1}^{89}x_i\biggr)+99(x_{34}+x_{81})} {}{} \addConstraint{x_{11}+x_{12}\geq 1} \addConstraint{x_{13}+x_{14}\geq 1} \addConstraint{x_{18}+x_{19}\geq 1} \addConstraint{\dots\dots\dots\dots} \end{mini}

\end{document}

enter image description here

Bernard
  • 271,350
  • Is there a way to write multiple arguments under the minimize, e.g. as asked for in a previous post – M B Nov 17 '20 at 23:40
  • yes, you type what you want for the first argument of the environment. You might try with \substack{... \\...}, for instance. – Bernard Nov 17 '20 at 23:46
  • This is truly a great package. One last question: I am having trouble aligning the \geq signs. Instead of aligning the beginning of each contraint with the beginning of the objective function, is it possible to align the \geq signs of the constraints? – M B Nov 17 '20 at 23:57
  • 1
    Yes: instead of \addConstraint{x_{11}+x_{12}\geq 1}, &c., write \addConstraint{x_{11}+x_{12}}{\geq 1}. You can see more possibilities, in §6 of the documentation, pp. 8-9: Output Formats for the Constraints. – Bernard Nov 18 '20 at 00:07