// checks if the CSA has enough data for a decision private CSAData checkData(CSAData data) { if (data != null) { if (data.getServiceTemplates().size() > 0) { data.setEvalResult(OK); return data; } else { data.setEvalResult(ERROR_1); return data; } } else { return data; } }
public CSAData evaluator(CSAData csa) { String[] msg = {"STATUS: Evaluating CSA Data"}; CloudAid.askData(CloudAid.PROMPT, msg, null); try { csa = this.checkData(csa); if (csa.getEvalResult() == 0) { // evaluation ok this.data = csa; this.convertReqsInCriterions(); this.generalizeCSARequirements(); this.generalizeCSACriteria(); if (this.methodID == CloudAid.SAW) { this.normalizeServiceTemplateWeights(); this.normalizeCriteriaWeights(); } return this.data; } else { return csa; } } catch (NullPointerException ex) { // System.out.println("No data do evaluate."); return null; } }
private void normalizeServiceTemplateWeights() { // normalize the general criteria System.out.println("SYSTEM: Normalizing Service Template Weights"); double total = 0; for (ServiceTemplate template : data.getServiceTemplates()) { total = total + template.getWeight(); } for (ServiceTemplate template : data.getServiceTemplates()) { double res = template.getWeight() / total; System.out.println( "SYSTEM: Total: " + total + " || value: " + template.getWeight() + "|| res: " + res); template.setWeight((float) res); } }
private void normalizeCriteriaWeights() { // normalize the general criteria System.out.println("SYSTEM: Normalizing general criteria"); double total = 0; for (Criterion crit : data.getCriteria()) { total = total + crit.getWeight(); } for (Criterion crit : data.getCriteria()) { double res = crit.getWeight() / total; System.out.println( "SYSTEM: Total: " + total + " || value: " + crit.getWeight() + "|| res: " + res); crit.setWeight(res); } // normalize each of the Service Templates for (ServiceTemplate template : data.getServiceTemplates()) { System.out.println( "SYSTEM: Normalizing criteria of the serviceTemplate: " + template.getId()); double templateTotal = 0; for (Criterion crit : template.getCriteria()) { templateTotal = templateTotal + crit.getWeight(); } for (Criterion crit : template.getCriteria()) { double res = crit.getWeight() / templateTotal; System.out.println( "SYSTEM: Total: " + templateTotal + " || value: " + crit.getWeight() + "|| res: " + res); crit.setWeight(res); } } }