Academic Integrity: tutoring, explanations, and feedback — we don’t complete graded work or submit on a student’s behalf.

I need to write a program to perform the simplex method. Suppose a problem has 4

ID: 3654290 • Letter: I

Question

I need to write a program to perform the simplex method. Suppose a problem has 4 variables and two inequalities as constraints. Design the program according to the following steps: Using these steps: 1. Prompt user to input 4 real numbers as the coefficients for the objective function 2. Prompt user the input 5 real numbers as the coefficients for the first unequalities ( fifth number is b1 ) 3. Prompt user to input 5 real numbers as the coefficients for the second inequalities ( fifth number is b2 ) 4. The program needs to perform simplex algorith and ouput the solutions.... This is really stumping me.... I didn't take C++ for 3 years , please make this as simple as possible nothing fancy.

Explanation / Answer

#include #include #define INFINITY 999 #define N 3 #define M 6 void minimum(float *arr,int *arrminpos,int n); /* Calculates the minimum valued position among the array arr having n elements. */ void display (float c[],float b[],float a[][M],int basic[]); /* Display the table */ void displayframe(float c[M]); /* Displays the frame of the table */ void calctemp(float *,float [][M],float [],int []); /* Calculates Zj-Cj */ /*--------------------------------------------------------------------------* Cj 5 4 3 0 0 0 miniRatio cB xB b a1 a2 a3 a4 a5 a6 bi/aij 0 x4 5 2 3 1 1 0 0 2.5 0 x5 11 4 1 2 0 1 0 2.75 0 x6 8 3 4 2 0 0 1 2.66 ---------------------------------------------------------------------------- Zj-Cj -5 -4 -3 0 0 0 ---------------------------------------------------------------------------- 5 x1 2.5 1 1.5 0.5 0.5 0 0 5 0 x5 1 0 -5 0 -2 1 0 infinity 0 x6 105 0 -0.5 0.5 -1.5 0 1 1 ---------------------------------------------------------------------------- Zj-Cj 0 3.5 -0.5 2.5 0 0 ---------------------------------------------------------------------------- 5 x1 2 1 2 0 2 0 -1 0 x5 1 0 -5 0 -2 1 0 3 x3 1 0 -1 1 -3 0 2 ---------------------------------------------------------------------------- Zj-Cj 0 3 0 1 0 1 ---------------------------------------------------------------------------- So the solution is :- x1=2 x2=0 x3=1 x4=0 x5=1 x6=0 max(z) = 5*2 + 4*0 + 3*1 = 13. *--------------------------------------------------------------------------*/ void main() { float c[M]={{5},{4},{3},{0},{0},{0}}; /* Stores co-efficient of the objective function Max(z) */ float a[N][M]={ {2,3,1,1,0,0}, {4,1,2,0,1,0}, {3,4,2,0,0,1} }; /* Stores the co-efficent of the constraints */ float b[N]={{5},{11},{8}}; /* Stores the values on RHS of constraints */ float temp[M]={{0},{0},{0},{0},{0},{0}}; /* Stores the values of Zj-Cj*/ int tempminpos; /* Stores the minimum valued position of {Zj-Cj} i.e. coming in variable */ float miniratio[N]; /* Stores the value of the ratio b[i]/a[i][j] */ int miniratiominpos; /* Stores the minimum valued position of b[i]/a[i][j] i.e. going out variable */ float key; /* Stores the key element */ int gooutcol; /* Stores the column number which goes out */ float z; /* Stores the value of the objective function */ float x[M]; /* Stores the value of the variables */ int i,j; /* Loop variables */ int basic[N]; /* Stores the basic variable */ int nonbasic[N]; /* Stores the non-basic variable */ int flag=0; /* Terminating variable */ //clrscr(); /*** Initializing basic variables to 3,4,5 i.e. x4,x5,x6 ***/ for(i=0;i