PHP-Function Help

Started by Volker Harun, February 01, 2009, 07:46:31 PM

Previous topic - Next topic

Volker Harun

Hi,

I am in the very need of some help.  :-\
I am programming a web-interface for - yet - personal use to satisfy my customers.
And I am running into one severe problem:  :-[

To simplify it:
Using a database, I get a list (A) of i.e. 10 products by 10 producers which are equivilent and could be exchanged by each other.

My customer has i.e. 10 users. User 1 likes product 1,3,5,6,7,9 .... hte other one likes only product 3. Another one is satisfied with the products 2,5,9,10 and so on. (In fact these behaviours are part of some treaties which are included in the database).

Now I would like to get a list of producers ... the shortest list to satisfy all the users of my customer.  8)

By the way, to clearify it: I have 144 treaties with each about 20.000 products out of a list of ~400.000 to take into account.
Luckily each of my customer has only 10 to 12 important treaties to take care of.

I must be able to present this bit of software within the next 7 to 10 days to some industrial partners to get some sponsoring.
And if it is a breakthrough, I will be able and willing to share some of the benefit (read profit).  8) ;) ;D

You folks should know me by now ... I am weird, but willing to share  ;)

Thanks in advance,
Volker

old_blaggard

Hmm... your example is a bit hard to follow. Could you flesh it out a little to make it a bit clearer?
http://www.terragen.org - A great Terragen resource with models, contests, galleries, and forums.

Volker Harun

Well, I try to put it into an example:

I have a couple of wholesalers (W) for sport-goods.
Wholesaler 1 (W1) has anything that Adidas offers, the shoes of Nike and shirts of Puma.
(W2) has everything that Nike, Puma and Reebok offers.
(W3) has everything of Nike and Reebok and some Adidas stuff.
(W4) has everything of Puma and Reebok and some goods from Nike.

To satisfy every customer I could work with the wholesalers W1, W3 and W4. Or the better solution would be to choose W1 and W2.

I have to check a few arrays:
The stock of my customer (Customer-Stock-array CS() ) and the stock of the wholesaler (W1(), W2(), ...)
And I need an algorhythm that chooses the least wholesalers to satisfy one of my customers.

The thing will be a bit more complicated for me as there are some favourite brands and so on, but I have a solution for that in mind ;)

Is it easier to get the point this way?  ???

Thanks Volker

FrankB

wow, that sounds like a pretty complicated problem. I have no immediate solution for you, but what I would do to start is searching google for the search terms algorithm, optimal supplier combination, find optimal combination... and the like. I'm sure your problem has been solved elsewhere, so maybe you can employ the benefits of the internet for your purposes here.
I think that part of the solution would be having the right DB query in the first place.

Regards;
Frank

Volker Harun

Hi Frank ...
you are right ... I am hoping to get things easy with an accurate DB-query.

To keep sticked to the above example, I have for each of the following a table:
- The products (all the shoes, shirts, shorts by any vendor) of course with unique fields
- The equivilant products of other brands (one article No. against a couple of numbers and vice versa)
- One table contains all the articles of all the wholesalers
This what I get each month as an SQLite-DB.

For my customers' stock I create an extra DB which imports the article-numbers of their stock.
And - now to the funny and weird part - a list of wholesalers they are allowed to work with. (Okay I do not serve the sporting industry, it is something different).

So - one customer with about 10 relevant wholesalers.
Checking each article number of my customer - one by one - arrgh it is impossible to keep it simple.

You folks should know the following .... nope I have to go for another example, else it is getting ridiculous.

mogn

Try to GOOGLE "dynamic programming"

otakar

#6
Seems like no big deal with a SQL query assuming all is in a relational database in normalized tables. Got an ERD of all that? This seems like a fun project, actually. I don't think PHP even enters the picture for this.

Volker Harun

Thanks for the input, I will keep you in touch tomorrow, as I just came back from a short but tough journey.

That SQlite DB is by the way a snippet of a very large IBM DB2. The small DB is only used as a fallback on network problems ... but I have other purposes.  ;)

Now I have to take a look back and need to sort out new ideas and goals I got these days.