<SYSTEM_TASK:>
Given the following text description, write Python code to implement the functionality described below step by step
<END_TASK>
<USER_TASK:>
Description:
 Matching Market
This simple model consists of a buyer, a supplier, and a market. 
The buyer represents a group of customers whose willingness to pay for a single unit of the good is captured by a vector of prices wta. You can initiate the buyer with a set_quantity function which randomly assigns the willingness to pay according to your specifications. You may ask for these willingness to pay quantities with a get_bid function. 
The supplier is similiar, but instead the supplier is willing to be paid to sell a unit of technology. The supplier for instance may have non-zero variable costs that make them unwilling to produce the good unless they receive a specified price. Similarly the supplier has a  get_ask function which returns a list of desired prices. 
The willingness to pay or sell are set randomly using uniform random distributions. The resultant lists of bids are effectively a demand curve. Likewise the list of asks is effectively a supply curve. A more complex determination of bids and asks is possible, for instance using time of year to vary the quantities being demanded. 
Microeconomic Foundations
The market assumes the presence of an auctioneer which will create a book, which seeks to match the bids and the asks as much as possible. If the auctioneer is neutral, then it is incentive compatible for the buyer and the supplier to truthfully announce their bids and asks. The auctioneer will find a single price which clears as much of the market as possible. Clearing the market means that as many willing swaps happens as possible. You may ask the market object at what price the market clears with the get_clearing_price function. You may also ask the market how many units were exchanged with the get_units_cleared function.
Agent-Based Objects
The following section presents three objects which can be used to make an agent-based model of an efficient, two-sided market.
Step1:  Example Market
In the following code example we use the buyer and supplier objects to create a market. At the market a single price is announced which causes as many units of goods to be swapped as possible. The buyers and sellers stop trading when it is no longer in their own interest to continue.
<ASSISTANT_TASK:>
Python Code:
import random as rnd
class Supplier():
    def __init__(self):
        self.wta = []
    
    # the supplier has n quantities that they can sell
    # they may be willing to sell this quantity anywhere from a lower price of l
    # to a higher price of u
    def set_quantity(self,n,l,u):
        for i in range(n):
            p = rnd.uniform(l,u)
            self.wta.append(p)
    
    # return the dictionary of willingness to ask
    def get_ask(self):
        return self.wta
class Buyer():
    
    def __init__(self):
        self.wtp = []
    
    # the supplier has n quantities that they can buy
    # they may be willing to sell this quantity anywhere from a lower price of l
    # to a higher price of u
    def set_quantity(self,n,l,u):
        for i in range(n):
            p = rnd.uniform(l,u)
            self.wtp.append(p)
    
    # return list of willingness to pay
    def get_bid(self):
        return self.wtp
class Market():
    count = 0
    last_price = ''
    b = []
    s = []
    
    def __init__(self,b,s):
        # buyer list sorted in descending order
        self.b = sorted(b, reverse=True)
        # seller list sorted in ascending order
        self.s = sorted(s, reverse=False)
    
    # return the price at which the market clears
    # assume equal numbers of sincere buyers and sellers
    def get_clearing_price(self):
        # buyer makes a bid, starting with the buyer which wants it most
        for i in range(len(self.b)):
            if (self.b[i] > self.s[i]):
                self.count +=1
                self.last_price = self.b[i]
                
        return self.last_price
    
    def get_units_cleared(self):
        return self.count
        
        
        
Explanation: Matching Market
This simple model consists of a buyer, a supplier, and a market. 
The buyer represents a group of customers whose willingness to pay for a single unit of the good is captured by a vector of prices wta. You can initiate the buyer with a set_quantity function which randomly assigns the willingness to pay according to your specifications. You may ask for these willingness to pay quantities with a get_bid function. 
The supplier is similiar, but instead the supplier is willing to be paid to sell a unit of technology. The supplier for instance may have non-zero variable costs that make them unwilling to produce the good unless they receive a specified price. Similarly the supplier has a  get_ask function which returns a list of desired prices. 
The willingness to pay or sell are set randomly using uniform random distributions. The resultant lists of bids are effectively a demand curve. Likewise the list of asks is effectively a supply curve. A more complex determination of bids and asks is possible, for instance using time of year to vary the quantities being demanded. 
Microeconomic Foundations
The market assumes the presence of an auctioneer which will create a book, which seeks to match the bids and the asks as much as possible. If the auctioneer is neutral, then it is incentive compatible for the buyer and the supplier to truthfully announce their bids and asks. The auctioneer will find a single price which clears as much of the market as possible. Clearing the market means that as many willing swaps happens as possible. You may ask the market object at what price the market clears with the get_clearing_price function. You may also ask the market how many units were exchanged with the get_units_cleared function.
Agent-Based Objects
The following section presents three objects which can be used to make an agent-based model of an efficient, two-sided market.
End of explanation
# make a supplier and get the asks
supplier = Supplier()
supplier.set_quantity(60,10,30)
ask = supplier.get_ask()
# make a buyer and get the bids (n,l,u)
buyer = Buyer()
buyer.set_quantity(60,10,30)
bid = buyer.get_bid()
# make a market where the buyers and suppliers can meet
# the bids and asks are a list of prices
market = Market(bid,ask)
price = market.get_clearing_price()
quantity = market.get_units_cleared()
# output the results of the market 
print("Goods cleared for a price of ",price)
print("Units sold are ", quantity)
Explanation: Example Market
In the following code example we use the buyer and supplier objects to create a market. At the market a single price is announced which causes as many units of goods to be swapped as possible. The buyers and sellers stop trading when it is no longer in their own interest to continue.
End of explanation
<END_TASK>