function irrigation
% 1.731 Irrigation efficiency example
% Sept 7, 2006
% This program evaluates and plots net revenue (objective) vs. irrigation efficiency
%
% Problem inputs
p=0.2    % crop market price in $ kg^-1
Y0=5000  % maximum yield in kg ha^-1 yr^-1
Sa=300   % applied water salinity in mg L^-1
c=10  % applied water cost coef. in $ (ham)^-1 yr^-1
Smax=1000 % maximum crop salinity in mg L^-1
%
% Plot objective function
e=0.01*(10:50);   % efficiency range
% Yfactor=zeros(1,length(e));
S=Sa./(1-e);    % root zone salinity
Qa=3./e;        % applied water
revenue=p*Y0*Yfactor(S,Smax);
cost=c*Qa;
F=revenue - cost;
close all
figure
Splot=0:10:1000
Yfactorplot=Yfactor(Splot,Smax);
plot(Splot,Yfactorplot)
figure
plot(e,F,'b',e,revenue,'r',e,cost,'g')
legend('net profit','revenue','cost')
%
% Identify optimum
optf=max(F)    
opte=0.1+0.01*(find(F==optf)-1)
return
function y=Yfactor(S,Smax)
Sok=S<=Smax;
y=(1-S(Sok)./Smax).^.33;  % yield response function
return