#!/usr/bin/octave
global NH = 1000000 NK = 2091694;
global EH = 1000 EK = 400;
global GH = 8.6 GK = 4.9;
global WH = 1100 WK = 1100;
global LH = 11.5 LK = 12.5;
global RH = 15 RK = 20;
global FK = WK * GK / EH;
global FH = WH * GH / EK;
function [nh, nk] = schlachtung(nh, nk, th, tk)
global FK FH;
hk = nk; hh = nh;
nh = nh + th; nk = nk + tk;
while((hh > 0 || hk > 0) && nh >= th && nk >= tk)
if (hh > 0)
nk = nk - 1;
hk = hk - 1;
hh = hh - FK;
endif
if (hk > 0)
nh = nh - 1;
hh = hh - 1;
hk = hk - FH;
endif
end
end
H = [NH]; K = [NK];
E = [NH * GH * WH + NK * GK * WK];
for d = 1:1:365
AK = K(end);
AH = H(end);
TK = ceil(AK / LK / 365); AK = AK - TK;
TH = ceil(AH / LH / 365); AH = AH - TH;
AK = AK + floor(AK / LK / 365 * RH);
AH = AH + floor(AH / LH / 365 * RH);
[AH, AK] = schlachtung(AH, AK, TH, TK);
if (AK <= 0) K = [K; NaN]; break; endif
if (AH <= 0) H = [H; NaN]; break; endif
E = [E; AH * GH * WH + AK * GK * WK];
K = [K; AK];
H = [H; AH];
printf("
end
clf; hold on;
set(gca, ["fontsize"], 12);
ak = plot(K, "r;cats;o-");
ah = plot(H, "g;dogs;o-");
gj = plot(E .* 0.0000041868, "b;energy;o-");
set(gca, ["y" "ticklabel"], get(gca, ["y" "tick"]) / 1000000);
title("Eigenwert: sustainable slaughter");
xlabel("time [days]");
ylabel("population [mlns]");
print("d+c-eigenwert3a.png", "-dpng", "-S960,640");
print("d+c-eigenwert3a.svg", "-dsvg", "-S960,640");