@Override
	public double simulate(AbstractStochasticLotSizingProblem problem,
			AbstractStochasticLotSizingSolution solution)
			throws ConvolutionNotDefinedException, SolvingInitialisiationException {
		
		//Check the inputs
		if (problem.getPeriods().length != solution.getAmountVariableValues().length)
			throw new SolvingInitialisiationException("The length of the problem and the solution do not match in StaticDynamicUncertaintySimulator solve");
		
		double CurrentInventory = 0.0; //Starting inventory
		double costs = 0.0;
		AbstractLotSizingPeriod[] periods = problem.getPeriods();
		boolean[] setupPattern = solution.getSetupPattern();
		double[] orderUpToLevel = solution.getAmountVariableValues();
		
		for (int i = 0; i < periods.length; i++){
			if (setupPattern[i]) costs += periods[i].getSetupCost();
			if (setupPattern[i] && CurrentInventory < orderUpToLevel[i]) CurrentInventory = orderUpToLevel[i];
			CurrentInventory -= periods[i].totalDemand().sample();
			costs += periods[i].getInventoryHoldingCost() * CurrentInventory;
		}
		
		return costs;
	}