So here is the deal...
Assume that you have multiple clients that sell their items at different prices. As the owner, you decided to give a fair chance to every client that uses your platform. Therefore, you need some sort of a way to fill the purchase orders between the sellers in such a way that everyone gets their items sold.
Round-Robin like method is required! So for example here is a way to describe the data:
Ohad, items: 5, price: 1$
Daniel, items: 2, price: 1$
Jim, items: 3, price: 1$
Tim, items: 1, price: 1.05$
If a client wishes to buy 4 items in Bulk, he should receive the items of Ohad -> Daniel -> Jim -> Ohad
(And the next time a bulk purchase will be executed, Daniel would start the lead)
If the client wishes to buy 11 items, first it will go around the people that share the same lowest price, and then it will add Tim's on top to match the requirement of 11 total items.
And of course, if the list of sellers was longer, the round-robin principles should still exist.
I am trying to think about an efficient way to get this done... I find most solutions to be very consuming or not 1000% working.
seriously don't want to limit people with their ideas... so I would love to hear anything and we will take it from there! :/
Cheers!
Go with KISS and don't make it more complicated than necessary.
Let the law of large numbers work for you and randomly pick a seller for each order you get, then fill the whole order from that seller. If there are enough orders and you use a good enough random number generator (random() should do), it will even out in time.
This will ignore price differences, so maybe you could use
ORDER BY random() * price LIMIT 1
to pick the seller to serve an order.
Related
This is my first post on Stackoverflow but I've consulted this website very often. I was hoping someone could help me out.
I'm trying to do a mapping of a product catalogue (not sure if it's the right term) in order to simplify it in the end. What I would like to achieve is to get a overview of the current product structure.
Variables:
Product_Name: definition of the product, total of 27 unique products
Product_Type: either data, voice, add-on or non-services
Customer_segment: 6 distinct segments
Carrier_type: how is the product delivered? (fiber/coax etc.)
Optional variables:
Account_ID: customer number
Revenue
What am I trying to achieve?
I would like to see how the columns relate to each other. So if I have for example product A, then I would like to see which options are related to this particular product.
Product A
Segment A Segment B Segment C
Carrier A Carrier B Carrier A Carrier C Carrier B Carrier D
I'm looking for ways on how to make such decision trees in R since I do not want to make these on my own. Even more awesome would be to include the account ID and revenue somehow. I've already looked into Market Basket Analysis but this only gives me the most common combinations of products per account (basket). Now I want to see which products belong together and to see if there is any overlap between them in order to simplify it in the end.
I'm not asking for a complete set of code but more like a push into the right direction. Does anyone know which method of analysis would be suited to do this?
Thanks!
Briefly, i have data set of sales for the year. I need to cluster users preferences. I have vectors these sales for each user. For example,
i have vector with purchases of John this consist of 1 or zero(bought this thing or not).
[1 ,0 ,0 ,1 ,0 ]
[product1,product2, product3,product4,product5]
it means that John bought product1 and product4. May be someone saw good articles abouts this. I need to cluster and offer other customers different things, for example if some customers have the nearest neighbor(with enough small distance) then i will able to offer him things from this neighbor.
in advance, sorry for my bad english and thanks
I am interested in ideas or articles!
size of real matrix of these customers is 10^8*10^6
Use market basket analysis, not cluster analysis.
In particular, it does not assume that every customer is typical (part of a cluster) or that a customer can only be part of one.
Rules of the kind
butter, bread -> marmelade
are excellent for product offering.
I'm working on this kind of data structure :
Now, say I have to search for products that are < 90 EUR, it should only returns the product "item2". On the other hand, if I search for products that are == 100 EUR, I should only returns the product "item1".
I have 60 000 products and 16 currencies, so I just can't convert all products in all currencies on a daily basis (as the currency rates updates daily) only to be able to perform this search.
I have 2 questions :
is this use case a good fit for a Postgres function ? Is there any other good and sustainable solution if not ?
if a postgres function is the solution. Given that I'm using Ruby on Rails (4.2) and the search requests (on products sizes, colors etc...) are chained using ActiveRecord : is the call to the DB function still chainable and usable in AR ?
Thanks for your help
Using a function for this is a terrible idea, because performance will suffer greatly: the exchange rates will change over time, rendering your indexes useless.
Further, it's a terrible idea to store a single price per item. Thing psychological prices and tax considerations: if something is €99.99 including VAT in the Eurozone, it'll probably make sense to sell it for $99.99 plus sales tax in the US. No amount of exchange rate manipulation using functions or other will change that. (Compare the prices of Apple in the US, in France, in the UK, etc.).
For each item, associate a price in Euros, one in Dollars, etc. -- each with a currency_id, and have the exchange rates reside in a separate table. Or create some kind of price-list table in which you associate prices based on currency (e.g. €99 = $99) to a price_id, and associate the products (it's actually the SKU, btw) to their corresponding price_id.
You can fill this data in semi-automatically using an exchange rate table, and periodically update them using one as well. But really: do reserve the ability to manually set prices, make sure you mark prices as including or excluding tax. And when it comes to taxes, don't forget that tax rates are different from a place to the next and from a product to the next.
For the record, I ended up creating a new column "price_eur" in the "products" table where I convert each price to EUR whatever is the original currency. Doing so I can perform a consistent search based on this price_eur column.
I just wanted to know if there was an alternative solution but looks like there is no other simple way...
In Opencart, I have a product which you select colors of.
Basically the pricing should be: Each additional printing color costs a flat rate of $50 + $0.25 for each.
So if a person were ordering 1000 items, with 2 colors, the cost would need to be BASECOST + $100($50x2) + $250(1000x$.25)
Right now I'm only able to set up the cost for each product. Since people are going to be both ordering large and huge quantities, there's no easy way to build it into the each price.
I could have sworn I saw a free extension awhile ago that allowed you to set both a flat price for an option, and a price for each on the quantity. Trying searching everything I could think of, but the only thing that I could find is for shipping (we already have a pretty complex setup for the shipping, so can't mess with that).
Has anyone came across a solution, or simple extension for this problem. Seems like a simple thing, but still can't find a solution for the life of me.
Thanks!
The easiest way I can see to do this would be to have fixed costs for certain price breaks which can be done through the Discount tab of each product, and can even be set based on customer group if you have wholesale as well as regular customers or other customer groups
Say your company is willing to sponsor the fees for taking programming certification examination. What is the best aproach to implement this?
I would say if the programmer passes the exam at the first try, it shoud be fully sponsored.
If the programmer doesn't pass the first try, the 2nd exam should be 50% sponsored. If failed 3rd time, the programmer should pay in full (including for the first 2 exams).
I find that it is difficult to balance between voluntary taking up the exam (for confident programmers) and mandatory / policy set by the management.
Anyone like to share your experience / suggestion on this?
For optional certification:
At our company, you must receive a pass to get any sort of compensation. Anything below, and you get nada. If you fail the first two times and pass the 3rd time, you still pay for the first two times...but the company will pay for the third.
For required certification:
Company pays no matter what.
Sponsor the first time regardless, that includes the necessary training.
Failure or success of the exam is of secondary importance comapred to the training, many companies often require staff to be regularly trained too, so its not much of a cost in the first place.
Taking the exam is also up to the staff member, let them take it if they want, but don't worry if they don't.
Fully sponsor training and test fees for the first attempt of the test and give a small bonus (~ cost of test fees) upon successfully passing a test or attaining a certification.
That way if the person doesn't pass on the first attempt, there's still an incentive to pass, even when they're putting up their own money.