Tackling Decision Processes with Non-Cumulative Objectives using Reinforcement Learning

## Abstract

Abstract Markov decision processes (MDPs) are used to model a wide variety of applications ranging from game playing over robotics to finance. Their optimal policy typically maximizes the expected sum of rewards given at each step of the decision process. However, a large class of problems does not fit straightforwardly into this framework: Non-cumulative Markov decision processes (NCMDPs), where instead of the expected sum of rewards, the expected value of an arbitrary function of the rewards is maximized. Example functions include the maximum of the rewards or their mean divided by their standard deviation. In this work, we introduce a general mapping of NCMDPs to standard MDPs. This allows all techniques developed to find optimal policies for MDPs, such as reinforcement learning or dynamic programming, to be directly applied to the larger class of NCMDPs. Focusing on reinforcement learning, we show applications in a diverse set of tasks, including classical control, portfolio optimization in finance, and discrete optimization problems. Given our approach, we can improve both final performance and training time compared to relying on standard MDPs.

## 1 Introduction

Markov decision processes (MDPs) are used to model a wide range of applications where an agent iteratively interacts with an environment during a trajectory.
Important examples include robotic control [Andrychowicz et al. ()], game playing [Mnih et al. ()], or discovering algorithms [Mankowitz et al. ()].
At each time step $t$ of the MDP, the agent chooses an action based on the state of the environment and receives a reward $r_{t}$.
The agent’s goal is to follow an ideal policy that maximizes

$$ $\mathbb{E}_{\pi}\left[\sum_{t=0}^{T-1}{r_{t}}\right],$ (1) $$

where $T$ is the length of the trajectory and the expectation value is taken over both the agent’s probabilistic policy $\pi$ and the probabilistic environment.
There exist a multitude of established strategies for finding (approximately) ideal policies of MDPs, such as dynamic programming and reinforcement learning [Sutton & Barto ()].

A limitation of the framework of MDPs is the restriction to ideal policies that maximize Equation 1, while a large class of problems cannot straightforwardly be formulated this way. For example, in weakest-link problems, the goal is to maximize the minimum rather than the sum of rewards, e.g. in network routing one wants to maximize the minimum bandwidths along a path [Cui & Yu ()]. In finance, the Sharpe ratio, i.e. the mean divided by the standard deviation of portfolio gains, is an important figure of merit of an investment strategy, since maximizing it will yield more risk-averse strategies than maximizing the sum of portfolio gains [Sharpe ()].
We therefore require a method to tackle non-cumulative Markov decision processes (NCMDPs), where instead of the expected sum of rewards, the expectation value of an arbitrary function of the rewards is maximized.
First steps in this direction have already been taken, but are currently limited to specific settings, e.g. by being restricted to only certain MDP solvers, deterministic environments, and restricted classes of non-cumulative objectives (for more details on these approaches see Section 4). The main contribution of this paper is twofold:

- •
First, we provide a theoretical framework for a general and easy-to-implement mapping of NCMDPs to corresponding standard MDPs. This allows the direct application of advanced MDP solvers such as reinforcement learning or dynamic programming to tackle also NCMDPs (see Figure 1).
- •
Next, we perform numerical experiments focusing on reinforcement learning. We show applications in classical control problems, portfolio optimization, and discrete optimization problems using e.g. the non-cumulative $\max$ objective and the Sharpe ratio. Using our framework, we find improvements in both training time and final performance as compared to relying on standard MDPs.

## 2 Theoretical Analysis

Figure: Figure 1: Mapping of a decision process with non-cumulative objective (blue) to a corresponding Markov decision process with adapted states and rewards (orange) that can be solved by standard methods (black). For details and notation, see Section 2.

#### Preliminaries

In an MDP, an agent iteratively interacts with an environment during a trajectory. At each time step $t$, the agent receives the current state $s_{t}$ of the environment and selects an action $a_{t}$ by sampling from its policy $\pi(a_{t}|s_{t})$, which is a probability distribution over all possible actions given a state. The next state of the environment $s_{t+1}$ and the agent’s immediate reward $r_{t}$ are then sampled from the transition probability distribution $p(r_{t},s_{t+1}|s_{t},a_{t})$, which depends on the MDP. This process repeats until it reaches a terminal state. The ideal policy of the agent maximizes the expected sum of immediate rewards, i.e. Equation 1. Note that we take this ideal policy to be part of the definition of an MDP to distinguish MDPs from NCMDPs with different ideal policies. For simplicity, we discuss only non-discounted, episodic MDPs. However, generalization to discounted settings is straightforward.

#### Non-cumulative Markov decision processes

In the following, we denote states and rewards related to NCMDPs by $\tilde{s}_{t}$ and $\tilde{r}_{t}$, respectively, to distinguish them from MDPs.
We define NCMDPs equivalently to MDPs except for their ideal policies maximizing the expectation value of an arbitrary scalar function $f$ of the immediate rewards $\tilde{r}_{t}$ instead of their sum, i.e.

$$ $\mathbb{E}_{\pi}\left[f(\tilde{r}_{0},\tilde{r}_{1},\dots,\tilde{r}_{T-1}) \right].$ (2) $$

NCMDPs still have a Markovian transition probability distribution but their return, i.e. Equation 2, depends on the rewards in a non-cumulative and therefore non-Markovian way. Thus, NCMDPs are a generalization of MDPs.
Due to this distinction, MDP solvers cannot straightforwardly be used for NCMDPs. To solve this problem, we describe a general mapping from an NCMDP $\tilde{M}$ with rewards $\tilde{r}_{t}$ and states $\tilde{s}_{t}$ to a corresponding MDP $M$ with adapted states $s_{t}$ and adapted rewards $r_{t}$ but the same actions. The mapping is chosen such that the optimal policy of $\tilde{M}$ is equivalent to the optimal policy of $M$. Therefore, a solution for $\tilde{M}$ can readily be obtained by solving $M$ with existing MDP solvers, as shown in Figure 1.

As a first step, we define

$$ $r_{t}=f(\tilde{r}_{0},\dots,\tilde{r}_{t})-f(\tilde{r}_{0},\dots,\tilde{r}_{t- 1}).$ (3) $$

As $\mathbb{E}_{\pi}\left[\sum_{t=0}^{T-1}r_{t}\right]=\mathbb{E}_{\pi}\left[f(
\tilde{r}_{0},\dots,\tilde{r}_{T-1})\right]$, the ideal policy of $M$ is also the ideal policy of $\tilde{M}$. However, the $r_{t}$ are now non-Markovian, since they depend on rewards in the past of the trajectory. Recovering theoretical convergence guarantees available for MDP solvers requires adapting our state space to recover the Markov property of $M$. In principle, methods developed based on past [Bacchus et al. (, )] or future [Thiébaux et al. ()] linear temporal logic could be employed to achieve this. However, we argue that for a wide range of functions $f$, a more straightforward approach is possible:
The primary challenge is that we need to access the non-cumulative return in a purely Markovian manner. This can be achieved by extending the state in a way that preserves all the information necessary to compute this return. The additional state information $x_{t}$ needs to be sufficient to compute $r_{t}$, i.e. the temporal difference of the non-cumulative returns $f$.
Concretely, we need to define a vector $x_{t}$ and two functions $y$ and $z$, such that the following relations hold:

$$ $\begin{gathered}s_{t}=(\tilde{s}_{t},x_{t})\text{ with }x_{t+1}=y(x_{t},\tilde {r}_{t}),\\ r_{t}=f(\tilde{r}_{0},\dots,\tilde{r}_{t})-f(\tilde{r}_{0},\dots,\tilde{r}_{t- 1})=z(x_{t},\tilde{r}_{t}).\end{gathered}$ (4) $$

With the Dirac delta function $\delta$, the transition probabilities $p$ of $M$ are then given in terms of the transition probabilities $\tilde{p}$ of $\tilde{M}$ by

$$ $p(r_{t},s_{t+1}|s_{t},a_{t})=\tilde{p}(\tilde{r}_{t},\tilde{s}_{t+1}|\tilde{s} _{t},a_{t})\delta\left[x_{t+1}-y(x_{t},\tilde{r}_{t})\right]\delta\left[r_{t}- z(x_{t},\tilde{r}_{t})\right].$ (5) $$

There are several possible choices for $x_{t}$, $y$, and $z$. For example, it is always possible to choose $x_{t}=(r_{0},\dots,r_{t-1})$. However, this is undesirable because it leads to a state size that grows with the trajectory length. Fortunately, it is possible to find $x_{t}$ of a small, constant size for many functions $f$. For example, for $f(\tilde{r}_{0},\dots,\tilde{r}_{t})=\min(\tilde{r}_{0},\dots,\tilde{r}_{t})$, we can choose $r_{0}=x_{1}=\tilde{r}_{0}$ followed by $x_{t}=y(x_{t},\tilde{r}_{t})=\min(x_{t},\tilde{r}_{t})$, and $r_{t}=z(x_{t},\tilde{r}_{t})=\min(0,\tilde{r}_{t}-x_{t})$. More examples are shown in Table 1.
By mapping the NCMDP to an MDP, all guarantees available for MDP solvers, e.g. convergence proofs for Q-learning [Watkins & Dayan ()], or the policy gradient theorem for policy-based methods [Sutton et al. ()], directly apply also to NCMDPs.

**Table 1: Examples of non-cumulative objective functions $f$.**
| $\bm{f(\tilde{r}_{0}},\dots,\bm{\tilde{r}_{T-1})}$ | State adaption $\bm{x_{t}}$ | Adapted reward $\bm{r_{t}}$ |
| --- | --- | --- |
| $\max(\tilde{r}_{0},\dots,\tilde{r}_{T-1})$ | $x_{1}=\tilde{r}_{0}$, $x_{t+1}=\max(x_{t},\tilde{r}_{t})$ | $r_{t}$ = $\max(0,\tilde{r}_{t}-x_{t})$ |
| $\min(\tilde{r}_{0},\dots,\tilde{r}_{T-1})$ | $x_{1}=\tilde{r}_{0}$, $x_{t+1}=\min(x_{t},\tilde{r}_{t})$ | $r_{t}$ = $\min(0,\tilde{r}_{t}-x_{t})$ |
| Sharpe ratio<br>$\frac{\mathrm{MEAN}(\tilde{r}_{0},\dots,\tilde{r}_{T-1})}{\mathrm{STD}(\tilde{<br>r}_{0},\dots,\tilde{r}_{T-1})}$ | $x_{0}=\begin{bmatrix}0\\<br>0\\<br>0\end{bmatrix}$, $x_{t+1}=\begin{bmatrix}\frac{x_{t}^{(2)}}{x_{t}^{(2)}+1}x_{t}^{(0)}+\frac{1}{x<br>_{t}^{(2)}+1}\tilde{r}_{t}\\<br>\frac{x_{t}^{(2)}}{x_{t}^{(2)}+1}x_{t}^{(1)}+\frac{1}{x_{t}^{(2)}+1}\tilde{r}_<br>{t}^{2}\\<br>\ x_{t}^{(2)}+1\end{bmatrix}$ | $r_{t}=\frac{x_{t+1}^{(0)}}{\sqrt{x_{t+1}^{(1)}-x_{t+1}^{(0)^{2}}}}$<br>$-\frac{x_{t}^{(0)}}{\sqrt{x_{t}^{(1)}-x_{t}^{(0)^{2}}}}$ |
| $\underset{k\in[-1,T-1]}{\max}\sum_{t=0}^{k}\tilde{r}_{t}$ | $x_{0}=0$, $x_{t+1}=\max(0,x_{t}-\tilde{r}_{t})$ | $r_{t}$ = $\max(0,\tilde{r}_{t}-x_{t})$ |
| $\tilde{r}_{0}\tilde{r}_{1}\dots\tilde{r}_{T-1}$ | $x_{0}=1$, $x_{t+1}=\tilde{r}_{t}x_{t}$ | $r_{t}=x_{t+1}-x_{t}$ |
| Harmonic mean<br>$\frac{1}{\frac{1}{\tilde{r}_{0}}+\dots+\frac{1}{\tilde{r}_{T-1}}}$ | $x_{0}=0,x_{t+1}=x_{t}+\frac{1}{\tilde{r}_{t}}$ | $r_{t}=\frac{1}{x_{t+1}}-\frac{1}{x_{t}}$ |
| $\delta^{T}\sum_{t=0}^{T-1}\tilde{r}_{t}$,<br>$\delta\in(0,1)$ | $x_{0}=\begin{bmatrix}0\\<br>0\end{bmatrix}$, $x_{t+1}=\begin{bmatrix}x_{t}^{(0)}+\tilde{r}_{t}\\<br>x_{t}^{(1)}+1\end{bmatrix}$ | $r_{t}=\delta^{x_{t+1}^{(1)}}x_{t+1}^{(0)}$<br>$-\delta^{x_{t}^{(1)}}x_{t}^{(0)}$ |

We demonstrate the need for the additional state information $x_{t}$ in the two-step NCMDP depicted in Figure 2. Here, the goal is to maximize the expected minimum of the rewards, i.e. $\min(\tilde{r}_{0},\tilde{r}_{1})$. If $\tilde{r}_{0}=1$ in the first step, the ideal policy is to choose $a_{1}$ in the second step, while if $\tilde{r}_{0}=-1$ the agent should choose $a_{0}$. Therefore, the choice of the ideal action depends on information contained in the past rewards, which is captured by $x_{1}=\tilde{r}_{0}$. We show the MDP constructed from the NCMDP as described above in the Appendix in Figure A1 and its state-action value function found by value iteration in Table A1.

## 3 Experiments

From an implementation perspective, our scheme of mapping NCMDPs to MDPs requires minimal effort, since we can treat both the NCMDP and the used MDP solver as black boxes by simply adding a layer between them, as shown in Figure 1. In addition, our treatment facilitates online learning and does not require any computationally expensive preprocessing of the NCMDP.
This opens the door for researchers with specific domain knowledge, who are not necessarily experts in reinforcement learning, to use standard libraries such as stable-baselines3 [Raffin et al. ()] to solve their non-cumulative problems. Conversely, it allows reinforcement learning experts to quickly tackle existing environments using our method.

In the following, we focus on reinforcement learning (RL). We provide details on hyperparameters, compute resources, and training curves for all experiments in Appendix A.

### 3.1 Classical Control

Figure: Figure 2: Two-step decision process with non-cumulative objective. In the first step, the agent has only one action available and receives a probabilistic reward. In the second step, the agent can choose between two actions.

As a first use case of our method, we train a reinforcement learning agent in the Lunar lander environment of the gymnasium [Towers et al. ()] library. The agent controls a spacecraft with four discrete actions corresponding to different engines while being pushed by a stochastic wind. Immediate positive rewards $r_{t}$ are given for landing the spacecraft safely with small negative rewards given for using the engines. A realistic goal when landing a spacecraft is to not let the spacecraft get too fast, e.g. to avoid excessive frictional heating. Therefore, we define an NCMDP where the agent is penalized for its maximum speed during a trajectory, i.e. we try to maximize

$$ $\mathbb{E}_{\pi}\left[\sum_{t=0}^{T-1}r_{t}-c\max{(v_{0},\dots,v_{T-1})}\right],$ (6) $$

where $v_{t}$ is the speed of the agent at time $t$ and $c$ defines a trade-off between minimizing the maximum speed and the other goals of the agent.
We train RL agents using Proximal Policy Optimization (PPO) [Schulman et al. ()] on the MDP constructed from the NCMDP as described above (MAXVELPPO).
To show the trade-off between the sum of the agents’ original cumulative rewards $\sum_{t=0}^{T-1}r_{t}$ and their maximum speed increase during a trajectory, we train agents for different $c$. Each value of $c$ corresponds to a marker in Figure 3. We compare our results to an RL agent with a similar but cumulative objective maximizing $\mathbb{E}_{\pi}\left[\sum_{t=0}^{T-1}(r_{t}-cv_{t}^{2})\right]$ (SUMVELPPO). As shown in Figure 3, the non-cumulative MAXVELPPO agent is consistently able to find a better trade-off than the cumulative SUMVELPPO agent.
All experiments were performed with 5 agents using different seeds. We plot average results and standard deviation as error bars for both the cumulative reward and the speed increase (mostly hidden behind markers).

Our method presented here could be applied to similar use cases in other classical control problems, such as teaching a robot to reach a goal while minimizing the maximum impact forces on its joints or the forces its motors need to apply.

### 3.2 Portfolio Optimization with Sharpe Ratio as Objective

Figure: Figure 4: Portfolio optimization. Sharpe ratio during 10 different training periods for algorithms maximizing the cumulative differential Sharpe ratio (DIFFSHARPE) and the non-cumulative exact Sharpe ratio (SHARPE).

Next, we consider the task of portfolio optimization where an agent decides how to best invest its assets across different possibilities. A common measure for a successful investment strategy is its Sharpe ratio [Sharpe ()]

$$ $\frac{\mathrm{MEAN}(\tilde{r}_{0},\dots,\tilde{r}_{T-1})}{\mathrm{STD}(\tilde{ r}_{0},\dots,\tilde{r}_{T-1})},$ (7) $$

where $\tilde{r}_{t}=(P_{t+1}-P_{t})/P_{t}$ are the simple returns and $P_{t}$ is the portfolio value at time $t$. By dividing through the standard deviation of the simple returns, the agent is discouraged from risky strategies with high volatility. As the Sharpe ratio is non-cumulative, reinforcement learning strategies so far needed to fall back on the approximate differential Sharpe ratio as a reward [Moody et al. (); Moody & Saffell ()]. However, using the methods developed in this paper we can directly maximize the exact Sharpe ratio.
We perform experiments on an environment as described by Sood et al. () where an agent trades on the 11 different S&P500 sector indices between 2006 and 2021. The states contain a history of returns of each index and different volatility measures. Actions are the continuous relative portfolio allocations for each day.
The experiment described by Sood et al. () consists of training 5 agents with different seeds over a 5-year period, periodically evaluating their performance on the following year, and testing the best-performing agent in the year after that. Then, the time period is shifted by one year into the future resulting in a total of 10 time periods. We re-implement this experiment by training agents using PPO with the cumulative differential Sharpe ratio (DIFFSHARPE) or the exact Sharpe ratio (SHARPE) as their objective. As depicted in Figure 4, the SHARPE algorithm significantly outperforms the DIFFSHARPE algorithm in the training years. However, as shown in Table 2, on the evaluation and test years there is no significant difference indicating over-fitting of the agents’ policies to the years they are trained on. Nonetheless, we expect training on the exact SHARPE ratio to give consistently better results if the problem of over-fitting is solved, e.g. by using realistic stock-market simulators which are for example being developed using Generative Adversarial Networks [Li et al. ()]. The experiments were performed with 5 sets of 5 seeds each and the standard deviation of different sets of seeds is reported.

While the Sharpe ratio is most widely adopted in finance, our method opens up the possibility to maximize it also in other scenarios where risk-adjusted rewards are desirable, i.e. all problems where consistent rewards with low variance are more important than a higher cumulative reward. For example, in chronic disease management, maintaining stable health metrics is preferable to sporadic improvements. In emergency or customer service, ensuring predictable response times is often more important than occasional fast responses mixed with slow ones.

### 3.3 Discrete Optimization Problems

Next, we consider a large class of applications where RL is commonly used: Problems where the agent iteratively transforms a state by its actions to find a state with a lower associated cost. These problems are common in scientific applications such as physics, e.g. to reduce the length of quantum logic circuits [Fösel et al. ()], or chemistry, e.g. for molecular discovery [Zhou et al. ()]. Another prominent example is the discovery of new algorithms [Mankowitz et al. ()]. Intuitively, these problems can be understood as searching for the state with the lowest cost within an equivalence class defined by all states that can be reached from the start state by the agent’s actions.

Concretely, we consider the class of discrete optimization problems equipped with a scalar cost function $c(\tilde{s}_{t})$ and the immediate rewards $\tilde{r}_{t}=c(\tilde{s}_{t})-c(\tilde{s}_{t+1})$. Additionally, we are interested in the state with the lowest cost found during a trajectory, i.e. the goal is to maximize

$$ $\mathbb{E}_{\pi}\left[c(\tilde{s}_{0})-\underset{k\in[0,T-1]}{\min}c(\tilde{s} _{k})\right]=\mathbb{E}_{\pi}\left[\underset{k\in[-1,T-1]}{\max}\sum_{t=0}^{k} \tilde{r}_{t}\right].$ (8) $$

We conjecture that maximizing Equation 8 will yield better results than maximizing $\mathbb{E}_{\pi}\left[\sum_{t=0}^{T-1}\tilde{r}_{t}\right]$ due to the following reasons:

- 1.
The agent does not need to learn an optimal stopping point.
- 2.
Considering only the rewards up to the minimum found cost might decrease the variance of the gradient estimate.
- 3.
The agent does not receive negative rewards for trying to escape a local cost minimum during a trajectory and is therefore not discouraged from exploring. This leads to learning difficult optimization strategies requiring an intermittent cost increase more easily.

#### Peak environment

To facilitate an in-depth analysis, we first consider a toy environment with the cost function depicted in the inset of Figure 5 (a). The cost function was chosen to be simple while still requiring intermittently cost-increasing actions of the optimal policy. Each trajectory lasts 10 steps and the agent’s actions are stepping to the left, right, or doing nothing. To minimize the number of hyperparameters, we use the REINFORCE algorithm [Williams ()] with a tabular policy.
We compare agents trained with the non-cumulative objective Equation 8 (MAXREINFORCE) with agents that maximize the cumulative rewards (REINFORCE). As shown in Figure 5 (a), the MAXREINFORCE agent trains much faster. Two possible sources of this speed-up are a different, more advantageous direction of the gradient updates and a reduced variance when estimating these gradients. To investigate which is the case, we periodically stop training and run $n=1000$ trajectories with a fixed policy. We then compute the empirical variance of the gradient update inspired by Kaledin et al. () as

$$ $\mathrm{VAR}=\frac{1}{n}\sum_{i=0}^{n-1}\left\lVert\vec{g}_{i}\right\rVert_{2} ^{2}-\left\lVert\frac{1}{n}\sum_{i=0}^{n-1}\vec{g}_{i}\right\rVert_{2}^{2},$ (9) $$

where $\vec{g}_{i}$ is the gradient from a single trajectory derived either by the MAXREINFORCE or the REINFORCE algorithm. As this variance scales with the squared magnitude of the average gradients, we normalize it by this value to ensure a fair comparison between the two algorithms. In Figure 5 (b), we show that in the initial phase of training, the MAXREINFORCE algorithm significantly reduces variance. To compare the direction of the gradients we use the same data to compute the normalized average gradients of both algorithms and show their dot product in Figure 5 (c). We find that the gradients are correlated (i.e. the dot product is bigger than zero) but not the same. Therefore, we conclude that the training speed-up is derived both from lower variance and a better true gradient direction.
All results reported are averaged over 10 seeds with standard deviations plotted shaded.

Figure: Figure 5: Peak environment. (a) Cost improvement during the trajectory against training episodes for the cumulative REINFORCE agent and the MAXREINFORCE agent maximizing Equation 8. The inset shows the cost function of the environment. (b) Empirical variance of both agents against training progress. (c) Estimated dot product of the average gradient of both agents against training progress.

Figure: Figure 6: ZX environment. (a) Cost improvement during the trajectory against total steps taken in the environment for the cumulative REINFORCE agent and the MAXREINFORCE agent maximizing Equation 8. Left inset: Zoom-in to the initial training phase. Right inset: Zoom-in to the final training phase. (b) Entropy of the agents’ policies against total steps taken in the environment. Inset: A typical ZX-diagram.

#### ZX-diagrams

As a real-world use case, we consider the simplification of ZX-diagrams, which are graph representations of quantum processes [Coecke & Kissinger ()] with applications e.g. in the compilation of quantum programs [Duncan et al. (); Riu et al. ()]. An example of a typical ZX-diagram is shown in the inset of Figure 6 (b). We consider the environment described by Nägele & Marquardt (), where
the cost function of a diagram is given by its node number, the start states are randomly sampled ZX-diagrams, and the actions are a set of local graph transformations. In total, there are 6 actions per node and 6 actions per edge in the diagram. This is a challenging reinforcement learning task that requires the use of graph neural networks to accommodate the changing size of the state and action space. We use PPO to train agents to maximize either Equation 8 (MAXPPO) or the cumulative reward (PPO) with a trajectory length of 20 steps. As shown in Figure 6 (a) the MAXPPO agent initially trains faster than the PPO agent (left inset). This is likely due to the reduced variance and different gradient direction as described above. The PPO agent then shortly catches up, but ultimately requires about twice as many training steps to reach optimal performance as the MAXPPO agent (right inset). We argue that this is because the MAXPPO agent is better at exploring and therefore learning difficult optimization strategies (reason 3 above). This is captured by the entropy of the MAXPPO agent’s policy staying much higher than the entropy of the PPO agent, as shown in Figure 6 (b). All reported results are averaged over 5 seeds with standard deviations plotted shaded.

#### Quantum error correction

Next, we focus on optimization problems where the starting state is always the same and the optimal stopping point is known. The specific tasks we consider are the search for quantum programs to either find new quantum error correction codes or to prepare logical states of a given quantum error correction code - both critical for the eventual realization of quantum computation [Terhal ()]. In both cases, the agent iteratively adds elementary quantum logic gates until the program delivers the desired result. The agents’ policies are encoded by standard multilayer perceptrons. We train agents on five different sized problems of both tasks. For details on the used environment, see Zen et al. () and Olle et al. ().
To obtain a single performance measure encompassing both final performance and training speed, we continuously evaluate the mean cost improvement of the agents and average it over the training process as suggested by Andrychowicz et al. (). Intuitively, this measure can be understood as the area under the agent’s training curve. In Table 3, we report the quotient of this performance measure of the MAXPPO algorithm and the PPO algorithm for both the best of 10 and the mean of 10 trained agents.
The different tasks are denoted by three integers, as customary in the quantum error correction community. We find that the MAXPPO algorithm performs similarly to PPO in quantum error correction code discovery (subscript e), and significantly better in logical state preparation (subscript s). We argue that the large degeneracy present in the solution space of the code discovery task diverts the more exploratory MAXPPO, lowering its performance to the level of PPO.

**Table 3: Results for quantum error correction environments.**
| Task | Area under training curve $\frac{\mathrm{MAXPPO}}{\mathrm{PPO}}$ |  |
| --- | --- | --- |
| Best of 10 | Mean of 10 |  |
| $[[5,1,3]]_{\mathrm{e}}$ | $\mathbf{1.0004}$ | $\mathbf{1.0001\pm 0.0008}$ |
| $[[7,1,3]]_{\mathrm{e}}$ | $0.9993$ | $0.9994\pm 0.0003$ |
| $[[9,1,3]]_{\mathrm{e}}$ | $0.9994$ | $0.9994\pm 0.0003$ |
| $[[10,2,4]]_{\mathrm{e}}$ | $\mathbf{1.0013}$ | $\mathbf{1.0023\pm 0.0017}$ |
| $[[12,2,4]]_{\mathrm{e}}$ | $0.9993$ | $0.9991\pm 0.0007$ |
| $[[5,1,3]]_{\mathrm{s}}$ | $\mathbf{1.0419}$ | $\mathbf{1.0666\pm 0.0407}$ |
| $[[7,1,3]]_{\mathrm{s}}$ | $\mathbf{1.1824}$ | $\mathbf{1.2090\pm 0.0623}$ |
| $[[9,1,3]]_{\mathrm{s}}$ | $\mathbf{1.0060}$ | $\mathbf{1.0905\pm 0.1079}$ |
| $[[15,1,3]]_{\mathrm{s}}$ | $\mathbf{1.1382}$ | $\mathbf{1.0309\pm 0.0806}$ |
| $[[17,1,5]]_{\mathrm{s}}$ | $\mathbf{1.4748}$ | $\mathbf{1.6218\pm 0.2144}$ |

#### Limitation

When applying MAXPPO to discrete optimization problems with long trajectories in the many hundreds of steps, we empirically observed an initially slow learning speed. This could be due to the agent initially mostly increasing cost and therefore receiving zero reward for almost the entire trajectory. A possible solution could be to dynamically adjust the trajectory length in these problems going from shorter to longer trajectories during the training process.

## 4 Related Work

A special case of NCMDPs is first considered by Quah & Quek (), who adapt Q-learning to the $\max$ objective by redefining the temporal difference error of their learning algorithms and demonstrate their algorithms on an optimal stopping problem. However, they do not adapt state space and do not provide theoretical convergence guarantees. Gottipati et al. () rediscover the same algorithm, apply it to molecule generation, and provide convergence guarantees for their method, while Eyckerman et al. () consider the same algorithm for application placement in fog environments. Cui & Yu () finally show a shortcoming of the method used in the above papers: It is guaranteed to converge to the optimal policy only in deterministic settings. Additionally, they provide convergence guarantees of Q-learning in deterministic environments for a larger class of functions $f$, focusing on the $\min$ function for network routing applications.
Independently, the $\max$ function is also used in the field of safety reinforcement learning in deterministic environments both for Q-learning [Fisac et al. (, ); Hsu et al. ()] and policy-based reinforcement learning [Yu et al. ()].
Moflic & Paler () use a reward function with parameters that depend on the past rewards of the trajectory to tackle quantum circuit optimization problems that require large intermittent negative rewards, albeit without providing theoretical convergence guarantees.
Additionally, Wang et al. () investigate planning problems with non-cumulative objectives within deterministic settings. They provide provably efficient planning algorithms for a large class of functions $f$ by discretizing rewards and appending them to the states.
Recently, Veviurko et al. () showed how to use the $\max$ objective also in probabilistic settings by augmenting state space and provide convergence guarantees for both Q-learning and policy-based methods. They then show experiments with their algorithm yielding improvements in MDPs with shaped rewards. However, they do not redefine the rewards, which requires adaptation of the implementation of their MDP solvers. Our method described above reduces to an effectively equivalent algorithm to theirs in the special case of the $\max$ objective.

A limitation of all works discussed above is that they require a potentially complicated adaptation of their reinforcement learning algorithms and only consider specific MDP solvers or specific non-cumulative objectives. They are also limited to deterministic settings, except for Veviurko et al. (), which consider only the $\max$ objective.

## 5 Discussion & Conclusion

In this work, we described a mapping from a decision process with a general non-cumulative objective (NCMDP) to a standard Markov decision process (MDP) applicable in deterministic and probabilistic settings. Its implementation is straightforward and directly enables solving NCMDPs with state-of-the-art MDP solvers, allowing us to show improvements in a diverse set of tasks such as classical control problems, portfolio optimization, and discrete optimization problems. Note that these improvements are achieved without adding a single additional hyperparameter to the solving algorithms.

In further theoretical work, a classification of objective functions $f$ with constant-size state adaptions $x_{t}$ would be desirable. From an applications perspective, there are a lot of interesting objectives with non-cumulative $f$ that could not be maximized so far. For example, the geometric mean could be used to maximize average growth rates, or the function $f(\tilde{r}_{0},\dots,\tilde{r}_{T-1})=\delta^{T}\sum_{t=0}^{T-1}\tilde{r}_{t}
,\delta\in(0,1)$ could be used to define an exponential trade-off between trajectory length and cumulative reward in settings where long trajectories are undesirable. We believe that a multitude of other applications with non-cumulative objectives are still unknown to the reinforcement learning (RL) community, and conversely, that researchers working on non-cumulative problems are not aware of RL, simply because these two concepts could not straightforwardly be unified so far. This manuscript offers the exciting possibility of discovering and addressing this class of problems still unexplored by RL.

## Code and Data Availability

We open-source all code used to produce the results of this manuscript in the following GitHub repositories: Classical control, portfolio optimization, and peak environment: Nägele (). ZX-diagrams: Nägele (). Quantum error correction code discovery: Olle (). Logical state preparation: Zen (). In addition, we provide all generated data and agent weights at [https://osf.io/ajwmk](https://osf.io/ajwmk).

## Acknowledgments

This research is part of the Munich Quantum Valley (K-4 and K-8), which is supported by the Bavarian state government with funds from the Hightech Agenda Bayern Plus.

Figure: Figure A1: Markov decision process constructed from the non-cumulative Markov decision process depicted in Figure 2.

Figure: Figure A2: Sharpe ratio on evaluation and test periods.

## Appendix A Details on experiments

#### Lunar lander

For training, we use the PPO implementation of stables-baselines3 [Raffin et al. ()]. The hyperparameters and network architecture of both algorithms were chosen as by Raffin () (which are optimized to give good performance without the velocity penalty), only increasing the batch size and the total training steps to ensure convergence. Training a single agent takes around one hour on a Quadro RTX 6000 GPU with the environment running in parallel on 32 CPUs.

#### Portfolio optimization

For training, we use the PPO implementation of stables-baselines3 [Raffin et al. ()].
The hyperparameters and network architecture of both algorithms were chosen as by Sood et al. () where they were optimized to give a good performance of the DIFFSHARPE algorithm. Training a single agent takes around one hour on a Quadro RTX 6000 GPU with the environment running in parallel on 10 CPUs.

#### Peak environment

For training, we use a custom REINFORCE implementation with a tabular policy to keep the number of hyperparameters minimal, updating the agent’s policy after each completed trajectory. We use a learning rate of $2^{-10}$ but also performed experiments scanning the learning rate which leaves qualitative results similar. Training a single agent takes around 20 minutes on a Quadro RTX 6000 GPU with the environment running on a single CPU.

#### ZX-diagrams

For training, we use the PPO implementation of Nägele & Marquardt () to facilitate the changing observation and action space.
The hyperparameters and network architecture were chosen as by Nägele & Marquardt () who originally chose them to give good performance of the PPO algorithm. This is the most compute-intensive experiment reported in this work with one training run lasting for 12 hours using two Quadro RTX 6000 GPUs and 32 CPUs.

#### Quantum error correction

For training, we use the PPO implementation of PureJaxRL [Lu et al. ()]. For the code discovery task, we modify the reward to consist of the (normalized) difference in immediate rewards used in Olle et al. (). The hyperparameters in the code discovery task have been fixed throughout all cases and chosen to provide good performance in all the examples considered with standard PPO. The hyperparameters for the logical state preparation task have been chosen to be the optimal ones reported in Zen et al. (), which were optimized for performance of the PPO algorithm. All of the training is done on a single Quadro RTX 6000 GPU.
Training 10 agents to complete the code discovery task takes 1 to 2 minutes, depending on the target code parameters. For the logical state preparation task, it takes around 100 seconds for $[[5,1,3]]_{l}$ and around 2500 seconds for $[[17,1,5]]_{l}$ to train 10 agents in parallel.

We estimate the total compute time to reproduce the results of this manuscript to be around 1000 GPU hours and 25000 CPU hours.

Figure: Figure A3: Training progress of cumulative SUMVELPPO algorithm in the Lunar lander environment. The standard deviation over 5 seeds is shaded.

Figure: Figure A4: Training progress of non-cumulative MAXVELPPO algorithm in the Lunar lander environment. The standard deviation over 5 seeds is shaded.

Figure: Figure A5: Training progress in the portfolio optimization task. The standard deviation over 25 seeds is shaded.

Figure: Figure A6: Training progress in the quantum error correction tasks. The best and worst performance of 10 seeds is shaded.

## Peer Reviews

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: It seems to me that if the update function u of definition 1 is a constant function, no information is preserved and the constructed MDP could not have the same value function as the NCMDP. Is this right? If it is, this sort of choice should be excluded in definition 1.
Later in the same paragraph, the authors note that an h_t recording all reward history is sufficient to construct an MDP but the state space is exponentially large so there must be some tradeoff between state space and "Markovness". How much information can be lost from the full history before we lose the Markov condition? Is there a characterisation of the functions u that satisfy this property?
soundness: 3
strengths: Definition 1 and the possible applications of the method are interesting.
summary: In traditional MDPs, the agent is tasked with the optimisation of the policy value function that is the expected sum of the rewards. In a non cumulative markov decision process, the value function is replaced by the expected value of an arbitrary function of the rewards. 
The authors propose a method to translate an NCMDP into a regular MDP and show the expected returns of the two are equal and apply MDP solving methods to NCMDPs.
weaknesses: The variables u, h and $\rho$ are discussed in the paragraph following the statements of equations 3,4,5. You should introduce them before.
Also, their description is too vague. For example "This can be achieved by extending the state space with ht , which preserves all necessary
information about the reward history" does not give me a good sense of what the function u should be. 
I suggest the statement of theorem 1 be rearranged to: assumptions then conclusion, instead of the current: assumption then conclusion then more assumptions.

---

confidence: 3
contribution: 2
initial_rating: 5
presentation: 2
questions: - The paper gives very specific examples of construction of $u$ and $\rho$ that allows an efficient reduction from NCMDP to MDP of small augmented state size. Can you give examples of more general classes of non-cumulative objective function $f$ that induces $h_t$ that is of reasonably small dimensions?
soundness: 2
strengths: - The NCMDP setting considered in this paper fits many applications that does not directly fit into the MDP setting with cumulative rewards. Some examples include the weakest-link problem in network routing which maximizes minimum reward, the Sharpe ratio in finance which maximizes the mean divided by standard deviation. 
- The paper provides a straightforward solution to NCMDPs by first map an NCMDP to a standard MDP, which allows direct application of black box MDP solvers. 
- It provides comprehensive empirical results applying this method to a range of environments with non-cumulative reward objective, including classical control, portfolio optimization with Sharpe ratio, discrete optimization with lost cost objective.
summary: This paper studies the problem of finding an optimal policy for a special class of decision problem called non-cumulative Markov decision process (NCMDPs) where instead of the sum of rewards, it aims to maximize the expected value of an arbitrary function of the rewards. The paper solves NCMDPs by mapping it to standard MDPs, allowing direct application of MDP solver for NCMDPs. It also performs numerical experiments of classical control, portfolio optimization, and discrete optimization that use NCMDP objectives, and shows that their method improves both training time and final performance compared with standard MDP solvers with cumulative reward.
weaknesses: - The mapping from NCMDP to MDP provided in equations (3)-(5) augments the state with $h_t$ that represent necessary information for reward history, and is updated as $h_{t+1}=u(h_t,\tilde{r}_t)$ and satisfies $r_t=\rho(h_t,\tilde{r}_t)$. For arbitrary reward function $f(r)$, an essential factor to ensure the mapping to MDP is of reasonable size is to find an efficient functional form of $u$ and $\rho$ that summarizes this information from reward history. However, the paper only shows a list of examples of special examples of $f$ and does not specify how to construct $u$ and $\rho$ for arbitrary function $f$ in general, and does not provide an bound to the resulting state dimensions, which at worst case must contain the set of all historical rewards. I think this makes the overall contribution of the paper limited. 
- In the experimental section, for each environment, the paper compares their method of MDP reduction (with modified state and reward) with an RL agent with cumulative objective. This does not seem like a very fair comparison given the cumulative objective will be the wrong objective in each of these environments, and it is clear that correct specification of the objective will lead to better performance.

---

confidence: 4
contribution: 2
initial_rating: 5
presentation: 3
questions: * Can the proposed mapping of NCMDPs to MDPs be generalized to infinite-horizon MDPs? (when $f$ is defined as a function of set.)

* It seems that if we transformed an NCMDP to a standard MDP, the resulting standard MDP is governed by the dynamics of $s_t$ and $h_t$ can be viewed as an auxiliary state. I am curious whether there are some connections with the framework called MDPs with latent dynamics (see [1], [2]).

[1] Simon Du, Akshay Krishnamurthy, Nan Jiang, Alekh Agarwal, Miroslav Dudik, and John Langford. Provably
efficient RL with rich observations via latent state decoding. In International Conference on Machine
Learning, 2019.

[2] Amortila, Philip, et al. "Reinforcement Learning under Latent Dynamics: Toward Statistical and Algorithmic Modularity." arXiv preprint arXiv:2410.17904 (2024).
soundness: 2
strengths: * The authors consider the problem of control in NCMDPs, which is important and understudied in the RL community.

* The proposed mapping of NCMDPs to standard MDPs is simple and intuitive, and can effectively solve many problem instances of NCMDPs.

* The empirical studies are concrete, showing both the necessity of considering the problem of control in NCMDPs and the effectiveness of the proposed mappings.
summary: In this paper, the authors consider the problem of control in finite-horizon Non-cumulative MDPs (NCMDPS). They propose a general mapping of NCMDPs to standard MDP, and hence the problem can be solved by existing standard RL methods. They use a series of numerical experiments to illustrate the NCMDP problems and the proposed transformations.
weaknesses: * The paper has technical flaws, i.e., the function $f$ is ill-defined. In the original problem statement, $f$ is defined as a function on $\mathbb{R}^T$. But later on, the authors also use notations like $f(r_1,...,r_t)$, where $f$ should be treated as a function on $\mathbb{R}^t$. I think it may be helpful to define $f$ as a function of a set ($f(\\{r_1,...,r_t\\})$, $\\{r_1,...,r_t\\}$ is the set of $t$ rewards, $t$ can be any integer between $1$ and $T$). This works for all problem instances in Table 1.

* The authors overstate their contributions. They claim their methods work for arbitrary functions $f$. However, as indicated in the previous comment, Definition 1 is invalid for general $f$ on $\mathbb{R}^T$. Even if $f$ is treated as a function of a set, it turns out only for certain choices of $f$ there exist fix-size $h_t$ and corresponding functions $u$ and $\rho$.  I think the authors should try to find a classification of functions f with constant-size state adaptions. Even some preliminary results such as sufficiency conditions or necessary conditions would be helpful.

* I think in empirical studies the authors should compare their methods with prior works on the control of NCMDPs with a specific choice of objectives and I am curious if the proposed method (which is more general) can produce comparable performances.

---

confidence: 3
contribution: 3
initial_rating: 5
presentation: 4
questions: 1) What are the off-policy implications of this method?
2) A regular average would appear to be a common and useful non-cumulative objective to include in the paper. Was there a reason that it was not included?
soundness: 2
strengths: This paper provides a theoretically-sound and easy-to-use framework that makes it possible to optimize non-cumulative objectives, by mapping such objectives to the regular cumulative formulation, such that optimizing the cumulative objective results in the optimization of the non-cumulative objective. This framework clearly has several potential use-cases in various domains. The paper is polished, well-written, and the technical concepts are explained in a relatively clear manner.
summary: The authors propose a decision-making framework that allows for the optimization of non-cumulative objectives, by mapping such objectives to the regular cumulative formulation, such that optimizing the cumulative objective results in the optimization of the non-cumulative objective.  The authors show that this MDP framework satisfies important theoretical properties that make it possible to find an optimal policy, and provide several empirical experiments in support of this.
weaknesses: I have two concerns regarding this paper:

The first of which is that while the authors do a good job explaining how their framework can be used, they fail to properly formalize the theoretical conditions that they are operating in. For example, they do not address whether the state and action-spaces are or can be finite/infinite, if there is a restriction on the type of policy that can be used (stationary, stochastic, etc.), as well as whether there are implications of their framework being used in off-policy settings. Because of this, the extent to which their framework can be utilized is unclear.

My second concern is related to the experiments. In particular, the comparison of non-cumulative objectives to the cumulative objects seems unintuitive, given that no-where in the paper do the authors claim the non-cumulative objectives are better than the cumulative objectives. Rather, it would be more intuitive, and consistent with the rest of the text, if the experiments showed that the proposed methods indeed are able to find the optimal policy for the non-cumulative objective. As such, it would appear that the experiments in the current draft of the paper do little to support the claim that the proposed methods can be used to optimize non-cumulative objectives.

As such, I am open to increasing my score if the authors can properly formalize the theoretical conditions that they are operating in, and either 1) the authors can convince me that the experiments in the current draft are adequate, or 2) the authors improve the existing experiments in such a way that they address my concerns, or 3) the authors can provide additional experiments that address my concerns.

Meta-review: The paper studies non cumulative Markov decision process (NCMDPs) in which the goal is to maximize the expected value of an arbitrary function of the rewards (not necessarily the sum of the rewards as in regular MDPs). The authors propose a method to map NCMDPs to regular MDPs and then use MDP solvers to solve them. They report experimental results in classical control, portfolio optimization, and discrete optimization with NCMDP objectives, and shows that their method improves both training time and final performance compared to using standard MDP solvers with cumulative reward. 

The reviewers saw the followings as positives for the paper:
(+) The paper is well-written.
(+) The reviewers found the mapping from NCMDPs to standard MDPs simple and intuitive.

However, despite its simplicity, the method is not very practical because of
(-) The exponential growth of the state space with the trajectory length. This hugely restricts the applicability of the method. 
The approach is not practical beyond the examples listed in the paper. 

Moreover,
(-) The empirical comparisons with standard MDP solvers with cumulative reward do not make much sense and do not add much value.

Decision: Reject