I have been trying to break up this long equation (see below) to fit into the page. It is quite long and I am wondering how I can break it up into different parts. There is something wrong with the \multiline function in my version, so I want to avoid using that.
\begin{equation}
\begin{aligned}
V^{j} \left ( q_{c},q_{e} \right ) \equiv \max_{\sigma^{j}, c_{c}^{j}, c_{e}^{j}, y_{c}^{j}, y_{e}^{j}} \left \{ \delta^{j} u(c^{j}) - g(y^{j}) + W\left ( \frac{\phi}{\gamma_{c}}[q_{c}-c_{c}^{j}+y_{c}^{j}], \frac{\psi}{\gamma_{e}}[\sigma^{j} (R q_{e}-\kappa^{j}-c_{e}^{j}+y_{e}^{j}) + (1-\sigma^{j}) (q_{e}-c_{e}^{j}+y_{e}^{j}) ] \right ) + \lambda_{c}^{j} (q_{c}-c_{c}^{j}) + \lambda_{e}^{j} (Rq_{e}-\kappa^{j}-c_{e}^{j})
\right \},\label{eqn:17}
\end{aligned}
\end{equation}\\
The output I am getting:
I am looking for an output that is like
but under the maximization problem with the main brackets.
Here are the relevant packages:
\documentclass[a4paper,12pt]{article}
\usepackage[margin=1in]{geometry}
\usepackage{amsmath,amssymb,amsfonts}
\usepackage{mathtools}
\usepackage{graphicx,amsmath,stackengine,scalerel}
\newcommand\qunderline[1]{\ThisStyle{%
\ensurestackMath{\stackengine{-1pt}{\SavedStyle#1}
{\SavedStyle\underline{\hphantom{#1}}}{U}{c}{F}{F}{S}}}%
}
\usepackage{xfrac}
\usepackage{nicefrac}
\usepackage{accents}
multline
, notmultiline
.