# Debugging an Optimization Problem

## Overview

This example will illustrate a few tools that can help debugging an optimization problem. For example, it will demonstrate how to test an optimization problem by only solving for a fixed number of time steps.

## A Basic Optimization Problem

For this example, the model is kept very basic. We consider a single reservoir with a few target and optimization goals. The optimization problem is given below.

```
class SingleReservoir(
GoalProgrammingMixin,
CSVMixin,
ModelicaMixin,
CollocatedIntegratedOptimizationProblem,
):
"""
An optimization problem involving a single reservoir.
"""
only_check_initial_values = False
def times(self, variable=None):
times = super().times(variable)
if self.only_check_initial_values:
times = times[:1]
return times
def path_constraints(self, ensemble_member):
constraints = super().path_constraints(ensemble_member)
constraints.append((self.state("Q_release"), 0, 1.5))
return constraints
def goals(self):
return [MinimizeQpumpGoal()]
def path_goals(self):
return [VolumeRangeGoal(), MinimizeChangeInQpumpGoal()]
```

## Optimizing for a given number of time steps

By overwriting the method `times`

, we can control the times for which the problem is optimized.
In this case, we optimize for all times
unless the class attribute `only_check_initial_values`

is set to `True`

.
Optimizing for only the initial time can be useful
to check for infeasibilities due to incompatible initial conditions.