0 views

Uploaded by Shivam Agarwal

Simplex method

- 1 Matrix Inversion by Gauss Jordan Elimination
- MIT8_044S13_Final_s (1)
- Ejem_AC
- 1298670088216
- Supplementary Answers
- Computer EV 18Aug
- How to Solve INPUT OUTPUT - By Sonali Dixit - EdKraft.in
- AN_Analog Control Sytem
- Sec8.4
- sharjeel+nasir.docx
- Lab 14
- Teoria de colas
- Introduction 1of2
- Hiro Estimate 1
- Exam 2 F10 Sol
- FS lab index page.docx
- syla
- hw4
- Assignment Output
- Matlab Work 1

You are on page 1of 3

cpp Page 1 of 3

// Lab3 Question

#include <iostream>

#include <iomanip>

#include <vector>

{

int index=0;

for (int i=1; i<length; i++)

{

if (lastrow[i]<lastrow[index])

index=i;

}

if (lastrow[index]>=0)

return -1;

else

return index;

}

{

int index=0;

for (int i=1; i<length; i++)

{

if (temp[i]<temp[index])

index=i;

}

return index;

}

{

int i, j;

cout<<"----------------"<<endl;

for (i=0; i<m; i++){

for (j=0; j<(n); j++)

cout<<setw(10)<<setprecision(5)<<A[i][j];

cout<<endl;

}

// cout<<"----------------"<<endl;

}

{

float lastrow[n+1], *temp;

int i, j, pivot_col=0, pivot_row;

bool stop=true;

{

if (activeA[m][i]<0)

stop=false;

if (stop==true){

cout<<endl<<"Optimal Solution is "<<activeA[m][n]<<endl;

float *sol_;

sol_ = new float [m];

for (i=0; i<m; i++)

{

if (index[i]>=0)

sol_[index[i]]=activeA[i][n];

}

for (i=0; i<m; i++)

{

cout<<"x"<<i+1<<" is "<<sol_[i]<<endl;

}

return;

File: /home/jarvis/Documents/shivam207/or_lab/Lab3/simplex.cpp Page 2 of 3

pivot_col=min_index(activeA[m], n+1);

for (i=0; i<m; i++)

{

if (activeA[i][pivot_col]>0)

temp[i]=activeA[i][n]/activeA[i][pivot_col];

else

temp[i]=1000000;

}

pivot_row=min_col_index(temp, m);

cout<<pivot_row<<" "<<pivot_col<<endl;

index[pivot_row]=pivot_col;

float pivot=activeA[pivot_row][pivot_col];

for (i=0; i<=m; i++)

{

for(j=0; j<=n; j++)

{

if (i!= pivot_row && j!= pivot_col)

{

activeA[i][j]=(activeA[i][j]*activeA[pivot_row][pivot_col]-activeA

[pivot_row][j]*activeA[i][pivot_col])/activeA[pivot_row][pivot_col];

}

}

}

activeA[pivot_row][i]=activeA[pivot_row][i]/pivot;

activeA[i][pivot_col]=-activeA[i][pivot_col]/pivot;

activeA[pivot_row][pivot_col]=1/pivot;

simplex(activeA, n, m, index);

int main()

{

int n, m, i, j, *sol_index;

float **A, *b, **activeA, *z;

cin>>m;

cin>>n;

activeA = new float* [m+1];

A[i]= new float [n];

activeA[i]= new float [n+1];

}

activeA[m]= new float [n+1];

for (i=0; i<m; i++){

for (j=0; j<n; j++){

cin>>A[i][j];

File: /home/jarvis/Documents/shivam207/or_lab/Lab3/simplex.cpp Page 3 of 3

activeA[i][j]=A[i][j];

}

}

b=new float [m];

for (i=0; i<m; i++){

cin>>b[i];

activeA[i][n]=b[i];

}

z=new float [n];

for (i=0; i<n; i++){

cin>>z[i];

activeA[m][i]=-z[i];

}

sol_index = new int[m];

sol_index[i]=-1;

simplex(activeA, n, m, sol_index);

return 0;

- 1 Matrix Inversion by Gauss Jordan EliminationUploaded bySphinx Rainx
- MIT8_044S13_Final_s (1)Uploaded by*83*22*
- Ejem_ACUploaded byaferminperez7869
- 1298670088216Uploaded byMarcos Benitz Junior
- Supplementary AnswersUploaded byGearTy
- Computer EV 18AugUploaded byVijesh
- How to Solve INPUT OUTPUT - By Sonali Dixit - EdKraft.inUploaded bycharu tyagi
- AN_Analog Control SytemUploaded byJyoti Shekhar
- Sec8.4Uploaded byTheGreatPostulio
- sharjeel+nasir.docxUploaded bynaseeruddin800yahooc
- Lab 14Uploaded bySandeep V Gowda
- Teoria de colasUploaded byabel aramis machado rodriguez
- Introduction 1of2Uploaded byAnkit Sharma
- Hiro Estimate 1Uploaded byHiro Yumbato Castro
- Exam 2 F10 SolUploaded byChulka
- FS lab index page.docxUploaded byTejas
- sylaUploaded byRobert Robinson
- hw4Uploaded byRavi Sharma
- Assignment OutputUploaded byNiti Arora
- Matlab Work 1Uploaded byIshan Jasyal
- Areas Between CurvesUploaded byDavidroy Munim
- PHYS 170 Midterm 2007Uploaded byykfung
- Math 3 test 2Uploaded byMarinelle Gay Faelmoca Sacoco
- Modified Wilson Plot - algorithmUploaded byAli Hashmi
- Week4 HomeaworkUploaded byAbdallaIsmail
- 1_1fundamentalUploaded byDilruk Gallage
- A Breif Introduction to the Fractional Fourier TransformUploaded byIan Hoover
- Problem Set 16 SolutionsUploaded byzninoromeo
- Inexact DifferentialUploaded byjacobian18
- ChE212 Implicit Eqn Soln and OptimizationUploaded byJohann Zabaleta

- out.pdfUploaded byShivam Agarwal
- Assignment 3 Lab (1).pdfUploaded byShivam Agarwal
- niculescu09.pdfUploaded byShivam Agarwal
- Theory of ComputationUploaded byVikas Maurya
- Linear Programming.pptUploaded byShivam Agarwal
- Cell Division, Cell Cycle & ApoptosisUploaded byShivam Agarwal
- A First Course in Discrete Mathematics 2nd Ed - ANdersonnUploaded byspock126
- AgriUploaded bypawann1997
- EVS20001_Solid Waste ManagementUploaded byShivam Agarwal
- EVS20001 Wastewater TreatmentUploaded byShivam Agarwal
- Water Pollution and ControlUploaded byShivam Agarwal
- ppUploaded byPREMENDRA SAMEER
- EV20001_Lecture Slides Set-1_Brajesh K DubeyUploaded byShivam Agarwal
- Waste Water 101Uploaded byShivam Agarwal
- Binary HeapsUploaded byShivam Agarwal
- Arkanath CvUploaded byShivam Agarwal

- Nintendo switch operating manual.pdfUploaded bybobisa
- Sas Programming 1 Essentials SummaryUploaded byMilánBerzsenyi
- Wang - 2016 - A Comparative Study of Cybercrime in Criminal Law China, US, England, Singapore and the Council of EuropeUploaded byJacobo Cordoba
- Mitsubishi PLC Communication Cable mac 50.pdfUploaded byRăzvan Dinu
- KiranUploaded byPratap Eluru
- 01 OverviewUploaded byŞemsettin karakuş
- airlive_IP_1000RUploaded byarim11
- Hierarchical Neural Network Algorithm for Classification of Normal Daily Activity Using Wearable SensorsUploaded byTan Quoc Huynh
- 3Giannetti_ArsTelematicaINGLUploaded byFuturifico
- Taking Control of the MLR Review ProcessUploaded byCognizant
- Scrum QuestionsUploaded bythecynic
- 2013 Samsung TV Firmware Upgrade InstructionUploaded bybob_mirk
- Sap Scm 7.01 Scm_sd _mm_ Me _pp_wm Ehp5 Col95 Latest CoursesUploaded byERPExams Com
- Systems Analysis and Design Chapter 1Uploaded byLibby Duke
- NumericalUploaded byRachit Madan
- C Programming III - Karl W BromanUploaded byPablo Flores Jara
- A-to-Z-of-C.pdfUploaded byPablo Rius
- 1756-pm016_-en-pUploaded bysaswata_tutu
- Error Rangecheck Offendingcommand DopdfUploaded byNatasha
- Week 1Uploaded byNanie Dwazni
- Unity3d Certified Developer Exam Objectives and Prep TopicsUploaded byuyaiekanem
- Atoll 2.7.1 Umts Hspa BasicUploaded bytrmarat61
- Microsoft Code NamesUploaded bybcdalai
- eu-17-Liberman-Lost-In-Transaction-Process-Doppelganging.pdfUploaded bykougaR8
- Process of Educational Planning in Pakistan by Dr M H Shah AIOU IslamabadUploaded byDr Syed Manzoor H Shah
- bitszg553_mid1Uploaded byShivam Shukla
- Binary TreeUploaded bypram92
- Oracle on VMware Licensing 201506 ModUploaded byaksmsaid
- sms (1)Uploaded byFauzan Akbar
- 16th and 17th June 2018Uploaded byrajragavan