Sunday, June 14, 2009

Reverse Auction and finding best price among multiple Suppliers using C#.net


Auction is the process of buying and selling Goods or Service based on bids.

Generally in auction, the seller puts an item (e.g Digital Camera) up for sale. Multiple buyers bid for the item, and one or more of the highest bidders will be selected to buy the goods at a price determined at the conclusion of the bidding.

There are many online auction sites e.g eBay.com are available in internet.

In these Auctions Buyers compete to get a Good or Service. So it will give benefit to the Seller.

But, in another form of Auction which is called as Reverse Auction , sellers compete to obtain business (Goods or Service). It will give benefit to the Buyer.

i-e In Reverse Auction the role of Buyer and Seller are reversed. It drives to reduce the purchase price.

In physical world, it is bit difficult to conduct Reverse Auction. Assume that you are going to purchase Digital Camera. And assume that in you place there are 10 shops available to sell different Digital Cameras. You can not expect all the 10 shop keepers to meet you and give their price list for enabling you to get the least price. Instead, you need to go to all 10 shops and get quotation from all of them and then you need to select least price within the 10 prices.

So, Reverse Auction in physical world is normally not much used. But in online world it can be easily implemented. So, there are lot of Reverse Auction sites available in Internet.

For example all freelance websites are working based on Reverse Auction only. Here the Buyers will be giving the requirements as Bid Request. Many Sellers (i-e Coders) will be placing bid amount. Finally the Buyer can choose the Seller who placed least bid amount.

Here the freelance website will be called as market maker.

Now we can think about how this Reverse auction can be implemented in Goods purchasing sites (i-e shopping Carts).

The Market Maker website will show the Goods from many vendors/Suppliers in their websites. The customer will be allowed to choose the items from different suppliers so that he can get least price for all the items.

As far this point, this Reverse Auction on online is simple. Now think about delivery charge.

Each supplier will be collecting delivery charge from the customer(buyer) irrespective of how many items the buyer selects from their cart. So, the buyer can not select the least priced item from each supplier blindly to get the best price.

To explain it more clearly, consider below example.

The buyer wants to buy 2 items, and 2 Suppliers are supplying those items with below prices.
Supplier/ItemSupplier1Supplier2
Item110INR12INR
Item211INR10INR


Just by seeing the above price list you will be thinking that getting Item1 from Supplier1 and Item2 from supplier2 will give least price (20INR).

But we should consider Delivery price also.
Assume below delivery price for the Suppliers.
Supplier1-6INR
Supplier2-8INR.

If we include the Delivery charge then the total price will become 34 INR(20+6+8). So it is better the get both items from Supplier1 itself. In this case the item price will be 21 INR, and delivery price will be 6 INR. The total price 27INR (21+6) will be less than 34 INR.

So we need to have specific steps/algorithm to find best price when developing Reverse Auction website. The algorithm will be again complicated as few Items won't be available with some Buyers. We need to consider this constraint also when developing Reverse Auction website.

For one of our clients we have implemented this best price finding system. We followed below steps for implementing it.

- Find permutations of all options and insert them into temp table with optionid.
- Delete invalid options from temp table.
- include delivery charge for each option in temp table.
- calculate total charge for each option and then select minimum from them.
- We can find suppliers and delivery charge for the selected option.

The core concept is simple. Just we need to consider all possible combinations and need to find total for each of them. And finally we need to choose a combination which is having least total value.
But we had to spent more time and effort to implement the first step i-e finding permutations of all options.

Because, we are having math formula only for finding permutations to select 'r' items from 'n' only when the value of 'r' is less than the value of 'n'. I-e there won't be any duplicates.

But in our case, we need to consider duplicates also. (i-e Number of Items may be 4. But we may need to select it from 2 Suppliers)

So there won't be any standard math formula/algorithm to get the result.

After doing a lot of search in the internet, finally I got a sample code written in C language for finding permutation even when duplicates available.

I then converted the C code into C# code and successfully implemented it in our Project.
As we used mdb table for doing this process, the I/O process significantly reduced the performance. So again we implemented it using C# Datatable itself.


void findPermutations(int N, int K)  //for finding all permutations
{
int[] slots = new int[K];
OptionID = 0;
while (incr(slots, K, N))
{
OptionID++;
}
}

bool incr(int[] slots, int K, int N) //it will be used by findPermutations
{

int i, carry;

insertOptions(slots, K);

for (i=0, carry=1; i < K; ++i) 
{
int b = slots[i] + carry;
carry = b/N;
slots[i] = b % N;

}




More Articles...

No comments:

Search This Blog