Update U-matrix on rent changes
Ensure the U-matrix recalculates whenever rents are updated by clarifying dependencies and re-render behavior in RentDivisionPuzzle.tsx, so changes to individual rents trigger a recalculation of utilities (U = V - R) across all agents and rooms. X-Lovable-Edit-ID: edt-a60b7332-4f67-4926-a402-d083626b1c12
This commit is contained in:
commit
dee3482dfa
1 changed files with 4 additions and 5 deletions
|
|
@ -46,11 +46,10 @@ const RentDivisionPuzzle = ({ onComplete }: RentDivisionPuzzleProps) => {
|
|||
const rentDiff = totalRent - currentTotal;
|
||||
|
||||
// Compute U-matrix: utility[agent][room] = valuation - rent
|
||||
const utilities = useMemo(() => {
|
||||
return valuations.map((agentVals) =>
|
||||
agentVals.map((v, roomIdx) => v - rents[roomIdx])
|
||||
);
|
||||
}, [valuations, rents]);
|
||||
// Computed directly to ensure reactivity when rents change
|
||||
const utilities = valuations.map((agentVals) =>
|
||||
agentVals.map((v, roomIdx) => v - rents[roomIdx])
|
||||
);
|
||||
|
||||
// Find envy relationships
|
||||
const envyInfo = useMemo(() => {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue