@Override
	public Formula getPreferedOffer (Formula offer, int snum) {		
		Formula resultOffer =  null;	
		List<Formula> potentialOffer = getPotentialOffer(offer);

		analysePotentialOffers (potentialOffer);

		if (snum == 1) {
			Collections.sort(potentialOffer, new Comparator<Formula>(){
				public int compare(Formula s1, Formula s2) {
					//return Double.compare(s2.getPreference(), s1.getPreference());
					return Double.compare(s2.getProbability(), s1.getProbability());
				}		    
			});
		} else if (snum == 2) {
			Collections.sort(potentialOffer, new Comparator<Formula>(){
				public int compare(Formula s1, Formula s2) {
					return Double.compare(s2.getPreference(), s1.getPreference());
				}		    
			});
		}

		for (Formula formula : potentialOffer) {
			System.out.println("---Potiencial Offer: " + formula);
		}

		Formula responseOffer =  null;		
		if (potentialOffer.size() > 0) {
			responseOffer = potentialOffer.get(0);		
			if (history.contains(responseOffer)) {
				responseOffer.setPrice(responseOffer.getPrice() + 50);
			}			
			if (responseOffer.getPrice() <= responseOffer.getThreshold()) {
				resultOffer = responseOffer;
				addHistoryFormula(responseOffer);
			}			
		}

		return resultOffer;
	}