Skip to main content

Property Selection Strategies

Each listing has multiple properties (room types). The picking strategy decides which properties and how many units to book to satisfy the guest requirement.

Available Strategies

StrategyWhen to UseHow It Works
GREEDYDefault (no guests specified)Picks best-scoring candidate iteratively
OPTIMALDefault (guests specified)Exhaustive backtracking — always finds global optimum
CHEAPEST_FIRSTBudget-consciousSorts by price per slot, fills greedily
HIGHEST_RATEDQuality-focusedSorts by rating (desc), fills greedily
MIN_WASTEMinimize empty bedsScores by wasted capacity, picks least wasteful

Scoring Formula

Every strategy uses ScoringUtil to evaluate candidates:

Static Cost (per property, independent of guest need)

staticCost = (price / 100) + ((10 - rating) * 20)

Example: ₹5,000/night property with 4.5 rating:

priceScore = 5000 / 100 = 50
ratingPenalty = (10 - 4.5) * 20 = 110
staticCost = 160

Dynamic Score (considers remaining guest need)

diffAdults = candidateCapacity - stillNeedAdults
diffChildren = candidateCapacity - stillNeedChildren

penalty = |negative diffs| * 1000 (huge penalty for unmet capacity)
waste = positive diffs * 1.0 (light penalty for excess)

score = penalty + waste + staticCost

Listing Score (for sorting final results)

listingScore = sum of (staticCost(property) * selectedQuantity)

Lower score = better listing. Used to sort search results.


GREEDY Strategy (Detail)

while (need > 0 AND candidates remain):
1. Calculate remaining need
2. Score all candidates with current remaining need
3. Pick lowest-scoring candidate
4. Calculate required units: max(ceil(needAdults/cap), ceil(needChildren/cap))
5. Cap to available inventory
6. Add to selection, subtract from need

Complexity: O(n²) — fast for typical property counts (5-20 per listing).

OPTIMAL Strategy (Detail)

for each combination of (property, quantity):
if sum(adults * qty) >= required AND sum(children * qty) >= required:
totalScore = sum(staticCost * qty)
track minimum totalScore combination

return combination with lowest totalScore

Pruning: If search space exceeds 200,000 combinations, falls back to GREEDY.

Complexity: Exponential but capped. Always finds the globally optimal selection.

Extra Guest Charges

After properties are selected, extra guest charges are computed:

adultsPerUnit = ceil(totalAdults / totalUnits)
extraAdults = clamp(adultsPerUnit - applicableAdults, 0, max - applicable)
extraCharge = (extraAdults * extraAdultRate) + (extraChildren * extraChildRate)

This is added to each night's base rate before tax.