/** * Creates a starting proposal for a new negotiation of a need. In this implementation, the * mostly preferred value for each competence attribute is selected to compose the proposal. * * @param competence The competence being negotiated * @return A new proposal */ public Proposal createStartingProposal(Need need, Competence competence) { Proposal proposal = new Proposal(myAgent.getAID()); proposal.setNeedType(competence.getType()); // fill attribute values for (int j = 0; j < competence.getNumberOfAttributes(); j++) { Attribute ownAttribute = (Attribute) competence.getAttributes().get(j); AttributeValue valueToPropose = new AttributeValue(); valueToPropose.setName(ownAttribute.getName()); valueToPropose.setType(ownAttribute.getType()); Attribute askedAttribute = need.getAttribute(ownAttribute.getName()); if (!ownAttribute.isDiscrete()) { float ownPreferredValue = checkAskedContinuousDomain( askedAttribute, Float.parseFloat(ownAttribute.getPreferredValue().toString())); if (ownAttribute .getType() .equals("float")) { // check if this is really of type float, or integer valueToPropose.setValue(String.valueOf(ownPreferredValue)); } else { valueToPropose.setValue(String.valueOf((int) ownPreferredValue)); } } else { String ownPreferredValue = checkAskedDiscreteDomain(askedAttribute, ownAttribute.getPreferredValue().toString()); valueToPropose.setValue(ownPreferredValue); } proposal.getAttributeValues().add(valueToPropose); } return proposal; }