public CostFunction add(CostFunction cf){
		SortedMap<Integer, Integer> result = new TreeMap<Integer, Integer>();
		
		// list of all costs
		SortedSet<Integer> values = new TreeSet<Integer>();
		values.addAll(this.costByDemandMap.values());
		values.addAll(cf.costByDemandMap.values());
				
		// add to result
		for(int cost: values){
			if (cost < MAX_COST && !values.contains(cost + 1)){
				if (this.getDemandByCost(cost) != this.getDemandByCost(cost + 1)
						|| cf.getDemandByCost(cost) != cf.getDemandByCost(cost + 1))
					result.put(this.getDemandByCost(cost + 1) + cf.getDemandByCost(cost + 1), cost + 1);
			}
			if (cost > MIN_COST && !values.contains(cost - 1)){
				if (this.getDemandByCost(cost) != this.getDemandByCost(cost - 1)
						|| cf.getDemandByCost(cost) != cf.getDemandByCost(cost - 1))
					result.put(this.getDemandByCost(cost - 1) + cf.getDemandByCost(cost - 1), cost - 1);
			}
			result.put(this.getDemandByCost(cost) + cf.getDemandByCost(cost), cost);
		}
		
		return new CostFunction(result);
	}