#!/usr/local/bin/perl -w # Generador de programas DEA a resolver con lp_solve # Q: I did not read dea.c, I have no idea on using... # A: dea [your_data_file] # 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! (CCR) 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 any n # SUM vx' = 1 # all v,w >= 0 # Easy questions: gamo@telecable.es # if (@ARGV<1) { print "Usage: dea.pl inputfile\n"; exit -2 ; } open (FIN, "<".$ARGV[0]) or die "Cannot open $ARGV[0]: $!"; $ok=0; while (){ next if (/^#/); chomp; if ($ok==0){ ($numein, $numeout) = split /\s+/,$_; $nume=$numein+$numeout; print "$numein $numeout\n"; $ok=1; }else{ $siz++; @line = split /\s+/,$_; print "@line\n"; $n=0; for $i (@line){ $n++; $m[$siz][$n]=$i; } if ($n!=$nume) { die "Data does not match with header in line $siz+1"; } } } close FIN; open FSH, ">lp.bat" or die "Cannot open lp.bat"; unlink "results"; for $n (1..$siz){ $number=1000+$n; print FSH "lp_solve < $number >> results\n"; open (FOUT, ">$number") or die "Cannot open 1000+$n"; for $y (1..$numein) { $m[$siz+1][$y]=$m[$n][$y]; } for $y ($numein+1..$nume) { $m[0][$y]=$m[$n][$y]; } print FOUT "max: "; for ($y=$numein+1;$y<=$nume;$y++){ if ($m[0][$y]!=0) { print FOUT " +$m[0][$y] Y$y";} } print FOUT ";\n"; for $x (1..$siz){ for $y (1..$numein){ if ($m[$x][$y]!=0){ print FOUT " +$m[$x][$y] X$y";} } for $y ($numein+1..$nume){ if ($m[$x][$y]!=0){ print FOUT " -$m[$x][$y] Y$y";} } print FOUT " >= 0;\n"; } for $y (1..$numein){ if ($m[$siz+1][$y]!=0) { print FOUT " +$m[$siz+1][$y] X$y"; } } print FOUT " = 1;\n"; close FOUT; } # print FSH "find objective @results > RESULT\n"; close FSH; system "sh lp.bat"; system "grep objective results > RESULT"; __END__