-
Notifications
You must be signed in to change notification settings - Fork 1
/
equilibrium.h
107 lines (95 loc) · 3.02 KB
/
equilibrium.h
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
/**
* \file equilibrium.h
*
* Storing tableaus representing equilibrium, and computing the equilibrium.
* This structure is mainly used by the list (list.h) to store the bi-partite
* graph of equilibria found. The tableau information of the equilibrium is
* stored, because the equilibrium can be computed from it, and if we want to
* restart from a given equilibrium, the tableau can simply be copied from this
* structure into the variables used for pivoting, initialised and the Lemke's
* algorithm runs to compute a new equilibrium.
*
* Author: Tobenna Peter, Igwe [email protected] August, 2012
*/
/* Include rat.h before this file */
#ifndef EQUILIBRIUM_H
#define EQUILIBRIUM_H
#include <stdlib.h>
#include <stdio.h>
#include <string.h>
#include "alloc.h"
#include "col.h"
#include "rat.h"
#ifdef GLEMKE
#include "gmp.h"
#include "gmpwrap.h"
#else
#include "mp.h"
#endif
/**
* An equilibrium structure which represents a computed
* equilibrium. This stores the tableau representing an
* equilibrium, in such a way that it can be easily copied
* and initialised for the Lemke's algorithm.
*/
typedef struct equilibrium
{
#ifndef GLEMKE
mp** A; /**< The tableau matrix */
mp *scfa; /**< The scale factors for the TABCOLs */
mp det; /**< The determinant of the tableau */
#else
gmpt** A; /**< The tableau matrix */
gmpt* scfa; /**< The scale factors for the TABCOLs */
gmpt det; /**< The determinant of the tableau */
#endif
int* bascobas; /**< VARS -> ROWCOL */
int* whichvar; /**< ROWCOL -> VARS, inverse of bascobas */
int lcpdim; /**< Dimensions of the LCP */
int nrows;
int ncols;
}Equilibrium;
#ifndef GLEMKE
/**
* Creates an equilibrium structure given the information of the tableau.
*/
Equilibrium createEquilibrium(mp** A, mp* scfa, mp det, int* bascobas, int* whichvar, int dim, int nrows, int ncols);
#else
/**
* Creates an equilibrium structure given the information of the tableau.
*/
Equilibrium createEquilibrium(gmpt** A, gmpt* scfa, gmpt det, int* bascobas, int* whichvar, int dim, int nrows, int ncols);
#endif
/**
* Frees the memory allocated to the various members
* of the given equilibrium.
*
* \param eq Equilibrium to be released from memory.
* \sa createEquilibrium
*/
void freeEquilibrium(Equilibrium eq);
void colprEquilibrium(Equilibrium eq);
/**
* Prints the specifie equilibrium.
*
* \param eq Equilibrium to be printed to the standard output.
*/
void printEquilibrium(Equilibrium eq);
/**
* Returns the strategy represented by the given equilibrium. The array
* of rational numbers which are returned consist of player 1's
* strategies, followed by player 2's strategies.
*
* \param eq The tableau representation
* \returns An array of rational numbers representing the equilibrium
*/
Rat* getStrategies(Equilibrium eq);
/**
* Returns an integer value representing TRUE or FALSE if both
* e1 and e2 are equal or not.
*
* \returns 1 if e1 and e2 are equal and 0 if e1 and e2 are not
* equal.
*/
int equilibriumisEqual(Equilibrium e1, Equilibrium e2);
#endif