@Override
	public AbstractStochasticLotSizingSolution solve(
			AbstractStochasticLotSizingProblem problem) {
		
		//First created the DP wrappers around the periods
		AbstractLotSizingPeriod[] originalPeriods = problem.getPeriods();
		DPBackwardRecursionPeriod[] periods = new DPBackwardRecursionPeriod[originalPeriods.length+1];
		//Create empty wrappers
		for (int i = 0; i < originalPeriods.length; i++) {
			periods[i] = new DPBackwardRecursionPeriod(originalPeriods[i]);
		}
		//Add the dummy period at the end
		periods[periods.length-1] = DPBackwardRecursionPeriod.getDummyPeriod();
		//Add the decisions
		for (int i = 0; i < periods.length-1; i++) {
			for (int j = i+1; j < periods.length; j++){
				try {
					periods[i].possibleDecisions.add(getDecision(periods, i, j, problem.getServiceLevel()));
				} catch (ConvolutionNotDefinedException e) {
					throw new RuntimeException("The demand distributions you have chosen could not be convoluted efficiently. Maybe try using normal distributions?");
				}
			}
		}
		
		//Solve the problem via backward recursion. Skip the dummy period.
		for (int i = periods.length-2; i >= 0; i--){
			try {
				periods[i].solve();
			} catch (SolvingInitialisiationException e) {
				throw new RuntimeException("The static uncertainty solver tried to solve an uninitialised period. This is a bug and should not happen");
			} catch (WrongOptimisationOrderException e) {
				throw new RuntimeException("The static uncertainty solver tried to solve the periods in the wrong order. This is a bug and should not happen");
			}
		}
		
		return new LotsizingDPSolution(periods, getAmoutVariableName());
	}