-
Notifications
You must be signed in to change notification settings - Fork 10
Changing the content of a given bid
Taha Doğan Güneş edited this page Oct 24, 2017
·
1 revision
To change the content of a bid, use putValue
method:
/**
* Make a new Bid as the current bid but with the value of the issue with
* the given issueID to the given value.
*
* @param issueId
* unique ID of an issue.
* @param pValue
* value of the issue.
*/
public Bid putValue(int issueId, Value pValue)
Please notice that putValue returns a new bid with the given value changed. The old bid stays unchanged.
For example, to assign the value of the first issue to a random value:
// Modifying a bid
Bid bid = offer.getBid();
Bid newBid = null;
// Getting the first issue
Issue issue = bid.getIssues().get(0);
// Getting issue number
final int issueNumber = issue.getNumber();
// Determining issue type
switch (issue.getType()) {
case REAL:
IssueReal issueReal = (IssueReal) issue;
double upperRealBound = issueReal.getUpperBound();
double lowerRealBound = issueReal.getLowerBound();
// accessing to the old value
// ValueReal valueReal = (ValueReal) bid.getValue(issueNumber);
// generating a new random value
double randomReal = ThreadLocalRandom.current().nextDouble(lowerRealBound, upperRealBound);
ValueReal valueReal = new ValueReal(randomReal);
newBid = bid.putValue(issue.getNumber(), valueReal);
break;
case INTEGER:
IssueInteger issueInteger = (IssueInteger) issue;
int upperIntegerBound = issueInteger.getUpperBound();
int lowerIntegerBound = issueInteger.getLowerBound();
// accessing to the old value
// ValueInteger valueInteger = (ValueInteger) bid.getValue(issueNumber);
// generating a new random value
int randomInteger = ThreadLocalRandom.current().nextInt(lowerIntegerBound, upperIntegerBound);
ValueInteger valueInteger = new ValueInteger(randomInteger);
newBid = bid.putValue(issueNumber, valueInteger);
break;
case DISCRETE:
IssueDiscrete issueDiscrete = (IssueDiscrete) issue;
List<ValueDiscrete> allValues = issueDiscrete.getValues();
// accessing to the old value
// ValueDiscrete valueDiscrete = (ValueDiscrete) bid.getValue(issueNumber);
// generating a new random value
Collections.shuffle(allValues);
ValueDiscrete valueDiscrete = allValues.get(0);
newBid = bid.putValue(issueNumber, valueDiscrete);
break;
}
Please create an issue, if you find any errors or you want a topic covered in this wiki.
- Java Programming Cheatsheet
- Setting Up Genius Environment
- Stacked Alternating Offers Protocol
- AbstractNegotationParty Methods
- How to generate a random bid?
- How to generate a random bid with a utility threshold?
- How to change the content of a bid?
- How to keep track of time in a negotiation session?
- How to get the maximum and minimum bid?
- How to iterate all bids in a domain?
- How to access weights of each issue?
- How to access the evaluation of a value?