An SDK to suppoort automated ODRL-policy negotiation.
Project description
Bambon Negotiator
Bambon (Bayesian Adaptive Mixed-type Bilateral ODRL-policy Negotiator) is a learning-based negotiator for negotiating constraints over one or multiple actions (e.g., use, read, share, transfer) expressed in an ODRL-style policy format.
Bambon observes opponent offers, updates Bayesian beliefs about opponent preferences (numeric / enum / set issues), and generates counter-offers until:
- agreement is reached (
odrl:Agreement), or - the negotiation becomes infeasible (
NegotiationInfeasible)
Features
- ✅ Negotiates constraints per action (single-action or multi-action offers)
- ✅ Supports mixed-type issues:
- numeric constraints
- categorical/enum constraints
- set-valued constraints
- ✅ Bayesian belief models to learn opponent preferences over time
- ✅ Hard policy enforcement (non-negotiable constraints)
- ✅ Context similarity & severity scoring
- ✅ Hopelessness detection (fails fast if negotiation diverges)
Repository Structure
-
negotiator.py
Main implementation:Bambon(observe / counter-offer / agreement logic) -
belief.py
BeliefRegistrymanages belief models per action & issue -
distributions.py
Bayesian belief distributions:- numeric beta-based model
- Dirichlet model for categorical constraints
- set belief handling
-
models.py
Core dataclasses andNegotiationInfeasibleexception -
helpers.py
Constraint parsing + operator helpers -
context.py
Similarity + severity scoring -
expressions.py
Expression helpers for constraints -
test_negotiator.py
Negotiation simulations / profiles (balanced, aggressive, exploratory)
Offer Format (ODRL-style)
Bambon expects offers in an ODRL-like JSON format:
{
"@id": "urn:uid:example",
"@type": "odrl:Offer",
"permission": [
{
"action": "use",
"constraint": [
{
"leftOperand": "odrl:purpose",
"operator": "odrl:eq",
"rightOperand": "research"
}
]
}
]
}
Constraints are normalized internally (e.g., odrl: prefixes stripped during parsing).
Quickstart
1) Create a negotiator
from negotiator import Bambon
neg = Bambon(
name="Provider",
init_offer=init_offer, # required
hard_policy=hard_policy # optional
)
Each action in init_offer["permission"] gets its own:
- belief registry
- negotiation state
2) Observe an opponent offer and generate a response
signals, response_offer = neg.observe(opponent_offer)
print("Signals:", signals)
print("Response:", response_offer)
signalsisNonewhile negotiatingsignalsbecomes non-null when an action is accepted and agreement is formedresponse_offerwill be either:- a counter-offer (
odrl:Offer), or - an agreement (
odrl:Agreement)
- a counter-offer (
Running
Run tests (recommended)
pytest -q
or:
python -m unittest -v
Example Minimal Negotiation Loop
from negotiator import Bambon
provider = Bambon(name="Provider", init_offer=provider_init, hard_policy=provider_hard)
consumer = Bambon(name="Consumer", init_offer=consumer_init)
offer = consumer_init
for round_i in range(50):
sig_p, offer = provider.observe(offer)
if offer.get("@type") == "odrl:Agreement":
print("Agreement reached (provider -> consumer)")
break
sig_c, offer = consumer.observe(offer)
if offer.get("@type") == "odrl:Agreement":
print("Agreement reached (consumer -> provider)")
break
else:
print("No agreement reached within max rounds")
Key Negotiation Parameters
Bambon behavior is governed by tunable controls, including:
lr— learning rate for belief updatesinertia— resistance to changing past proposalstau_in,tau_out— thresholds controlling adaptation vs acceptancemax_set_k— maximum size for proposed setsjaccard_snap_threshold— snaps set proposals when overlap is highno_agreement_until— prevents early agreement before minimum roundsmax_rounds— maximum rounds before infeasibilityhopeless_window,hopeless_patience— detects non-converging negotiation
If negotiation is judged impossible, Bambon raises:
from models import NegotiationInfeasible
Output Types
Bambon produces ODRL-like structures:
- Counter-offer:
@type = "odrl:Offer" - Agreement:
@type = "odrl:Agreement"with constraints filled using accepted values
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file bambon-1.0.0.tar.gz.
File metadata
- Download URL: bambon-1.0.0.tar.gz
- Upload date:
- Size: 48.7 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
cf29833496aeaa8fef0eb2ac5ce61d478a5a426435cc63f7f3b2744d46b7a57b
|
|
| MD5 |
e22b1557fc8e2626aa240d9fa8b0d679
|
|
| BLAKE2b-256 |
e1057d6f029edadc4be42fac441bcc3b49cfc5305c2450c777d4a94bada06f60
|
File details
Details for the file bambon-1.0.0-py3-none-any.whl.
File metadata
- Download URL: bambon-1.0.0-py3-none-any.whl
- Upload date:
- Size: 61.5 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.2.0 CPython/3.13.0
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
6d7fe651e5ef33fe03b81d4da4ee55bddd2782f98d536342ad4b4dedf73e6acb
|
|
| MD5 |
f8a3943d6f3a136456b22bdeafbd6cfb
|
|
| BLAKE2b-256 |
5fc14675d474e20aa9dd130b3fa5e21a8242c1dbd390767f2c129b2dab42d2d4
|