Exact Shapley coalition values
CoalitionAster brings cooperative-game calculations into an AI coding conversation. Open the project folder, discuss how each player changes a coalition value and review exact fractional shares against independent orderings. These are mathematical fixtures, not payout advice.
from fractions import Fraction
from math import comb
def shapley_values(values):
if type(values) not in (list, tuple) or not 1 <= len(values) <= 256 or len(values) & (len(values)-1):
raise ValueError("shapley.table")
if any(type(v) is not int or abs(v) > 10**6 for v in values) or values[0] != 0:
raise ValueError("shapley.value")
players = len(values).bit_length()-1
result = []
for player in range(players):
share = Fraction(0)
for subset in range(len(values)):
if not subset & (1 << player):
size = subset.bit_count()
weight = Fraction(1, players*comb(players-1, size))
share += weight*(values[subset | (1 << player)]-values[subset])
result.append(share)
return result| Project | Test additive games and zero players, rejecting a nonzero empty coalition or a table whose length is not a power of two. |
|---|---|
| Review before applying | Compare actual behavior with the expected result. If a check fails, investigate it before applying more changes. |
| Connection | Base URL, credentials and a reachable server. |
from fractions import Fraction
from math import comb
def shapley_values(values):
if type(values) not in (list, tuple) or not 1 <= len(values) <= 256 or len(values) & (len(values)-1):
raise ValueError("shapley.table")
if any(type(v) is not int or abs(v) > 10**6 for v in values) or values[0] != 0:
raise ValueError("shapley.value")
players = len(values).bit_length()-1
result = []
for player in range(players):
share = Fraction(0)
for subset in range(len(values)):
if not subset & (1 << player):
size = subset.bit_count()
weight = Fraction(1, players*comb(players-1, size))
share += weight*(values[subset | (1 << player)]-values[subset])
result.append(share)
return resultMake the assumptions behind a calculated share reviewable
CoalitionAster gives mathematical application work a Windows coding workspace for source inspection and AI-assisted discussion. Begin with the meaning of the input table and the result your software reports. A calculation can be internally consistent while answering a different question from the one its interface presents, so establish that meaning before requesting implementation changes.
The Shapley-value example supplies a concrete project task: checking exact fractional shares derived from coalition values. Bring a small table and explain how participants map to entries. Ask the assistant to inspect those assumptions alongside the calculation, without treating the illustrative mathematical result as a financial recommendation or an operational allocation policy.
Review proposed edits against independently worked examples, including how an empty coalition is represented. Run your project's tests and inspect how exact fractions reach the reporting layer. If the interface rounds values, review that separately so a formatting decision does not appear to alter the underlying allocation or obscure the assumptions that produced it.
You may use an unfiltered AI model offered through a supported OpenAI-compatible or Anthropic endpoint. Supply credentials when required and check tools and context capacity. The selected service determines model behavior and restrictions; CoalitionAster keeps the coding work grounded in project files and results that you can inspect for yourself.
Clarify the calculation before changing its code
What should a coalition-value fixture explain?
Identify participants, how table entries correspond to coalitions and the expected value for the empty coalition. Use a small example with independently calculated shares. This lets the assistant review representation assumptions as well as the arithmetic.
Does the mathematical example define a real payout policy?
No. It is an illustration for reviewing project code. The meaning of inputs and the decision to use any allocation rule belong to your application requirements; a computed share alone does not justify an operational or financial decision.
How should I review rounded output?
Keep exact calculation fixtures separate from display fixtures. State the desired rounding and presentation rules, then inspect where they are applied. A rounded report should not be mistaken for the exact values returned by the underlying calculation.
Is cloud test execution included because of the domain name?
The documented product is a Windows coding workspace with configurable model connections. Cloud test execution is not established by the domain. Run checks in your project's chosen environment and bring relevant results back to the review.
CoalitionAster · Updated 2026-10-25