3

Similar to a previous question, I need to construct a bilevel optimization. The previous question received a good answer except I need to number each equation even those in the nested aligned block.

What would be the simplest way to modify the structure below to support number of all equations? The nested aligned block yields a compile error if changed to align.

MWE (basic structure courtesy of @sergei-golovan)

\documentclass{article}
\usepackage{amsmath}
\DeclareMathOperator{\st}{s.t.}
\begin{document}

\begin{align}
  \min \limits_{\mathbf{x}, \mathbf{y}} \quad & {-}2x_1^2 + x_2^2 - 6y_1 + y_2^2 \\
    \st \quad & x_1^3 + 3x_2 - 10 \le 0 \\
        & \begin{aligned}
            \st \quad & {-}x_1 + 2x_1 - x_2^2 \le 0\\
                      & {-}x_1 + 2x_2 \le 0
          \end{aligned}
\end{align}
\end{document}

enter image description here

2 Answers 2

5

Here are two possibilities with the optidef package:

\documentclass{article}
\usepackage{amsmath}
\usepackage{optidef}
\DeclareMathOperator{\st}{s.t.}

\begin{document}

\begin{mini!}|s|
 {\mathbf{x, y}}{-2x_1^2 + x_2^2 - 6y_1 + y_2^2}{\label{objective}}{}
\addConstraint{x_1^3 + 3x_2 - 10}{\le 0 \label{ineq:C1}}
\addConstraint{-x_1 + 2x_1 - x_2^2}{\le 0\label{ineq:C2}}
\addConstraint{-x_1 + 2x_2}{\le 0\label{ineq:C3}}
\end{mini!}

\begin{mini!}|s|[2]
 {\mathbf{x, y}}{-2x_1^2 + x_2^2 - 6y_1 + y_2^2\tag{2}}{\label{objective}}{}
\addConstraint{x_1^3 + 3x_2 - 10}{\le 0 \label{ineq:C1}}
\addConstraint{{-x_1} + 2x_1 - x_2^2}{\le 0\label{ineq:C2}}
\addConstraint{{-x_1} + 2x_2}{\le 0\label{ineq:C3}}
\end{mini!}

\end{document}

enter image description here

Edit: a workaround for two-level constraints:

\begin{mini!}|s|[2]
 {\mathbf{x, y}}{-2x_1^2 + x_2^2 - 6y_1 + y_2^2\tag{2}}{\label{objective}}{}
\addConstraint{x_1^3 + 3x_2 - 10\tag{3}}{\le 0 \label{ineq:C1}}
\addConstraint{\st\quad}{{-x_1} + 2x_1 - x_2^2\le 0\label{ineq:C2}}
\addConstraint{\phantom{\st}\quad}{{-x_1} + 2x_2\le 0\label{ineq:C3}}
\end{mini!}

enter image description here

6
  • In these bilevel optimizations, the second set of constraints (e.g., Eq. (3) in the MWE needs a second s.t. since those constraints are specific to the first s.t. (Eq. (2)). Is that possible in optidef? My quick trial did not work.
    – ZaydH
    Sep 19, 2020 at 20:26
  • 1
    I didn't have understood this. I'll try to find a workaround.
    – Bernard
    Sep 19, 2020 at 20:29
  • 1
    @ZaydH: I've added another variant code. Does it correspond to what you want?
    – Bernard
    Sep 19, 2020 at 20:43
  • I am very sorry @Bernard for me being dense here but I do not see the edit above. The "edited" link is not showing like it is for Isitar's answer.
    – ZaydH
    Sep 19, 2020 at 21:07
  • 1
    @ZaydH: I'm afraid I posted it with another answer… :-( Anyway, now it's added to this answer.
    – Bernard
    Sep 19, 2020 at 21:16
2

you can use another package named optidef: https://www.ctan.org/pkg/optidef here is your problem:

\usepackage{optidef}
\begin{document}
    
    \begin{mini!}|s|[2]<b>
        {x,y}{-x^2_1+x^2_2-6y_1+y^2_2}
        {}{}
        \addConstraint{x^3+x_2-10}{\leq 0}{}
        \addConstraint{-x_1+2x_1-x^2_2}{}
        \addConstraint{-x_1+2x_2}{\leq 0}{}
    \end{mini!}
\end{document}  

enter image description here

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.