Resource bartering in data grids

We present models for bartering of resources on grids. Bartering models can be useful for making resource allocation decisions in grids and perhaps even for building a so called barter grid whereby distributed resources such as electronic media can be bartered. Grids allow various resources to be shared among many users. This sharing however definitely does not mean that everyone will have unrestricted use of the resources. Some mechanism such as pricing or quotas can be employed in order to enforce controlled sharing of resources. A barter model for resource sharing can enable people or computer centers to directly get something in return for letting their resources to be used by others. We utilize directed hypergraphs to develop a barter model in which multiple resources can be traded. We prove that the decision version of the multi-resource bartering problem is NP-complete. We present an integer programming formulation for the bartering problem. We also present a linear time algorithm to compute components that may contain feasible bartering solutions. We generalize our multi-resource bartering formulation to the case where multiple instances of resources are present. Finally, we present various computational results from our software that makes use of LP SOLVE and CPLEX mixed integer programming libraries to solve example bartering problems.


Introduction
Grids allow various resources such as cpu cycles, storage, licensed software executions and data to be shared among many users.For small academic and research communities that know and trust each other, free unrestricted sharing of resources may not pose a big problem since people in these communities are courteous and avoid abuse of resources.On the other, when we move to larger scale grids and in particular to commercial platforms, sharing, however, will definitely not mean that everyone will have unrestricted use of the resources.Some mechanism such as pricing or quotas would have to be employed in order to enforce controlled sharing of resources.The best example of what may happen if resources are provided free of charge is the spam mail problem on the Internet.If grids are to be successfully deployed on a large scale, then mechanisms must be devised to manage resources.Buyya et al. [3] and Wolski et al. [28] discuss several economic models that can be used for resource management in grids.These are commodity market, posted price, bargaining, spot market, tendering, auction, coalition, bartering, monopoly and oligopoly models.
Prices of grid resources such as cpu cycles, storage and data can be too subjective and dynamic.Therefore, we believe that pricing-based schemes such as auctions can be disadvantageous especially for parties that are going to both sell and buy resources.To illustrate this, we draw an example from the Internet domain name registration scene.Domain names are resources.Suppose party A have registered domain name X and party B has registered domain name Y.Each party knows that his domain name is valuable.But let's say that party A needs the domain name Y owned by B. Likewise, party B needs the domain name X owned by A. Knowing that their names are valuable, each party may put his domain name for sale for a huge sum of money (say $ 50,000).If these parties do not have any money, they can swap their names provided that they realise that their bids form a cycle (of length two).This realisation however, maybe difficult especially in cases where we have bid structures that form cycles of length n where n is greater than 2. In such cases, since parties may not have enough money, they are not able to bid for the requested amount and hence trading of the n names may not be possible.Yet, if were able to detect bids forming a cycle of length n, then the n names could ISSN 1058-9244/04/$17.00 2004 -IOS Press and the authors.All rights reserved all be traded.This example illustrates the disadvantage of markets based on pricing with money.By pricing items with money, we lose rich trading structures that would enable us to come up with feasible trading patterns.The well known word for direct trading of items without involvement money is bartering.In this paper, we propose the use of bartering for grid resource management and provide a formal mathematical model that enables us to develop scheduling algorithms for bartering problems.
Grids first appeared for enabling sharing of computational resources among researchers in academia and research laboratories.If grids are to be deployed successfully on a massive scale, they have to address the needs of ordinary people that make up the mass market.What do the ordinary people need?Ordinary people do not run sophisticated applications that require massive computational resources like the researchers do.They are more interested in data-centric resources such as mp3 music files, ebooks, financial reports, historical stock quotes, news and movies.We, therefore, believe that data grids rather than computational grids have much more potential to get the the attention of mass market.The popularity of file sharing networks such as Napster [16] and Kazaa [13] is a clear evidence that demonstrates real interests of the mass market.On the other hand, even though these file sharing networks are quite popular, they have one drawback and that is that files can be shared illegally.We believe that if we get rid of the sharing mechanism (that may result in illegal free copying of items) and replace it with a bartering mechanism and hence come up with a so called "bartergrid", this barter grid will get the attention of mass market.Consider someone who has purchased an ebook.After reading the ebook he may not need the the ebook any longer, so he may use the so called bartergrid to barter his ebook for something that he needs, for example, a movie.Such bartering transactions will not pose any legal problems since people will be trading their legally owned items for other legally owned items.Such a barter grid will require mechanisms for floating ownerships so that ownership of an item is transferred from one user to another.Another mechanism that will be required is a model for bartering, that is, problem definitions and algorithms that will produce feasible bartering solutions.The subject matter of this paper is only the latter, that is development of a model and algorithms which will take barter bids from users and produce optimal bartering solutions according to some objective function.
Recently complementary auction and double auction markets have received a lot of attention among researchers [9,12,15,27].These markets have purchase/sell prices as a fundamental component in their problem formulation.We believe that in its most general form involving multiple resources and multiple resource instances, bartering offers a much more general and stronger combinatorial market and that it probably contains complementary auction and double auction markets as special cases.On the Internet, several sites that offer bartering services can be found [25].These sites, however, utilize barter units in place of money.In this paper, we focus on a market that allows direct bartering.In direct bartering, multiple resources can be traded directly without involvement of money by traders.However, unlike the auctions, the bids in the barter market are made in terms of resource(s) offered and resource(s) requeste d.In our barter market, we want to choose a feasible set of bids that can be satisfied and that optimizes some objective.We will call this problem multi-resource bartering problem.
We review previous work on auctions, bartering and graph theoric results that will be useful for bartering in Section 2. In Section 3, we present a graph theoric model for multi-resource bartering problem.We also look into the problems of eliminating unnecessary resources and decomposing the problem into smaller subproblems.We present a linear time algorithm to do this in Section 4. In Section 5, we prove that multiresource bartering problem is NP-complete.In Sections 6 and 7, we give integer programming formulation of our problem respectively for single and multiple instance versions.Finally, the last two sections present timings from various tests and a discussion of results.

Previous work
The difficulty of finding "double coincidence of wants" in direct bartering was formally stated by Jevons [10].Since then a lot of studies have been carried on the analysis of bartering and monetary issues from economists' perspectives using various models [6,11,23].
Depending on the number of distinct resources and the number of instances (units) of these resources that can appear in a bid, we can classify the bartering problems into four categories: (i) Single instance single resource, (ii) Multiple instance single resource, (iii) Single instance multiple resource, (iv) Multiple instance multiple resource problems.The subject matter of this paper is bartering problems of type (iii) and type (iv).We have addressed in particular problems of type (i) and (ii) in our earlier work [17,18].These two problems have polynomial time solution.Problems of type (i) in which we maximize the number of resources bartered is in fact the graph theoric maximum vertex disjoint cycles problem that is addressed in Gutin et al. [8] (or see [2, p. 146]).Gutin et al. solves this problem with O(n 3 ) complexity by transforming it to an assignment problem.The solution of problem (i) which is formulated as a minimum cost circulation problem is illustrated through an example in Fig. 1.We represent each barter bid as an arc where the tail of the arc represents the item to be given and the head of the arc represents the item that is requested.Figure 1(a) shows an example bid graph.Given a bid graph, a capacitated network (with all arc capacities equal to 1), is constructed by employing node splitting procedure [1, p. 41].As part of the node splitting procedure, a node v is replaced by two nodes v and v with an arc <v , v > in between them.The aim of node splitting procedure is to implement node capacities with 1 unit and hence enable at most one bid to win an item.A cost of -1 is assigned to arcs corresponding to bid arcs and 0 to the arcs between the split nodes.It is easy to verify that the solution of the minimum cost circulation problem [1, p. 7] on this network will give us the maximum vertex disjoint cycles.Hence, the maximum number of satisfied bids can be found this way.Figure 1(b) shows the transformed network with split nodes.The arc labels give the (capacity, cost, f low) values.The arcs (representing bids) with flow value 1 give the maximum solution.We also note that by introducing nodes that correspond to barterers and assigning capacities that reflect the number of instances of each item, solution of problems of type (ii) can also be found in a similar manner [17].
It is also important to note the relationship of bartering to that of matching problems.In the most popular and the simplest matching problem on an undirected graph, if we replace each undirected edge (u, v) with two directed arcs, <u, v> and <v, u>, then maximum cardinality matching amounts to finding maximum vertex disjoint cycles of length two.In the special case of bartering in which a single item is to be bartered with another single item, we are solving a maximum vertex disjoint cycles problem with no restriction on cycle length.A similar relationship can possibly be established for the multi-item bartering problem we study in this paper and the gangmatching problem that is addressed in Condor by Raman et al. [21,22].Double auction mechanisms [9,12,27] in which simultaneous buy and sell bids may be placed may look similar to bartering mechanisms.Pricing, however, is a major component in the formulation of the double auction problems.Double auction mechanisms can be used in barter exchanges in which barter units are employed to value (price) resources.However, in this paper, we address direct barter exchange, in which resources are not priced by barter units.

Multi-item bartering model
Our multi-resource barter exchange is a synchronous market which consists of two main components: -Resources: Each barterer puts forward a set of distinct (i.e., single instance) resources that he owns and combinations of which he may want to trade away for resource(s).The set of all resources of all the barterers is denoted by R. -Bids: Each barterer makes a number of bids.A bid consists of a set of owned resources of the barterer that is offered for another set of resources owned by other barterers.The following example illustrates the form of a bid: We will call the offered (requested) set of resources on the the left (right) hand side as the tail (head) set of a bid.The bid simply declares that the barterer can give away resources in the tail set provided he can get the resources in the head set.We will let B denote the set of all bids by all barterers.
Having collected these bids over a period of time, we can then close the market (hence the name synchronous) and then solve the bartering problem which in the simplest case may have the objective of maximizing the number of bids that can be satisfied.In this way, we may be able to trade away grid resources directly for other grid resources without involvement of money.We put forward a few rules that must be satisfied by a bartering solution: -Rule 1: If a bid is selected (satisfied) in a bartering solution, then all the resources in the head set must be given to the barterer owning the satisfied bid.-Rule 2: In a bartering solution produced, it is possible that a subset of (i.e., none, some, or all ) of resources in the tail set may be given in order to get all the resources in the head set in a satisfied bid.What this means is that it is possible that we can give fewer resources than what appears in the declared tail set and yet be able to get all the resources requested.This also implies that it is possible to get something simply as free without giving away anything at all.-Rule 3: the third rule simply says that in a bartering solution, a resource can appear in the head set of only one satisfied bid.Violating this rule may mean giving the same resource to more than one barterer which is unacceptable.We also enforce this rule even if the bids satisfied belong to the same barterer.
Directed hypergraphs are generalizations of directed graphs.Whereas single vertices appear at the tail and head of arcs in directed graphs, arbitrary sized sets of vertices appear at the tail and head of hyperarcs in directed hypergraphs.Hence in our bartering problem, bids can be represented by hyperarcs and resources as vertices in directed hypergraphs.In the rest of the paper, we use the notation R for the set of vertices and B for the set of hyperarcs since these coincide respectively with resources and bids in our problem.We now give formal directed hypergraph definitions that we will utilize while formulating a solution technique for the bartering problem.A directed hypergraph D(R, B) consists of two sets, R and B where R is a set of vertices and B is a set of hyperarcs.Each hyperarc b = <R t , R h > is an ordered pair of non-empty disjoint subsets R t and R h of R. Here, R t and R h are the sets of vertices that appear respectively in the tail and head of the hyperarc b .For the example shown in Fig. 2 The indegree(r) of vertex r is defined to be the number of times vertex r appears in the heads of hyperarcs.Similarly, the outdegree(r) of vertex r is the number of times vertex r appears in the tails of hyperarcs.The set of vertices that appear in the tail or head of a hyperarc is called a hypernode.
Directed hypergraphs are also known as AND/OR graphs [20, p. 21].In the AND/OR graph representation, a directed graph is constructed with two types of nodes: AND nodes which represent hyperarcs (bids) and OR nodes which represent vertices (resources).Figure 2(b) shows the AND/OR graph representation of the example in Fig. 2(a).In the figure, the white nodes represent the AND nodes and the black nodes represent the OR nodes.
For the example in Fig. 2, the possible maximal (maximal in the sense that the set cannot be grown bigger) bartering solutions are If our objective is to maximize the number of bids satisfied, we choose S 1 as our maximum solution.The bold edges in the Fig. 2(a) show this optimal solution.
In summary, the resources and the bids in our multiresource bartering problem can be represented by a directed hypergraph.The feasible solutions of the bartering problem are bids, B , that have their head sets disjoint (because of Rule #3) and whose induced subhypergraphs, D (R , B ), have outdegree(r) indegree(r) for each vertex r ∈ R (because of Rules #1 and #2).

Another example illustrating problem reduction
We give another more complicated example in Fig. 3 to illustrate how some of the unsatisfiable bids and unnecessary resource nodes can be removed.The bold edges in this figure again give the solution that maximizes the number of bids satisfied.We remark the following about this solution: - Having removed all these resources and the bids that can never be part of a solution, what we are left with is a reduced directed graph which possibly contains disconnected components.In Fig. 3, there are two such components shown in the shaded regions.We will call a connected maximal subset of hyperarcs such that its induced directed subhypergraph has all its vertices, r, with outdegree(r) > 0 as a barter-candidate (bc) component.Here by connected, we mean the connected underlying undirected AND/OR graph with the directions on the arcs removed.We present the details of a linear time algorithm to compute the bc-components in Section 4.
-If we look at resource s, we see that it was used to satisfy tail sets of two bids of the same barterer.Just like getting something for free is possible, it is also possible to get multiple bids satisfied with the same resource(s).In the next Subsection 3.2, we cover the details of this objective in more detail and also introduce another model in which a resource can only appear exclusively in the tail set of one satisfied bid.

Other objectives and tail inclusive and exclusive problem cases
So far, we assumed we had the objective of maximizing the number of satisfied bids.Alternatively, in order to give the barterers a chance of dictating the priority (importance) of their bids, we can perhaps let the barterers state what fee they are willing to pay if their bid is satisfied.This can be done by associating a fee f b with each bid b.Our multi-resource problem then becomes that of coming up with a set of bids that maximize total fees.If we do this, then it is possible that a barterer may not want his resources to appear in the tail set of more than one satisfied bid even if it means that he is able to get more of his bids satisfied.Figure 4 exemplifies these two different objectives.The bold hyperarcs indicate the bids that are satisfied.Note that in this particular problem, all the bids can be satisfied as shown in Fig. 4(a) and we can collect a total of $235 in fees.But let's say the owner of resource c is willing to pay $100 to only one satisfied bid involving c.Then the solution that can be returned is shown in Fig. 4(b).In this case, the total fees that will be collected is $135.
Motivated by the terms inclusive-OR and exclusive-OR, we call the solution objective exemplified by Fig. 4(a) as the inclusive case and and that of Fig. 4 bids are disjoint.The exclusive (inclusive) case puts (does not put) similar restrictions on the tail sets.In other words, in the exclusive case, tail sets of satisfied bids are disjoint in a feasible solution.

Finding BC-components in directed hypergraphs
Let G(V, E) be the AND/OR graph representation of the hypergraph D(R, B).A linear, (|V | + |E|), algorithm for finding the bc-components of the directed hypergraph can be implemented by a two-phase procedure as follows: (i) Remove all the resource (OR) nodes that have outdegree equal to 0 either initially or as a result of propagation.Remove also all the bid (AND) nodes that have one or more removed resource nodes in their head sets.(ii) Find the connected components on the underlying undirected graph (i.e., graph obtained by removing directions on the arcs) by depth first traversal.The connected components obtained are the bc-components.

It is clear that step (ii) takes O(|V | + |E|).
Step (i) functions very similar to the topological sorting algorithm [26, p. 286].Algorithm for phase (i) is given in Fig. 5 using C++/STL (Standard Template Library) syntax.Here, V is the adjacency linked list data structure containing both the resource and the bid nodes as shown in Fig. 6.Both forward arc list (i.e., all u such that <v, u>∈ E) as well as back arc list (i.e., all u such that <u, v>∈ E) are stored for each node v.The size method (function) returns the cardinality of the lists or arrays.The variable Nr is the number of resources (i.e., it is equal to |R|).The remove nodes procedure starts by first setting the outdegree field for each resource node and putting those that have outdegree equal to 0 into the queue Q.In the body of the while loop, a resource node with outdegree 0 is removed from the queue and marked as REMOVED.All the bid nodes that point to it are also removed (since the resource in the head set of these bid nodes cannot be obtained).For each removed bid node, we also update (decrease by one) the outdegree of resource nodes that appear in its tail set.If outdegree of a resource node becomes 0, it is entered into the queue.The while loop repeats until the queue is empty.It should be clear that this removal process takes O(|V | + |E|).

Complexity of the multi-resource bartering
The following theorem establishes the complexity of the multi-resource bartering problem.

Theorem 1. The decision version of the multi-resource bartering problem is NP-complete.
Proof.Given a directed hyper-strongly connected hypergraph D(R, B) which represents multi-resource bartering bids and a positive integer K B |B|, we ask the decision question: Does B contain a multiresource bartering solution with at least K B hyperarcs (bids)?Clearly multi-resource bartering problem is in NP, since we can guess a set of K B directed hyperarcs and check in polynomial time whether the vertices (in the subhypergraph induced by guessed hyperarcs) have (i) indegree either 0 or 1 and (ii) outdegree greater than or equal to the indegree.
We transform the maximum independent set problem [7, p. 53] to the multi-resource bartering problem.An independent set in an undirected graph G(V, E) is a subset V ⊆ V such that for all u, v ∈ V , the edge {u, v} is not in E. The decision version of the independent set problem asks whether there exists an independent set of size at least K G in the graph G.We perform a polynomial transformation of the independent set problem to the multi-resource bartering problem as follows: Let adjedges(v) denote the set of edges that are incident on vertex v in graph G.   Here, an undirected graph with 5 vertices and 6 edges are given.The corresponding directed hypergraph with vertices and hyperarcs that will be constructed are also given on the right.
The independent set problem on G(V, E) can then be stated as a bartering problem on D(R, B) : Does B contain a multi-resource bartering solution with at least 2K G hyperarcs?To show that solution of the multi-resource bartering problem will give an independent set of size K G , we note that K G of these bids will be the <{v}, adjedges(v)> hyperarcs and the other K G will be the corresponding <adjedges(v), {v}> hyperarcs.The bartering solution guarantees that the head sets of satisfied bids are disjoint (because of Rule #3).Hence, the head sets of <{v}, adjedges(v)> hyperarcs are disjoint, meaning the set of all incident edges , i.e., adjedges(v) of each of the K G vertices will be disjoint.Since, each vertex v in an independent set of a graph also has adjedges(v) disjoint, then it is clear that the K G vertices in the tail of <{v}, adjedges(v)> hyperarcs form an independent set for the graph G(V, E).Conversely, a solution to the independent set problem induces a solution to the bartering problem: Corresponding to each vertex v that appears in the independent set, bids <{v}, adjedges(v)> and <adjedges(v), {v}> appear in the solution of the bartering problem.

Integer programming formulation
We solve the inclusive and exclusive case multiresource bartering problems by formulating them as integer programming problems.Let us define an |R|×|B| hypergraph matrix T as follows: and similarly the H matrix as: For the example in Fig. 1(a), nonzero entries of matrices T and H are as follows: Let us denote 0 as vector of 0's and 1 as a vector of 1's (both of which are of size |R|).We also define a fee (or weight) vector f of size |B| which has each component set to the fee (or weight) amount f b that we would like to maximize.

Inclusive case
We can now express the inclusive multi-resource bartering problem as the following integer programming problem: subject to constraints : Note that if the variable x b is 1 in the solution, then this means bid b is satisfied.Constraints of type (2) basically enforce our rule which says that a resource can be in the head set of only one satisfied bid.Constraints of type (3) simply says that the outdegree of a resource must be greater than or equal to the indegree the feasible solution.The objective function maximizes the total fee (weight).If we want to maximize the number of bids satisfied, then we can set f = 1.

Exclusive case
In order to get a formulation for the exclusive multiresource bartering problem, we simply add the constraint set T x 1 to the inclusive multi-resource bartering problem in order to enforce the restriction that a resource can only appear in the tail set of one satisfied bid.However, by substituting this new constraint set into (3), we now see that the Hx 1 constraints become redundant and hence can be removed.As a result, we get the following formulation of the exclusive multi-resource bartering problem: subject to constraints :

Redundant constraints
We also remark that redundant constraints may be generated in ( 2), ( 3), (6), and (7).To identify these, let t b = tail(b) and h b = head(b).Let also S t = {t 1 , . . ., t |B| } and S h = {h 1 , . . ., h |B| }.We will define conset(S, r) as the set of members of S that contain resource r, i.e., conset(S, r) = {s ∈ S | r ∈ s}.In constraints of type ( 2), resources that have conset(S h , r) identical will have the same row values.Hence, we can delete the redundant constraints of type ( 2) by finding two or more resources that have identical consets.We can repeat the same process for constraints of type (6) this time by considering conset(S t , r).Similarly, for constraints of type ( 3) and ( 7), resources which have both conset(S t , r) and conset(S h , r) identical will have the same row values.The redundant constraints that result in this way can also be removed.

Multiple instance multi-resource bartering
We now formulate the most general form of the bartering problem in which we have multiple resources with multiple instances.
To illustrate the multi-instance multiple resource bartering, we present the following example scenario with three barterers: -Barterer u 1 owns 2 units of resource a and places the following bids: Note that numbers in parantheses above give the number of instances of resources given or requested.The directed hypergraph corresponding to this example is given in Fig. 8.
We now introduce additional notation to facilitate the formulation.Let: For the aforementioned example, the supplies variable has the following values: Assuming rows 1, 2, 3 and 4 represent the resources a, b, c and d respectively, the head matrices are given as follows: Similarly, the tail matrices are given as follows:

Exclusive multiple instance multiple resource (Exclusive-MIMR) bartering
Our earlier formulation given by constraints (6-8) for the single instance version generalizes in a straightforward way to the multiple instance of this problem.We formulate Exclusive-MIMR problem as folllows: In constraint (10) the 2-tuple (u, r) stands for barterer u who owns and offers for bartering resource r.In this constraint, we simply sum the instances of the resource r that are to be given away by barterer u in his selected bids and constrain this quantity to be no more than the barterer's resource r supply.Constraint (11) is the multi-instance version of the constraint (7) previously given.

Inclusive multiple instance multiple resource (Inclusive-MIMR) bartering
Unlike the exclusive-MIMR case, it is not easy to start with the single instance inclusive constraints (2)(3)(4) and extend them in a straightforward way to to the multiple instance case.It is better to rethink the inclusive-MIMR constraints carefully.If we concentrate on a resource r, then we surely should not give away more than the total number of instances that is owned by the barterers.However, is this constraint enough?As in the single instance case, the answer is no.We have to give only if we are able to satisfy our bids that offer them.In the single instance case, since a resource has only one unit, that means there is single barterer owning it and hence there is no possiblity of a resource being used to satisfy (i.e., appear in the tail of) bid(s) of another barterer.But in the case of inclusive-MIMR, since we keep the total number of resources, using the total number of resources only to constrain the number of resources given away exposes us to the danger of someone's resource being used to satisfy others' bids.Therefore, we have to limit the supply provided by a barterer to the minimum of the number of units he owns and the quantities that are used in his satisfied bids where this particular resource appear.We express this as follows: Let us now go back to the single instance case and see whether the above constraint indeed generates the single instance inclusive constraints (2-3).In the single instance, we have S (u) r = 1 and one barterer u that owns the particular resource r.So, the above inequality simplifies to: We can get rid of the min term by writing the above as two constraints: We can conclude that the above two constraints are indeed the single instance inclusive constraints 2 and 3 respectively.If we return back to the inclusive-MIMR case, instances of a resource can be owned by more than one barterer.If there are n r barterers that own resource r, then we can get rid of the min term by writing 2 nr constraints each of which takes either the S term from each barterer.For example, if we have two barterers u 1 and u 2 that own resource r, then we would write the following four constraints: .
The above enumeration scheme may be attractive if n r is a small number.For larger n r , an alternative procedure is to introduce additional variables that replace the min terms.We introduce a nonnegative integer variable, y (u) r in place of the corresponding min term.Hence, for a particular resource r, we can now rewrite the constraint (13) as the following constraints: r .
We can now give the complete inclusive-MIMR problem formulation as follows: 17)

Implementation and tests
We have developed code which solves the multiresource bartering problem by making use of existing mixed integer programming (MIP) packages.We have used two MIP solvers.The first is the LP SOLVE [5] which is a linear programming solver that is freely distributed under GNU Lesser license.LP SOLVE also contains a MIP solver that employs branch and bound technique.The second is the CPLEX MIP Solver [4] which is a commercial package and has a sophisticated MIP solver.We have generated various test cases for single instance multiple resource bartering problem by randomly generating bids.We have used 4 parameters while generating the test cases.These are: β: denotes the number of barterers.
ω: denotes the bound on the number of resources owned by each barterer.The actual number of resources for each barterer is generated randomly in the range 1, . . ., ω. ρ: denotes the bound on the number of bids made by each barterer.The actual number of bids for each barterer is generated randomly in the range 1, . . ., ρ. φ: denotes the bound on the number of resources in the head set of a bid.The actual number of resources for each bid is generated randomly in the range 1, . . ., φ.
Note that the number of resources in the tail set of each bid is also generated randomly in the range 1, . . ., ω.
Finally, the resources that will appear on the head and tail sets are also generated.The rand() function was used on the Solaris operating system as random number generator.The characteristics of a number of tests generated are shown in Table 1.Solutions of the generated single instance multiple resource bartering problems were obtained by solving (1)(2)(3)(4)(5)(6)(7)(8).The weight of each bid was taken to be one so that we could maximize the number of bids satisfied.
The tests were carried out on a SUN HPC 4500 server with 400 Mhz processors and 3 GBytes of memory.The execution times for the tests described in Table 1 are given in Table 2.The test runs that have >24 hrs.as their solution times were terminated because they took very long and did not produce any answer after 24 hours.These tests are not meant to be comprehensive performance evaluation of the LP SOLVE and CPLEX packages.Rather, they were used to test the developed models and routines.The tests, however, do give us some feeling about execution times.We also ran other tests and our observations are the following: -LP SOLVE execution times exploded when the number of bids reached above 200.-The exclusive case always took longer time than the inclusive case.If we look at the constraints for both problems, we see that in the inclusive case, only the head sets of bids in the solution should be disjoint.But in the exclusive case, not only the head sets but also the tail sets should be disjoint.This is probably making the problem computationally harder.-CPLEX MIP solver worked fast until around 1000 bids.After that it also started to take longer.We had test cases with around 1800 bids which did not terminate within 24 hours even for the inclusive case.

Discussion and conclusion
In this paper, we have proposed the use of direct bartering techniques for managing resources in grids.We believe that bartering techniques offer advantages since they make it possible to have more complex resource trading patterns.This, for example, may help us to get rid of liquidation problems and may make trading possible in cases where due to subjective pricing a solution may not exist.We have presented a new mathematical model for the multi-resource bartering problem by representing it as a directed hypergraph problem.We have also presented the notion of bc-components in directed hypergraphs which help us to remove unnecessary resources and bids from the original problem.We have implemented programs that make use of existing integer programming solvers.We have performed a number of tests.However, in order to determine suitability of the MIP packages for real life use, more computational experiments need to be done.
We have also proposed a so-called bartergrid where items all over the world could be bartered.Such a bartergrid would be an excellent medium for trading electronic media.Looking at recent news, we believe that a bartergrid can even be established for the matching of other items such as human organs.The clever three-way transplant done by doctors in Johns Hopkins University [14,24] is in fact an excellent example that demonstrates the power of bartering.We also note that existing computational grids can also make use bartering: For example, different computer centers can barter jobs with each other.
The software we have developed for testing our models is called BarterMachine.An alpha version of this software is available on the Internet [19].Users can enter bids and the barter engine will return the multiresource bartering solution that maximizes the number of bids (or total weights assigned to bids).Note that our publicly available sofware uses LP SOLVE and can only solve small problems.
As the results of our tests show, faster solvers are needed to solve the multi-bartering problem.However these results should not make us pessimistic about adapting bartering in real life.Heuristics can be built for example by filtering bids so that polynomial time algorithms (single/multiple instance and single resource bartering) can be applied at first to find some solutions if there exists any.Heuristics can also be devised that partition the large number of bids into smaller sets that can be solved by the optimal solver in parallel in a reasonable amount of time.Another approach that can be followed is that we can enforce small number of bids by (i) keeping the bidding time short and/or (ii) limiting the number of bids per user.Hence when we reach a threshold number that can be solved in a reasonable time by the optimal solver, the algorithm is run.Winning bids can be removed from the system and the remaining stay for the next run of bartering solver and so on.
Another issue that needs to be clarified is that when developing our model, we assumed the barterers always bid non-empty set of resources.But what happens if a barterer wants to give away resource(s) for free or bid for resource(s) by offering nothing for them.This problem can also be taken care of in our model.We introduce a fictitious (dummy) resource called NOTH-ING.Then if someone wants to give away resource(s) for free, he places the bid: resource(s) => NOTH-ING.If on the other hand, someone wants to acquire resources(s) for free, then he places the bid: NOTHING => resource(s).We can also adjust bid priorities (fees) in order to have the NOTHING bids to be picked up in a solution.Let n be the number of bids that contain NOTHING.We can let each NOTHING bid to have a fee of 1 and the other bids to have a fee of f b • (n + 1) where f b is the original fee associated with each bid.In this way, we give more priority to the bids that trade non-empty set of resources.
Finally, we would like to remark that some economists may object to bartering saying that it is not an efficient market mechanism.However, if bartering is studied from a computer science perspective and efficient algorithms and software are designed for it, then we believe that a serious barter economy will develop and compete with monetary economy.

Fig. 1 .
Fig. 1.Network showing bartering bids (a) and the transformed network with split nodes (b).The arcs in (b) are labelled (capacity,cost,flow) values.

Fig. 2 .
Fig. 2.An example showing bartering bids (a) and its AND/OR graph representation (b).
The owner of resource a is able to get the resources b and c for free without giving away his resource.-Some of the bids and resources cannot appear in a feasible solution: These are resources β, x, w and bids b 18 , b 19 , b 20 .It is clear that the resource β cannot appear in a solution, since it does not appear in the tail set of any bid.If we remove β, then the head set of bid b 20 cannot be satisfied.Hence bid b 20 cannot be satisfied and must be removed.This removal may propagate.Bids b 18 and b 19 and resources w and x are removed because of propagation.

Fig. 3 .Fig. 4 .
Fig. 3.An example showing bartering bids and the two bc-components present in the directed hypergraph.

Fig. 5 .
Fig. 5. Procedure for the removal of unsatisfiable bids and resources.
A directed hypergraph D(R, B) is constructed from the graph G(V, E) by letting R = V ∪ E and B = {<{v}, adjedges(v)> : v ∈ V } ∪ {<adjedges(v), {v}> : v ∈ V }.Clearly this construction takes polynomial time.We illustrate this construction by the example graph given in Fig.7.

Fig. 7 .
Fig. 7. Transformation of independent set problem on graph G(V, E) to the bartering problem D(R, B).
for the set of barterers and u ∈ U denote a single barterer.-B (u) stand for the set of bids made by barterer u. -S (u) r stand for the number of instances of resource r owned (supplied) by barterer u. f (u) b stand for the fee associated with bid b of the barterer u. -T (u) and H (u) stand respectively for the |R| × |B (u) | tail and head matrices for the user u.Note that T r,b ) denote the number of instances of resource r that is given away (requested) in bid b of barterer u. x (u) b stand for the binary variable associated with bid b of the user u.
b∈B (u ) T (u ) r,b • x (u ) b ) u ∈ U, r ∈ R s.t.S(u)   In the summation over u in constraint(16), we implicitly assume that y (u) r = 0 for the S (u) r = 0 cases.The bold arcs in Fig. 8(a) and (b) give the solutions for inclusive and exclusive MIMR problems respectively.Notice that in the exclusive solution in Figure 8(b), barterer u 3 has to give only c(2) and that he can keep d(1).

Table 2
Solution times (in seconds) for the various tests given in Table1