You are asked to write a function (prototype and explanations of which will be given below) and a main function
to test the function you wrote and demonstrate that your function works correctly for dierent inputs. You should
submit the c le containing the main function the and the function that you are asked to write.
Function
typedef struct lp{
int n; /* number of variables */
int m; /* number of constraints */
double* c; /* cost coefficients */
double* A; /* constraint coefficients matrix. stored in row major fashion */
double* b; /* constraint righthandside vector */
double* x; /* a solution */
} lp;
typedef struct simplex{
int* basic; /* vector includes indices of the basic variables */
int* nbasic;/* vector includes indices of the basic variables */
double* y; /* solution to system y^T B = c_B^T */
double* xB; /* solution to system Bx_B = b*/
double* B; /* matrix B */
double* cB; /* c_B vector */
double* cN; /* c_N vector */
double* cbarN; /* reduced cost vector */
double* N; /* matrix N */
double* Aj; /* vector Aj */
double* ratios; /* vector ratios */
int entering;
int exiting;
} simplex;
typedef struct la{
double* l;
double* u;
int* ind;
double* sol;
double* ws;
} la;
void allocateSpace ( lp* l , simplex* s , la* pla ) ;
A program needs to store various data during the execution. So in the beginning of the run, just after the amount
of space (size of the data) is determined, it reserves some part of the memory for itself. You are asked to write a
program to achieve this task. The size information is stored in a variable of type struct lp (details of which is given
above) in members m and n. Function has its address in its 1st argument l. The required number of elements that
is to be stored for each member of 3 variables of types lp, simplex and la respectively are given in the following
table. The function should allocate necessary amount of space for each member.
lp
member requirement
c n
A n*m
b m
x n
simplex
member requirement member requirement
B m*m xB m
N n*m y m
cB m Aj m
cN n ratios m
charN n basic m
nbasic n
la
member requirement
ind m
l m*(m+1)/2
u m*(m+1)/2
sol m
w*s m*m
Notes: Nothing will be asked to the user!
Input arguments
l: the pointer to the variable of type struct lp. It contains the members m and n which should be used to allocate
memory
s: the pointer to the variable of type struct simplex.
pla: the pointer to the variable of type struct la.
Return value
This function returns nothing.