--------------- # Aufgabe 1 # --------------- require(linprog) calctimes0 = rep(0,100) calctimes1 = rep(0,100) phaseI_iter0 = rep(0,100) phaseII_iter0 = rep(0,100) phaseI_iter1 = rep(0,100) phaseII_iter1 = rep(0,100) maxF0 = rep(0,100) maxF1 = rep(0,100) # total calculation times # with new R-Version 3.4.0: # about 20 sec fuer n = 20, m = 100 # about 32 sec fuer n = 25, m = 125 # about 55 sec fuer n = 30, m = 150 # about 2 min fuer n = 40, m = 200 # total calculation times # with older version of R: # about 65 sec fuer n = 20, m = 100 # about 90 sec fuer n = 25, m = 125 # about 3 min fuer n = 30, m = 150 # about 6 min fuer n = 40, m = 200 n = 30 m = 150 vec_c = rep(1,n) totalcalctime = Sys.time() for(i in 1:100) { a0 = runif( n*m ) A0 = matrix( a0 , ncol=n , nrow=m ) b0 = runif( m , min = n/2-sqrt(n) , max = n/2+sqrt(n) ) a1 = a0 - 0.5 A1 = matrix( a1 , ncol=n , nrow=m ) b1 = b0 - n/2 # rechte Seite positiv, only phase II: calctime = Sys.time() res0 = solveLP(vec_c,b0,A0,TRUE) calctimes0[i] = Sys.time() - calctime phaseI_iter0[i] = res0$iter1 # sollte Null sein phaseII_iter0[i] = res0$iter2 maxF0[i] = res0$opt # rechte Seite nicht immer positiv, phase I + II: calctime = Sys.time() res1 = solveLP(vec_c,b1,A1,TRUE) calctimes1[i] = Sys.time() - calctime phaseI_iter1[i] = res1$iter1 phaseII_iter1[i] = res1$iter2 maxF1[i] = res1$opt } totalcalctime = Sys.time() - totalcalctime totalcalctime # Rechenzeiten LOP0 und LOP1: m = max(calctimes0,calctimes1) plot(calctimes0,ylim=c(0,m),col="blue",xlab="das wievielte Zufallsexperiment", ylab="Rechenzeit",main="Rechenzeiten fuer LOP0 (blau) und LOP1 (rot)") points(calctimes1,col="red") # Phase-I und Phase-II Iterationen fuer LOP0 und LOP1: par(mfrow=c(1,2),byrow=TRUE) # two pictures in one plot-window plot(phaseI_iter0, ylim=c(0,100),col="blue",xlab="das wieviele Zufallsexperiment", ylab="Phase-I Iterationen",main="Phase-I Iterationen LOP0 (blau) und LOP1 (rot)") points(phaseI_iter1, ylim=c(0,100), col="red") plot(phaseII_iter0, ylim=c(0,100),col="blue",xlab="das wieviele Zufallsexperiment", ylab="Phase-II Iterationen",main="Phase-II Iterationen LOP0 (blau) und LOP1 (rot)") points(phaseII_iter1, ylim=c(0,100), col="red") # Rechenzeiten gegen Gesamtzahl Iterationen: plot(phaseI_iter0+phaseII_iter0,calctimes0,ylim=c(0,m),xlim=c(0,140), col="blue",xlab="phaseI + phaseII iterations",ylab="calc times", main="Rechenzeiten gegen Gesamtzahl Iterationen, \n LOP0 (blau) und LOP1 (rot)") points(phaseI_iter1+phaseII_iter1,calctimes1,col="red") # Wert des Maximums plot(maxF0,ylim=c(0,100),col="blue",xlab="das wievielte Zufallsexperiment", ylab="maxF", main="maxF, LOP0 (blau) und LOP1 (rot)") points(maxF1,col="red")