Skip to content

A Node.js module that finds the optimal set of matches between a set of agents and a set of objects, using an auction algorithm.

Notifications You must be signed in to change notification settings

cjhooker/auction-matcher

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

11 Commits
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

auction-matcher

A Node.js module that finds the optimal set of matches between a set of agents and a set of objects, using an auction algorithm.

Installation

npm install auction-matcher --save

Usage

TypeScript

import * as auctionMatcher from 'auction-matcher'
type MatchValue = auctionMatcher.MatchValue;

let possibleMatches = [ 
    { agentId: 'Alicia', objectId: 'apple', value: 100 },
    { agentId: 'Alicia', objectId: 'broccoli', value: 80 },
    { agentId: 'Alicia', objectId: 'carrot', value: 90 },
    { agentId: 'Bo', objectId: 'apple', value: 50 },
    { agentId: 'Bo', objectId: 'broccoli', value: 40 },
    { agentId: 'Bo', objectId: 'carrot', value: 30 },
    { agentId: 'Cara', objectId: 'apple', value: 25 },
    { agentId: 'Cara', objectId: 'broccoli', value: 10 },
    { agentId: 'Cara', objectId: 'carrot', value: 0 } 
];

let optimalMatches: MatchValue[] = auctionMatcher.match(possibleMatches);
console.log(optimalMatches);

JavaScript

let auctionMatcher = require('auction-matcher');
let possibleMatches = [ 
    { agentId: 'Alicia', objectId: 'apple', value: 100 },
    { agentId: 'Alicia', objectId: 'broccoli', value: 80 },
    { agentId: 'Alicia', objectId: 'carrot', value: 90 },
    { agentId: 'Bo', objectId: 'apple', value: 50 },
    { agentId: 'Bo', objectId: 'broccoli', value: 40 },
    { agentId: 'Bo', objectId: 'carrot', value: 30 },
    { agentId: 'Cara', objectId: 'apple', value: 25 },
    { agentId: 'Cara', objectId: 'broccoli', value: 10 },
    { agentId: 'Cara', objectId: 'carrot', value: 0 } 
    ];
let optimalMatches = auctionMatcher.match(possibleMatches);
console.log(optimalMatches);

Output

[ { agentId: 'Alicia', objectId: 'carrot', value: 90 },
  { agentId: 'Bo', objectId: 'broccoli', value: 40 },
  { agentId: 'Cara', objectId: 'apple', value: 25 } ]

Test

To run all unit tests except the slow ones:

npm test

Some tests on large datasets take a long time to run (~2 minutes). If you want to include these in your test run, do:

npm run test-all

About

A Node.js module that finds the optimal set of matches between a set of agents and a set of objects, using an auction algorithm.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published