Ali
Ali

Reputation: 5111

Weighted Average Calculation Based on Different Criteria

I am working on a reverse auctioning system in PHP. My customers get bids from different vendors against their requested products/services. While displaying received bids to the logged in customer, I need to do a sorting based on weighted average against following criteria:

  1. Price (40%) -> Lowest price is good.
  2. Vendor Rating (20%) -> Rating = 1-5 (5 being best).
  3. Delivery Options (10%) -> More delivery options offered the best.
  4. Distance (10%) -> Lowest distance from customer location is the best.
  5. Payment Methods (10%) -> More payment methods offered the best.

So far I have been able to create following formula:

$weightage = ($price*.40) + ($rating*.20) + ($delivery_options*.10) + ($distance*.10) + ($payment_methods*.10);

I need to show bids having highest weightage value on top. I am confused about the addition/subtraction of the weightage based on what is best for customer i.e if price is lower then this should be considered best for customer and should I add weightage or subtract weightage?

Any help would be appreciated. Thanks

Upvotes: 0

Views: 362

Answers (1)

Ali
Ali

Reputation: 5111

I got it sorted out. Here's what I did:

Quote #1 (Best Quote)

Price: 120

Rating: 5

Delivery Options: 2

Distance: 2000 km

Payment Methods: 5

Availability: 1

Price Factor = 1 - ( (Price - Min Price) / (Max Price - Min Price) ) = 1

Rating Factor = ( (Rating - Min Rating) / (Max Rating - Min Rating) ) = 1

Delivery Options Factor = ( (Delivery Options - Min Delivery Options) / (Max Delivery Options - Min Delivery Options) ) = 1

Distance Factor = 1 - ( (Distance - Min Distance) / (Max Distance - Min Distance) ) = 1

Payment Methods Factor = ( (Payment Methods - Min Payment Methods) / (Max Payment Methods - Min Payment Methods) ) = 1

Availability Factor = ( (Availability - Min Availability) / (Max Availability - Min Availability) ) = 1

Quote #1 Weightage = (Price Factor * 40%) + (Rating Factor * 20%) + (Delivery Options Factor * 10%) + (Distance Factor * 10%) + (Payment Methods Factor * 10%) + (Availability Factor * 10%) = 1

Apply same formula to other quotes, you'll get weightage for each quote, and then you can sort quotes easily (Order by Quote Weightage Asc/Desc).

Upvotes: 1

Related Questions