4
$\begingroup$

I downloaded the package TuGames from http://library.wolfram.com/infocenter/MathSource/5709/ to calculate Shapley Values in cooperative bargaining games.

I got it to work earlier today but after closing and opening mathematica again, this simple code would not work. When it worked, all I did was paste the content of the package in C:\Program Files\Wolfram Research\Mathematica\11.0\AddOns\Packages\TuGames\, and I manage to run the code below. However, it doesn't run anymore. Any thoughts on what could be causing the problem?

Needs["coop`CooperativeGames`"]
Needs["TuGames`"]

ExpGame := (T = {1, 2, 3, 4}; Clear[v];
  v[{}] = 0;
  v[{1}] = 0;
  v[{2}] = 0;
  v[{3}] = 0;
  v[{4}] = 0;
  v[{1, 2}] = 0;
  v[{1, 3}] = 1/4;
  v[{1, 4}] = 2/4;
  v[{2, 3}] = 1/4;
  v[{2, 4}] = 3/4;
  v[{3, 4}] = 0;
  v[{1, 2, 3}] = 1;
  v[{1, 2, 4}] = 1;
  v[{1, 3, 4}] = 1;
  v[{2, 3, 4}] = 1; v[T] = 2)
ShapleyValue[ExpGame]

This is the error I'd get sometimes. Other times it just crashes.

In[30]:= Needs["coop`CooperativeGames`"]
Needs["TuGames`"]
During evaluation of In[30]:= Get::noopen: Cannot open coop`CooperativeGames`.
During evaluation of In[30]:= Needs::nocont: Context coop`CooperativeGames` was not created when Needs was evaluated.
Out[30]= $Failed

Happy to provide more context if necessary. Thanks!

$\endgroup$
4
  • 1
    $\begingroup$ Is the file "CooperativeGames.m" located in the folder "coop"? The failure indicates that Mathematica could not generate the context coopCooperativeGames. What does say FindFile["coopCooperativeGames"] or FindFile["CooperativeGames`"]? $\endgroup$ Commented Apr 10, 2019 at 15:41
  • $\begingroup$ If I understand you correctly, you have pasted the package contents into a notebook. However, you must add the package path to the Mathematica search path in order to be able to run the package. For instance, set \$TuGamesPath = \$BaseDirectory<>"\\11.0\\AddOns\\Packages\\TuGames" and then set finally AppendTo[\$Path, \$TuGamesPath]. To check that the new path is added to the search path execute \$Path in a notebook. $\endgroup$ Commented Apr 10, 2019 at 16:15
  • 1
    $\begingroup$ @HolgerI.Meinhardt Do you have a link to a version of cddlib which includes cddmathlink? Unfortunately, the latest version does not seem to have the MathLink code. $\endgroup$
    – Szabolcs
    Commented Apr 10, 2019 at 21:26
  • $\begingroup$ @Szabolcs that right. I just copied the MathLink code of version cddlib-094g (I guess it is the last version that ships the MathLink code) into the directory tree of the latest version cddlib-0.94-j. Adjusted the Makefile for Mathematica Version 11.3 under Linux and compiled it. I have binaries for RHEL 7.5, if you want, I can open a link for downloading. $\endgroup$ Commented Apr 11, 2019 at 7:43

1 Answer 1

6
$\begingroup$

In order to avoid in the future any annoying error message that has been mentioned above while following a manual installation that does not respect best practice of publicizing a Mathematica package, in particular on Windows systems, see for instance the post at

Mathematica Community

we decided to completely overhaul the package structure. Since version 2.5.1, the package is distributed as a Paclet that allows a custom installation for everyone. The installation of the package requires about 90 MB free hard-disk space, and the Mathematica version should not be smaller than 10. For Mathematica versions smaller than Version 10, a manual installation is requested. In that case one has to respect the guidelines related to the associated operating system that can be found from the Mathematica documentation.

Moreover, in order to react more quickly to the needs of the community, we changed the host from Wolfram Library Archive to GitHub. The most recent version 2.5.4 can now be downloaded from the following URL

Project Host

as an ordinary Zip file or as a Mathematica Paclet that can be found at

URL Paclet: TuGames

We strongly recommend to rely on a custom installation. Such a installation can be easily accomplished while applying the subsequent steps:

Start Mathematica, open a notebook, and execute therein

PacletInstall["/full/Path/to/TUG-2.5.4.paclet"]

that should return the value

Paclet[TUG, 2.5.4, <>]

to indicate a successful installation. Notice that

"/full/Path/to/TUG-2.5.4.paclet"

indicates the directory where the TUG-2.5.4.paclet is located at your hard-disk.

After these steps, the installation procedure is completed, and one can start a session while executing

In[1]:= Needs["TUG`"]

This will load all necessary auxiliary packages to run the program. Define then the above game by

In[2]:= ExpGame := (T = {1, 2, 3, 4}; Clear[v]; v[{}] = 0; v[{1}] = 0; v[{2}] = 0; v[{3}] = 0; v[{4}] = 0; v[{1, 2}] = 0; v[{1, 3}] = 1/4; v[{1, 4}] = 2/4; v[{2, 3}] = 1/4; v[{2, 4}] = 3/4; v[{3, 4}] = 0; v[{1, 2, 3}] = 1; v[{1, 2, 4}] = 1; v[{1, 3, 4}] = 1; v[{2, 3, 4}] = 1; v[T] = 2);

and then one can apply some basic operations like computing the Shapley value

In[3]:= ShapleyValue[ExpGame]
Out[3]= {23/48, 25/48, 7/16, 9/16}

the pre-nucleolus

In[4]:= PreNucleolus[ExpGame]
Out[4]= {5/12, 7/12, 5/12, 7/12}

or the modiclus

In[5]:= Modiclus[ExpGame]
Out[5]= {1/2, 1/2, 3/8, 5/8}

just to mention some interesting game solutions that can be computed with the help of this package.

Furthermore, we have added some Cddmathlink executables for RHEL 7.5 and MacOSX to use the graphical features of the package, which makes it not anymore necessary to install them by the user. Then it is possible to plot the core of the above game without further adjustments while executing

PlotCore3dV6[ExpGame]

Core of the Game

However, in case that these executables are not binary compatible with your OS, this C-library must be compiled by yourself. Windows users should compile it with the help of Cygwin. Unfortunately, we are not experienced enough to provide any support for Windows OS.

Finally, we have revised and extended the documentation to access about 230 pages via the Mathematica Documentation Center. These pages can be accessed while entering into the panel of the Documentation Center just TUG or guide/InstalledAddOns, or scroll down, and click at the end of the page at the right corner on the field "Add-ons and Packages".

Updated Information for Installing the Package TuGames: 17.05.2020

For getting the Paclet of the Mathematica Package TuGames 2.6.1, we recommend a direct installation from GitHub under Mathematica V11.3 or later while executing in a notebook the command

ResourceFunction["GitHubInstall"]["himeinhardt", "TuGames"]

otherwise one needs to follow one of the alternative custom installation procedure given at the project home at GitHub mentioned above.

$\endgroup$
1
  • 2
    $\begingroup$ Nice to see people using paclets! They’re the way Mathematica code should be distributed. $\endgroup$
    – b3m2a1
    Commented Jun 11, 2019 at 7:11

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.