Combination of orders and suppliers - algorithm

So i have the following situation.
I want to find all possible combination of product order at an amount of suppliers.
Lets say i have 3 products
Product G
Product S
Product X
Now lets say i have 3 suppliers
Supplier A
Supplier B
Supplier C
What are all possible combinations of orders? Im not really a math genius so i tried writing them out (27 combinations):
However im at a loss how to calculate this without writing it out like i did.
Im sure there is an algorithm or simple calculation for this.

Related

how to get available quantity of Lot number

how to get available quantity of Lot number in multiple warehouse
suppose i have 3 warehouse A,B and C,
Lot number LOT0001
i want sum of total currently availabel quantity of LOT0001 in all three location.
In odoo you can pass filters in context.
ex:
context={'lot_id':'','owner_id':'','package_id':'','warehouse':'','force_company':'','location':''}
product.with_context(context).qty_available
In odoo base module system will automatically calculate quantity based on context.
If you not pass context then system will give you sum of all warehouse stock.
this may help you.

Magento: Minimal quantity different sizes

I'm making a shop with clothing. But there is a minimal order amount per order. Now i want to have a choice that the customer can make with different sizes.
So the minimal count is 10 pieces, and if a customer wants 4 size M, 5 size L and 1 size XL. what is the easiest way in code that i can accomplish this?
I'm using simple products associated with configurable products.
Maybe this could help :)
How to get the Total Quantity Of All the Items In your Shopping Cart

Approximating Price

I have a set of products. Each product is a variation of a non existent “parent”. Also, each product (let’s call them child products) has its own individually assigned price in our database. Here is a small example set.
Parent SKU is 1000.
Product Children are:
1000-TankTop-SM - 14.95
1000-TankTop-2X - 17.95
1000-Hoodie-SM - 34.95
1000-Hooodie-2X - 39.95
Here is the problem. Our database lists each real child product price (as directly above) in a one-to-one relationship. Each product has a SKU and I can look up the price of each product by SKU. I have a website that that cannot support this method of pricing. The way pricing works is this. I create a “parent” product. Each parent product must have a base price. The prices of variations are created from adding or subtracting a dollar amount. So a “parent” has two attribute sets, product type and size. A plus or minus amount must be associated with each attribute. So from my example above we have.
Sizes:
SM +- ?
2X +- ?
Product Types:
TankTop +- ?
Hoodie += ?
How can I decide what the variables above should equal to at least approximate the actual child product prices? Is this possible without any extreme outliers?
This sounds like a frustrating (ie: crummy) database system, since it's effectively impossible to create certain arbitrary prices. ie:
TankTop = + $2.00
Shirt = + $1.00
Sweat = + $5.00
Small = - $1.00
Medium = + $0.00
Large = + $3.00
X-Large = + $5.00
With the above example, it would be impossible to have a Small Shirt cost $10.00 while simultaneously having a Medium Shirt cost $10.50.
So, each product has a price defined as a sum of: BASE_SKU_PRICE + SIZE_MODIFIER + STYLE_MODIFIER. This means that you cannot assign an arbitrary price value to each unique item, so you'll need to use a regression model.
If you want to re-adjust the price for a massive table of items, the easiest approach to minimize outliers would be a multivariate variation of linear least mean square errors approximation (LMS), which is just another type of multivariate linear regression approach.
This will allow you to model each unique item (ie: SKU) as a function of:
y = a + bX_1 + cX_2
If you want a very tidy approach to handling this for a production database system, you would be best off just using MATLAB or SPSS to create your database table, as you can specify confidence intervals, and other parameters to help optimize your approximation.
Finally, I found an example online which you could try out in OpenOffice Calc or Microsoft Excel. This will give you a working algorithmic approach rather than you having to derive the analytical form equations and generate code from them. It might even be enough to solve your problem without having to break out MATLAB or SPSS.

Limit stores - most efficient or easy approach?

Say you have multiple vendors (lets say 5) all selling the same items for different prices. You must buy item A,B,C, D, E. Each vendor has item A,B C,D,E so you can easily go through each vendor and find the cheapest version of each item. However, say you are limited to only shopping from X vendors. So you must now find the cheapest combinations that make sure you do not use more vendors than allowed. How does one solve this problem without trying every combination of vendors?
Another way of phrasing an example.
for 5 shops, we are only allowed to use 2 shops to buy 5 items (with each item at a different price in different shops). How do we save the most money? Is there a method of solving without trying every combination
your search is about linear programming ... realy long to explain ^^ : https://en.wikipedia.org/wiki/Linear_programming

Methods of comparing prices

I will create a list of products that I wish to buy. Let's say they are all given a unique reference code. I have a list of suppliers I can buy from and for convenience each supplier uses the same reference code for each product.
Some suppliers charge shipping. Others only charge shipping if you spend less than a certain amount. Some suppliers discount certain products if you buy them more than once but there may be restrictions (such as by 1 get 1 free).
It is extremely easy to take the list of products I want to buy and tally up the total it would cost to buy all of them from each supplier. What I want to do though is create a script to work out whether it would be better to split the order.
For example:
Retailer A charges:
Product A - £5
Product B - £10
Product C - £10
Product D - £10
Shipping - £5
Retailer B charges:
Product A - £5
Product B - £12
Product C - £12
Product D - £30
Shipping - £5 - free if spending £20 or more
In this case, if I wanted to buy Product C only, the cheapest would be from retailer A.
If I wanted to buy:
1x Product A
2x Product B
1x Product D
The cheapest would be retailer B (because of the free delivery) for products A and B and to then split the order and purchase product D from retailer A (as the price even with delivery is significantly lower even with delivery included).
So in my head it's not a complex task and I can work it out very easily on paper. The question is, how I would translate this into code. I'm not looking for the code to do it - just some guidance on the theory of how to implement it.
If we restrict the problem to simply choosing which vendor to buy each product from, and you get a vendor-dependent reduction in shipping cost if you spend a vendor-dependent amount, then you can formulate your problem as an integer linear program (IP or ILP), which is a good strategy for problems suspected to be NP-hard because there has been a lot of research and software packages developed that try to solve ILP fast in practice. You can read about linear programming and ILP online. An ILP problem instance has variables, linear constraints on the variables, and a linear objective you want to minimize or maximize. Here's the ILP set up for your problem:
For each product that a vendor sells, you have one vendor-product variable that tells how many of the product you will purchase from the vendor. For each of these variables you have a constraint that the variable must be >= 0. For each product you wish to buy, you have a constraint that the sum of all the vendor-product variables for that product must equal the total number of the product that you wish to buy.
Then for each vendor that offers a shipping discount, you have a shipping discount variable which will be either 0 if you don't get the discount, or 1 if you do. For each one of these shipping discount variables, you have constraints that the variable must be >=0 and <= 1; you also have a constraint that says when you multiply each vendor-product variable for the vendor by the vendor's price for that product, and add it all up for the vendor (so you get the total amount you are spending at the vendor), this amount is >= the vendor's shipping discount variable multiplied by the vendor's minimum amount you need to spend to get the discount.
You also have for each vendor a vendor variable which is 1 if you use the vendor, and 0 if you don't. For each of these vendor variables A, you have constraints 1 >= A > =0 and also for each vendor-product variable B for the vendor, you have a constraint A >= B/N, where N is the total number of items you want to buy.
Finally the objective you want to maximize is made by multiplying each vendor-product variable by the vendor's price for that product, adding it all up (call this part of the objective X), and then multiplying each vendor's shipping discount variable by the shipping cost reduction you get if you get the discount, adding it all up (call this part of the objective Y), and multiplying each vendor variable by the vendor's undiscounted shipping cost, adding it all up (call this part of the objective Z) then your objective is simply to minimize X - Y + Z. This is all you need to define the ILP, then you can feed it into an ILP solver and hopefully get a solution quickly.
Mixed Integer Linear Programming is ok for your problem.
You can use a free solver such as Coin Clp. If you want to know about commercial MILP solver performances, you can find some benchmarks there : http://plato.asu.edu/bench.html.
If you want to have a rough idea of the time required to solve your problem, you can run your problem on NEOS Server : http://www.neos-server.org/neos/.
When you have a lot of 0-1 variable, you can also contemplate to use Constraint Programming which often suits better for heavy combinatorial problems.
Both MILP and CP algorithms use branch and bound technique, which is faster than naive enumeration.
Cheers

Resources