Very preliminary design question

Very preliminary design question

Old forum URL: forums.lhotka.net/forums/t/2837.aspx


albruan posted on Wednesday, May 09, 2007

I am starting to take a look at creating a bartering system for use by several (somewhere between 23 and 37) NPOs (non-profit organizations) here in town to streamline setting up trades among them for material goods and services.  If it was just two NPOs, there wouldn't be a problem; both would enter what they have and what they need and then the system would let both of them know if there was a match.  For example, if OrgA has Item1 and needs Item2 while OrgB has Item2 and needs Item1, there'd be a match of needs and each NPO could help out the other.  On the other hand, there wouldn't be a match if OrgB has Item2 and needs Item3.  However, if there's a third NPO, OrgC, who has Item3 and needs Item1, the three organizations could help each other out.  OrgA would transfer Item1 to OrgC, OrgC would then transfer Item3 to OrgB who would then transfer Item2 to OrgA.  The problem is compounded when each organization has several items they're offering in return for several other items.  I know it can be done, but I imagine it will require a lot of recursion going on.  My questions are these: is it doable with CSLA and where, or how, should I start my design? 

Bayu replied on Wednesday, May 09, 2007

This is a nice challenge!

But note that the core of your challenge really has nothing to do with Csla. Csla is not a rule-engine or logic parser or something like that. However, as far as persisting and validating the data is concerned: yes, csla can help you out.

At this point however, it seems to me that you are rather in search for a smart algorithm that can help you solve the 'bartering matrix'.

As an Artificial Intelligence student I can tell you that algorithms most probably exist in order to address and solve these complex challenges. Unfortunately I cannot give you a specific name (yet) but perhaps it's not too hard to figure out the details yourself. One way to look at it is through a matrix where the columns denote your resources and the rows denote your organizations. Using positive and negative values you can then indicate which organization needs/offers which resources.

Given this matrix you can:
- easily compute which needs can be fullfilled
- which companies have the potential to be helped out partially and/or fully
- using the previous you can prune your matrix to only include those companies that can actually be helped out partially or fully
- then you can compute a 'distance matrix' from this pruned matrix. It is up to you define a distance measure that matches your strategy. In any way, this distance function would compute the resource-distance between any two companies and should be designed such that smallest distances match companies that are most likely or preferred to help each other out. This distance matrix therefore is always a square matrix with as many columns/rows as you have companies in the pruned matrix. Each element in this matrix then stores the distance between the two companies that intersect on this element.
- if you wish you can also compute a distance matrix per resource. You would then have as many distance matrixes as you have different resources.

Perhaps at this point you would like to put all your companies in a resource-graph where the nodes indicate companies and where arrows connect companies that can help each other out on one or more resources. In this graph you should be able to find out easily which companies are fully or partially helped out. You would then eliminate these companies from the graph and also 'fix' the resource assignments. From this you can continue in an iterative fashion and keep assigning (fixing) resources until no more companies can be helped out.


I am aware that this has become quite a technical and perhaps also a bit a sketchy answer. I hope it is of any help and enables you to get started on designing such an algorithm. It will be challenging for sure, but if you ask me it is quite a nice challenge to face. ;-)

Have fun and good luck.
Bayu



BBM replied on Wednesday, May 09, 2007

Hi Allen.

Yes you can use CSLA for such an application. 

All object oriented-system design starts with the enumeration of Use Cases.  From each Use Case, decide what objects you need and what each object's unique responsibility/behavior will be.

Hth

BBM

cjherasmus replied on Friday, May 11, 2007

Allen,

some of the answers to your questions, are somewhat over complicating things. Here's my thinking.

It sounds that you've done user requirements analysis and probably understand already the different business processes that is currently driven by NPO's or have created new business processes. A word of advice. It doesn't mean anything if you have a technical solution, but your customers doesn't know what they want or what they're doing. Assuming that you are past this stage.

Have a look at the bigger picture in terms of architecture, i.e. hardware, software, processes, end-users, locations, infrastructure, etc. Assuming that the NPO's are distributed in different locations, look at web technology with maybe a centralized data store. You could make some more money here if you act as service provider.

How big is your project team? What kind of support would you offer? Who's maintaining the systems?

Assuming that only certain people will be allowed to do transactions, establish communication mechanisms between NPO's via web or email technology. Security would play a big part here. You'll probably have a database with all the NPO's data on it, if you go centralized. It would be like a dictionary where NPO's could look up items for exchange, etc. Much like Amazon or something similar, instead, you'll have NPO's and not indivudual users, you'll have items instead of books. You'll exchange instead of buy.

There's probably many ways to go about implementing this. A NPO ABC logs in and search for an item they need. A result is displayed where to find item. NPO sees that item is avialable from NPO XYZ. NPO ABC puts in a exchange request to NPO XYZ. An alert is initiated at the NPO XYZ offices via email, web, etc. NPO XYZ accepts or rejects. Datastore is updated, i.e. item now belongs to NPO ABC. Delivery is initiated.

As you can see, there are many technical and non-technical issues and processes. Be sure that CSLA will support the business and sub-sequently the information system.

Good luck

Regards

 

Copyright (c) Marimer LLC