public void addObjective(Objective objective) { Preconditions.checkNotNull(objective, "objective"); Preconditions.checkArgument( !objectives.containsKey(objective.getName()), "Objective %s already exists in this scoreboard", objective.getName()); objectives.put(objective.getName(), objective); }
/** * Helper method that sets a specific grade in the Criteria Reference * * @param objId The objective * @param value The new grade * @return The new overall grade for the objective * @throws An unknown objective exception if you can't find the objective */ public float setObjectiveGrade(Long objId, int value) throws UnknownObjectiveException { Iterator i = this.objectiveGrades.keySet().iterator(); Objective tempObj; while (i.hasNext()) { tempObj = (Objective) i.next(); if (tempObj.getId().equals(objId)) { this.objectiveGrades.put(tempObj, value); recalcGrade(); return this.getGrade(); } } throw new UnknownObjectiveException("Could not find the Objective [" + objId + "]"); }
@Override public void serialize(ConfigurationSection section) { super.serialize(section, TYPE); section.set("amount", amount); section.set("boss", name); }
private boolean setProvisions(Objective tmpMsg, Behaviour task4Plan) { System.out.println("Setting Provisions..."); ArrayList ar = tmpMsg.getMessage().getAcl().getContent().getActions().get(0).getArguments(); System.out.println(ar.size()); if (!(task4Plan.getProvisionList().isEmpty())) { // Planýn provisioný yoksa set etmete çalýþmak hata verecekti. // Onun için böyle bir kontrol yapýyoruz. for (int j = 0; j < ar.size(); j++) { task4Plan.getProvisionList().get(j).setValue(ar.get(j)); System.out.println("Provison'lar " + task4Plan.getProvisionList().get(j).getValue()); System.out.println("Provision deger: " + task4Plan.getProvisionList().get(j).getValue()); } for (int i = 0; i < task4Plan.getProvisionList().size(); i++) { { if (!task4Plan.getProvisionList().get(i).isSet()) { System.out.println( task4Plan.getBehaviourName() + " planin " + task4Plan.getProvisionList().get(i).getprovName() + " Provision'u set edilememis."); return false; } } } } return true; }
/** * * <!-- begin-user-doc --> * <!-- end-user-doc --> * * @generated */ public Objective createObjectiveFromString(EDataType eDataType, String initialValue) { Objective result = Objective.get(initialValue); if (result == null) throw new IllegalArgumentException( "The value '" + initialValue + "' is not a valid enumerator of '" + eDataType.getName() + "'"); return result; }
/** * Print the student solution * * @param studs The studly students assigned to their study groups */ private void printStudentSolution(ArrayList<Student> studs) { System.out.println("Solution Format: 3"); System.out.println("Objective Function: " + Objective.getDescription()); System.out.println("Class Info: " + fileIO.getClassDesc()); System.out.println("Student Info: " + fileIO.getStudentDesc()); System.out.println("Number of students: " + studs.size()); for (Student s : studs) { System.out.println(s.getEmail()); System.out.println(s.getGroupAssignment().getTime()); System.out.println(s.getGroupAssignment().getTAEmail()); } System.out.println("Solution cost: " + solutionCost); }
private void Match(Objective incomingObjective) { System.out.println("Matcher => Match() metodu..."); ArrayList matchedBehaviours = new ArrayList(); try { System.out.println("Content'te bir olay var!!!"); FipaMessage fm = incomingObjective.getMessage(); int msgNum = incomingObjective.getMessageNum(); MatcherOntology mo = new MatcherOntology(); matchedBehaviours = mo.getPlan(fm); int numTasks = matchedBehaviours.size(); System.out.println("Matcher'ýn eþleþtirdiði plan sayýsý: " + numTasks); if (numTasks > 1) System.out.println("Birden fazla Behaviour ile eslestirildi."); else if (numTasks == 0) System.out.println("Objective, hicbir behaviour ile eslestirilemedi."); else { String matchedBehaviour = (String) matchedBehaviours.get(0); System.out.println(matchedBehaviour); Class c = Class.forName("test." + matchedBehaviour); System.out.println("Matcher Behaviour sinifi..."); Behaviour Plan = (Behaviour) c.newInstance(); BehaviourQCell behQCell = new BehaviourQCell(Plan, msgNum); if (this.setProvisions(incomingObjective, Plan)) { // mesajdaki // parametreler, // provisionlara // getirilecektir BehaviourQ.add(behQCell); scheduler_notify.V(); System.out.println("Objective " + matchedBehaviour + " ile eslestirildi."); } } } catch (Exception e) { System.out.println("Failed: " + e); } }
public boolean dominates(ObjectiveArray that) { // get objectives from states. Objective[] objectivesA = this.getObjectives(); Objective[] objectivesB = that.getObjectives(); // check that sizes are equal. if (objectivesA.length != objectivesB.length) { throw new InconsistentObjectiveSizeException(); } int dominationCountForA = 0; int dominationCountForB = 0; int equalityCount = 0; for (int i = 0; i < objectivesA.length; i++) { // get corresponding objectives to determine domination. Objective objectiveA = objectivesA[i]; Objective objectiveB = objectivesB[i]; if (!objectiveA.getBehaviour().equals(objectiveB.getBehaviour())) { throw new InconsistentObjectiveBehaviourException(); } // if this objective is designed to minimize. if (objectiveA.getBehaviour().equals(ObjectiveBehaviour.MINIMIZED)) { if (objectiveA.getValue() < objectiveB.getValue()) { dominationCountForA++; } else if (objectiveB.getValue() < objectiveA.getValue()) { dominationCountForB++; } else { // the equality condition for two objectives. equalityCount++; } } else { if (objectiveA.getValue() > objectiveB.getValue()) { dominationCountForA++; } else if (objectiveB.getValue() > objectiveA.getValue()) { dominationCountForB++; } else { // the equality condition for two objectives. equalityCount++; } } } if (equalityCount != 0) { if (equalityCount < objectivesA.length) { return (dominationCountForA == (objectivesA.length - equalityCount)) ? true : false; } else { // means that all objectives are same. return false; } } else { return (dominationCountForA == objectivesA.length) ? true : false; } }
private Bid getBidABMPsimple(double targetUtility) throws Exception { // Value[] lIssueIndex = new Value[nrOfIssues]; HashMap<Integer, Value> lIssueIndex = new HashMap<Integer, Value>(); ArrayList<Issue> issues = utilitySpace.getDomain().getIssues(); double[] lIssueAlpha = new double[issues.size()]; double[] lBE = new double[issues.size()]; double[] lBTE = new double[issues.size()]; double[] lTE = new double[issues.size()]; double lUtility = 0, lNF = 0, lAlpha, lUtilityGap, lTotalConcession = 0; // ASSUMPTION: Method computes a second bid. Method proposeInitialBid is used to compute first // bid. lUtilityGap = targetUtility - utilitySpace.getUtility(myLastBid); for (int i = 0; i < issues.size(); i++) { lBE[i] = (Double) (utilitySpace .getEvaluator(issues.get(i).getNumber()) .getEvaluation(utilitySpace, myLastBid, issues.get(i).getNumber())); } // STEP 1: Retrieve issue value for last bid and compute concession on each issue. int i = 0; for (Issue lIssue : issues) { lAlpha = (1 - utilitySpace.getWeight(lIssue.getNumber())) * lBE[i]; // CHECK: (1 - lBE[i]); This factor is not right?? lNF = lNF + utilitySpace.getWeight(lIssue.getNumber()) * lAlpha; lIssueAlpha[i] = lAlpha; i++; } // Compute basic target evaluations per issue for (i = 0; i < issues.size(); i++) { lBTE[i] = lBE[i] + (lIssueAlpha[i] / lNF) * lUtilityGap; } // STEP 2: Add configuration tolerance for opponent's bid for (i = 0; i < issues.size(); i++) { lUtility = (Double) (utilitySpace .getEvaluator(issues.get(i).getNumber()) .getEvaluation( utilitySpace, ((Offer) messageOpponent).getBid(), issues.get(i).getNumber())); lTE[i] = (1 - CONFTOLERANCE) * lBTE[i] + CONFTOLERANCE * lUtility; } // STEP 3: Find bid in outcome space with issue target utilities corresponding with those // computed above. // ASSUMPTION: There is always a UNIQUE issue value with utility closest to the target // evaluation. // First determine new values for discrete-valued issues. double lEvalValue; int lNrOfRealIssues = 0; for (i = 0; i < issues.size(); i++) { lUtility = 1; // ASSUMPTION: Max utility = 1. Objective lIssue = issues.get(i); if (lIssue.getType() == ISSUETYPE.DISCRETE) { IssueDiscrete lIssueDiscrete = (IssueDiscrete) lIssue; for (int j = 0; j < lIssueDiscrete.getNumberOfValues(); j++) { lEvalValue = ((EvaluatorDiscrete) utilitySpace.getEvaluator(lIssue.getNumber())) .getEvaluation(lIssueDiscrete.getValue(j)); if (Math.abs(lTE[i] - lEvalValue) < lUtility) { // lIssueIndex[i] = lIssueDiscrete.getValue(j); lIssueIndex.put(new Integer(lIssue.getNumber()), lIssueDiscrete.getValue(j)); lUtility = Math.abs(lTE[i] - lEvalValue); } // if } // for lTotalConcession += utilitySpace.getWeight(lIssue.getNumber()) * (lBE[i] - ((EvaluatorDiscrete) utilitySpace.getEvaluator(lIssue.getNumber())) .getEvaluation((ValueDiscrete) (lIssueIndex.get(lIssue.getNumber())))); } else if (lIssue.getType() == ISSUETYPE.REAL) lNrOfRealIssues += 1; } // TODO: Still need to integrate integer-valued issues somewhere here. Low priority. // STEP 4: RECOMPUTE size of remaining concession step // Reason: Issue value may not provide exact match with basic target evaluation value. // NOTE: This recomputation also includes any concession due to configuration tolerance // parameter... // First compute difference between actual concession on issue and target evaluation. // TODO: Think about how to (re)distribute remaining concession over MULTIPLE real issues. In // car example // not important. Low priority. double lRestUtitility = lUtilityGap + lTotalConcession; // Distribute remaining utility of real and/or price issues. Integers still to be done. See // above. for (i = 0; i < issues.size(); i++) { Objective lIssue = issues.get(i); if (lIssue.getType() == ISSUETYPE.REAL) { lTE[i] += lRestUtitility / lNrOfRealIssues; switch (utilitySpace.getEvaluator(lIssue.getNumber()).getType()) { case REAL: EvaluatorReal lRealEvaluator = (EvaluatorReal) (utilitySpace.getEvaluator(lIssue.getNumber())); double r = lRealEvaluator.getValueByEvaluation(lTE[i]); // lIssueIndex[i] = new ValueReal(r); lIssueIndex.put(new Integer(lIssue.getNumber()), new ValueReal(r)); break; case PRICE: EvaluatorPrice lPriceEvaluator = (EvaluatorPrice) (utilitySpace.getEvaluator(lIssue.getNumber())); // lIssueIndex [i] = new ValueReal(lPriceEvaluator.getLowerBound()); lIssueIndex.put( new Integer(lIssue.getNumber()), new ValueReal(lPriceEvaluator.getLowerBound())); Bid lTempBid = new Bid(utilitySpace.getDomain(), lIssueIndex); // lIssueIndex[i] = lPriceEvaluator.getValueByEvaluation(utilitySpace, lTempBid, // lTE[i]); lIssueIndex.put( new Integer(lIssue.getNumber()), lPriceEvaluator.getValueByEvaluation(utilitySpace, lTempBid, lTE[i])); break; } } } return new Bid(utilitySpace.getDomain(), lIssueIndex); }