19 #define POS(R,C,NC) ((R)*(NC)+(C))
22 static char*
errors[]={
"ERROR! Function \'setCoefHead\' -> \'malloc\'.\n"
23 ,
"ERROR! Function \'setCoefHead\' -> \'listInsertLst\'.\n"
24 ,
"ERROR! Function \'setCoefHead\' -> \'arrayInsert\'.\n"
25 ,
"ERROR! Function \'setCoefHead\' -> \'newExp\'.\n"
26 ,
"ERROR! Function \'setCoefHead\' -> \'hashInsert\'.\n"
27 ,
"ERROR! Function \'setCoefTail\' -> \'malloc\'.\n"
28 ,
"ERROR! Function \'setCoefTail\' -> \'hashInsert\' or"
30 ,
"ERROR! Function \'setCoefTail\' -> \'arrayInsert\'.\n"
39 res=malloc(
sizeof(
SExp));
57 res=malloc(
sizeof(
SProb));
75 for(i=0,res=0;varid[i];i++)
85 int* vpos,pos,erro,res;
92 if(
hashGet(prob->
pos,(
void*)varid,(
void**)&vpos))
94 vpos=malloc(
sizeof(
int));
113 exp=
newExp((varc+1>10)?(varc+1):10);
127 tmp=malloc(
sizeof(
double));
149 int* vpos,pos,res,error;
156 if(
hashGet(prob->
pos,(
void*)varid,(
void**)&vpos))
158 vpos=malloc(
sizeof(
int));
179 tmp=malloc(
sizeof(
double));
192 fprintf(stderr,
"\n%d\n\n",error);
Prob newProb()
Creates a problem.
int hashInsert(HashMap hmap, void *key, void *value, int replace)
Associates a value to a key in a hash table.
Array newArray(int size)
Creates an empty array, with the specified initial capacity.
Array coefs
Coefficients of the variables.
int setOpRHS(Prob prob, int op, double rhs)
Adds the relational operator and the right-hand side to a condition.
int op
Operator of the expression.
int listInsertLst(List list, void *value)
Inserts an element at the end of a list.
int hashGet(HashMap hmap, void *key, void **value)
Provides the mapping for a key from a hash table.
int addCoefTail(Prob prob, const char *varid, int varc, double coef)
Adds the coefficient of a variable.
int varhash(const char *varid)
Hash function for variables names.
HashMap pos
Variables and their indexes.
List exps
List of expressions (objective function, and conditions).
static char * errors[]
Error messages.
Definitions of data types and functions required to read and store the data about the problem...
HashMap newHash(int size, float factor, int(*hash)(void *), int(*equals)(void *, void *))
Creates a hash table.
int addCoefHead(Prob prob, const char *varid, int varc, double coef)
Adds a new condition to the problem, and adds the coefficients of a variable.
Array invpos
Variables on each index.
Exp newExp(int size)
Creates an expression.
double rhs
Right-hand side of the expression.
int listLst(List list, void **value)
Provides the value at the last position of a list.
List newList(void)
Creates a list.
int arrayInsert(Array array, int index, void *elem, int replace)
Inserts an new element at the specified position of an array.