What is an efficient algorithm for simulating purchasing decisions? -
i'm attempting code simple game-like simulation of consumer purchasing products. i'm looking algorithm satisfies following:
inputs:
- an amount of money consumer has spend
- a collection of want scores, w1...wn (where higher value means consumer wants more)
a collection of products, each product has:
- a collection of want scores, s1...sn (where value corresponds how product satisfies particular want)
- a price
- a number in stock
output:
a set of pairs of form (product, numbertobuy). amount products satisfy wants of consumer subtracted values w1...wn, "perfect" solution 1 resulting sum of w1...wn minimum.
the set must satisfy following absolute constraints:
- numbertobuy less or equal number of product in stock.
- the sum on entire set of price of product multiplied number of product buy less or equal money consumer has.
if there multiple solutions result in w1...wn being @ same minimum, best 1 of sum of price of of products purchase lowest. price secondary concern satisfying wants, however.
notes:
- there no benefit "oversatisfying" want - want values cannot drop below 0 - there no inherent penalty oversatisfying want either, other you're spending money no benefit.
- efficiency trumps finding optimal solution, within reason - quick algorithm finds "pretty good" solution not the optimal solution better slower algorithm finds optimal solution. ideally, though, i'd come somewhere close optimal solution (i.e. consumer doesn't make decisions blatantly sub-optimal, choosing buy more expensive of 2 products otherwise identical).
one brute-force approach problem enumerate possible combinations of products can purchased satisfy absolute constraints, take 1 best satisfies customer's wants, become far slow number of products available consumer increases.
does have idea of efficient approach?
bonus:
i'd interested if can think of either separate algorithm/approach or modification on algorithm above problem, goal not minimize sum of w1...wn, rather sum of squares of w1...wn - i.e. reducing high want values more important reducing low want values.
Comments
Post a Comment