MatchingMarkets.py icon indicating copy to clipboard operation
MatchingMarkets.py copied to clipboard

Explain installation of package, dependencies

Open nealmcb opened this issue 4 years ago • 5 comments

Some more hints in the README on how to pull in the dependencies and run this would be helpful.

So far this worked for me to avoid import errors:

pip install scipy networkx PyQt5

Then, since I don't see a pyproject.toml or setup.py, I just tried to run python from the root directory of the project, as cloned via git.

But I'm guessing that I'm getting different versions than you are, since I get these errors:

Python 3.8.0 (default, Oct 28 2019, 16:14:01)
[GCC 8.3.0] on linux
Type "help", "copyright", "credits" or "license" for more information.
>>> import matchingmarkets as mm
>>> import numpy.random as rng
>>> newsim = mm.simulation(time_per_run=100, max_agents=5000, arrival_rate=15,typeGenerator=rng.randint, 
   compatFct=mm.stochastic_neighborSameType,crit_input=3, numTypes=5)
>>> newsim.graph(plot_time=0.8)
Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/srv/s/games/MatchingMarkets.py/matchingmarkets/simulations.py", line 254, in graph
    newMarket.update(metaAlgorithm=self.metaAlgorithm,
  File "/srv/s/games/MatchingMarkets.py/matchingmarkets/market.py", line 393, in update
    nx.draw_networkx_edges(self.Graph, self.graph_pos,
TypeError: draw_networkx_edges() got an unexpected keyword argument 'font_size'
>>>

It looks like I have networkx version 2.5.

nealmcb avatar Feb 12 '21 02:02 nealmcb

Note also that I ran the tests as described at https://github.com/QuantEcon/MatchingMarkets.py/tree/master/tests and they all worked up to Plotting Tests, where I got the same error I noted above.

...
Non-Stochastic brute search
Optimization terminated successfully.
         Current function value: -1036.000000
         Iterations: 49
         Function evaluations: 133
Results:  [1.02182617]

Plotting Tests

---PLEASE VERIFY THAT GRAPHS ARE RENDERED ON YOUR SCREEN---

+++++++
Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
Traceback (most recent call last):
  File "<stdin>", line 1, in <module>
  File "/srv/s/games/MatchingMarkets.py/matchingmarkets/tests.py", line 154, in FullTest
    market.update(discount=rng.random_sample,
  File "/srv/s/games/MatchingMarkets.py/matchingmarkets/market.py", line 393, in update
    nx.draw_networkx_edges(self.Graph, self.graph_pos,
TypeError: draw_networkx_edges() got an unexpected keyword argument 'labels'

nealmcb avatar Feb 13 '21 19:02 nealmcb

My PR #8 seems to resolve the API issue.

Now I'm seeing this PULP_CBC_CMD test failure:

...
Plotting Tests complete                                                                                                     
============================                                              
Pulp Test                                                                    
         Testing zero subtraction                                        
         Testing inconsistant lp solution                                 
Test failed: var x == 0.0 != 4                                         
Tests failed for solver <matchingmarkets.algorithms.pulp.solvers.PULP_CBC_CMD object at 0x7efc65d16f40>
* Solver <class 'matchingmarkets.algorithms.pulp.solvers.PULP_CBC_CMD'> failed.

Note also that several messages that seem like warnings, simply because I didn't install all the solvers, also come out, e.g.:

Solver <class 'matchingmarkets.algorithms.pulp.solvers.CPLEX_DLL'> unavailable

nealmcb avatar Feb 13 '21 20:02 nealmcb

Hi,

Sorry about taking so much time to respond. I haven't worked on this project in a while.

I added a setup.py you should be able to run normally. If it sees more use, I can add it to pip without too much trouble.

Try it and running python -m unittest discover test to run the unit test suite and it should work. If it doesn't I'll investigate, thanks.

VHRanger avatar Feb 16 '21 23:02 VHRanger

Excellent - thank you!

The updates fixed the error I encountered in testing, and all the tests now pass.

I note that I got what seemed like a more complete test by running FullTest(), which may be worth mentioning some more in the documentation. The FullTest did surface a warning or two, which may or may not be worth some attention.

[run FullTest manually]
...
Non-Stochastic brute search
Warning: Maximum number of function evaluations has been exceeded.
Warning: Either final optimization did not succeed or `finish` does not return `statuscode` as its last argument.
Results:  [6.76774276]

...

Attribute Qt::AA_EnableHighDpiScaling must be set before QCoreApplication is created.
/srv/s/games/MatchingMarkets.py/matchingmarkets/market.py:332: RuntimeWarning: divide by zero encountered in double_scalars
  k=(1/(0.9*np.sqrt(len(
iteration done

(That divide by zero line RuntimeWarning was copied in from a run before my full install, so it may be spurious.)

Thanks again!

nealmcb avatar Feb 17 '21 02:02 nealmcb

Yeah that warning is because it would be too long to set up a brute force search that converges in the test suite

VHRanger avatar Feb 17 '21 16:02 VHRanger