/* Generador de programas DEA a resolver con lp_solve * Q: I did not read dea.c, I have no idea on using... * A: dea * where the data file contents is * * Ninputs Moutputs * col1in .. colNin col1out .. colMout * .. .. .. .. .. .. * etc etc etc etc etc etc * * Q: Ok, DEA... but what kind of DEA? * A: The simple one! I don't agree using parametric DEA, since DEA is * a great model for non-parametric estimation on efficiency, forgiving * human assumptions on DMU operations. * Ps: DEA = Data Envelopment Analysis, DMU = Decision Making Units * * Take x inputs, y outputs on n delegations, generate the set of programs * Max SUM wy' for each delegation'(1..n) * s.t. SUM vx - SUM wy >= 0 for each n * SUM vx' = 1 * all v,w >= 0 * Easy questions: gamo@telecable.es */ #include #define DATA 1000 #define VARS 50 FILE *fin,*fout,*fsh; unsigned int numein,numeout,nume,x,y,n,siz; float m[DATA+3][VARS+1]; char nombre[8]; int main(int argc, char *argv[]) { if (argc<=1) { printf("Usage: dea \n"); return -2; } fin=fopen(argv[1],"r"); printf("%s:",argv[1]); fscanf(fin,"%d %d\n",&numein,&numeout); printf("%d inputs, %d outputs,",numein,numeout); nume=numein+numeout; while (!feof(fin)){ siz++; for (x=1;x<=nume;x++) fscanf(fin,"%f ",&m[siz][x]); } fclose(fin); printf(" %d data\n",siz); fsh=fopen("lp.sh","w"); for (n=1;n<=siz;n++){ sprintf(nombre,"%d",(DATA+n)); fprintf(fsh,"lp_solve <%s >%s.lp\n",nombre,nombre); fout=fopen(nombre,"w"); for (y=1;y<=numein;y++) m[siz+1][y]=m[n][y]; for (y=numein+1;y<=nume;y++) m[0][y]=m[n][y]; fprintf(fout,"max: "); for (y=numein+1;y<=nume;y++) if (m[0][y]!=0) fprintf(fout," +%f Y%d",m[0][y],y); fprintf(fout,";\n"); for (x=1;x<=siz;x++){ for (y=1;y<=numein;y++) if (m[x][y]!=0) fprintf(fout," +%f X%d",m[x][y],y); for (y=numein+1;y<=nume;y++) if (m[x][y]!=0) fprintf(fout," -%f Y%d",m[x][y],y); fprintf(fout," >=0 ;\n"); } for (y=1;y<=numein;y++) if (m[siz+1][y]!=0) fprintf(fout," +%f X%d",m[siz+1][y],y); fprintf(fout," = 1 ;\n"); fclose(fout); } fprintf(fsh,"grep objective *.lp > RESULT\n"); fclose(fsh); return -1; }