# Programming Agents by Their Social Relationships: A Commitment-Based Approach
## 5 2 COMM: An Infrastructure for Programming Social Relationships
### Modeling the Environment
In order to still get a good return from the sale, \(seller\) could try to negotiate with the couriers to have better prices for the shipments. Upon the negotiation phase, \(seller\) could decide to accept or reject the counteroffer. For instance, it could negotiate with truck \(trk2\) the transportation of the goods from \(A\) to \(B\) for only 20 Euros (instead of 50, as asked by \(trk2\)). Similarly, \(seller\) could decide to rely on the plane only for the route from \(B\) to \(C\) (provided that \(pln1\) offers that kind of service, as well) and then negotiate a cheaper price for \(B-C\) with \(trk4\). If these negotiations will be concluded positively, a new set of commitments will be created as shown in the following:

```
1\(c_{5}:C(customer,seller,at(pkg,D),pay(450,seller))\)
2\(c_{6}:C(seller,trk2,c_{7},pay(20,trk2))\)
3\(c_{7}:C(trk2,seller,pay(20,trk2))\)
4\(c_{8}:C(pln1,seller,pay(100,pln1)\wedge at(goods,B),at(goods,C))\)
5\(c_{9}:C(seller,trk2,c_{10},pay(50,trk4))\)
6\(c_{10}:C(trk4,seller,pay(50,trk4)\wedge at(goods,C),at(goods,D))\)
```

\(c_{5}\) encodes the counteroffer made by \(customer\) to \(seller\). \(c_{6}\) and \(c_{9}\) represent the offers made by the seller to \(trk2\) and \(trk4\) related to \(A-B\) and \(C-D\). These two commitments contain, as antecedent conditions, two additional commitments: \(c_{7}\) and \(c_{10}\), respectively. The meaning of such notation is that the creation of \(c_{7}\) and \(c_{10}\) leads to the detachment of \(c_{6}\) and \(c_{9}\), respectively. Should \(trk2\) decide that the offer made by \(seller\) is acceptable, it could create \(c_{7}\) committing to offer its services at the agreed prices. The \(seller\) would then be asked to pay, less it violates \(c_{6}\). The same holds for \(trk4\). \(c_{8}\), finally,encodes the second type of service offered by \(pln1\), namely the ability to bring the goods only from \(B\) to \(C\) upon payment of 100 Euros. Depending on which commitments in the set \(\{c_{1},\ldots,c_{10}\}\) are created and on how they progress (i.e., they could be detached, released, or even canceled), the interaction takes very different shapes. For instance, \(trk2\) and \(trk4\) could decide to refuse (or ignore) the offer made by _seller_, forcing it to refuse the counteroffer made by the customer. The customer, as a consequence, could then decide to accept the original offer or to give up. Still, the _seller_ could decide to accept the counteroffer and then still rely on \(trk1\) and \(pln1\) for the shipment, thereby making a lower profit, but making the _customer_ happy. A commitment-based representation of social relationships, reified in the environment as resources, provides a uniform and comprehensive representation of all these alternative paths. Furthermore, the _Entice_ and _Cooperate_ schemas provide a structured guideline to develop agents able to properly manipulate commitments and to react to the corresponding relevant social events. ### Remarks

2 COMM provides JADE and JaCaMo agents with an explicit representation of social relationships (i.e., commitments) that agents can directly manipulate. We have seen that a first positive consequence is that agents can be programmed by following a uniform schema that is agent-platform independent. This is not, however, the unique advantage that one gains when 2 COMM is integrated within an agent platform. Table 1 synthesizes a comparison between JADE and JaCaMo, highlighting aspects that are improved or added by an explicit representation of social relationships as commitments. _Programmable interaction means_: 2 COMM reifies social commitments as artifacts embodied in the environment, in particular as _commitment artifacts_. This significantly improves JADE, where programmable interaction means are missing. On the other hand, JaCaMo already integrates the CArtAgO component and, hence, already includes programmable artifacts that can be used to mediate the interaction among the agents.