Nein, so soll das ungefähr aussehen:
public class RäuberBeute
{
int Zeitende = 100;
int y = 5;
int x = 100;
int a = 0.001;
int b = 0.0001;
int c = 0.0004;
int e = 0.005;
int x_delta = 0;
int y_delta = 0;
for (int i=0; i<Zeitende; i++)
{
x = x + x_delta;
y = y + y_delta;
System.out.println("x=" + x + " y=" + y);
}
zusätzlich noch Verbesserungsmöglichkeiten, wie
- die Hasen können sich ohne Füchse nicht beliebig vermehren, da das Gras
in der Realität nicht unbegrenzt vorhanden ist.
- Krankheiten nehmen bei zunehmender Population zu und erhöhen die
Sterberate
Alles anzeigen
Ist zwar Matlab-Code mit graph. Ausgabe, aber du kannst es ja selbst portieren od. dir Anregungen holen..., die Dämpfung durch begrenztes Futter und begrenzte Beute ist berücksichtigt,..auch ein Vergleich mit realen Messdaten, zusätzlich gabs noch eine Erweiterung , die den Einsatz von Schädlingsbekämpfungsmittel auf den Kreislauf berücksichtigt hat - die ist hier nicht drin aber im pdf.
Aber das Zeugs in Java coden , musst du schon selbst.
Ist ja nicht viel,.. die Berechungsgleichungen hast du ja ... also nur Werte noch Einlesen, die Diffgleichungen ausrechnen, und dir über die Ausgabe kurz Gedanken machen,.. graphisch oder bloss textuelle Ergebnisse.
%
% CHAPTER: population dynamics - Lotka-Volterra predator-prey model
% EXAMPLE: 100 - model with\without damping
% KEYWORDS: population dynamics, ODEs
% DESCRIPTION: Implementation of the Lotka-Volterra predator-prey model
% AUTHORS: kira
% LAST MODIFIED: 2009-02-27
% BY: gz
tfinal = str2double(instruct.var1); % end time in years
prey = str2double(instruct.var2); % number of prey
pred = str2double(instruct.var3); % number of predators
prey_g = str2double(instruct.var4); % growth rate prey
prey_f = str2double(instruct.var5); % food rate prey
pred_g = str2double(instruct.var6); % growth rate predators
pred_f = str2double(instruct.var7); %food rate predators
realValues = str2double(instruct.var8); % decision variable, 1 or 2
t0 = 0; % this is the start time of the experiment
x = [prey pred]'; % these are the initial numbers of predator and prey
[t,x] = ode45(@ungedaempft,[t0 tfinal], x);
subplot(2,2,1:2);
hold on;
plot( t,x(:,1), '-g','LineWidth',2); % Beute
plot( t,x(:,2), '-r','LineWidth',2); % Raeuber
title('Populationsdynamisches Modell nach Lotka und Volterra');
xlabel('t');
ylabel('x1 und x2');
grid on;
if realValues == 1
prey_d = 50;
pred_d = 25;
x1 = [prey pred]'; % these are the initial numbers of predator and prey
[t1,x1] = ode45(@gedaempft,[t0 tfinal], x1);
Stuetz = t1(1:round(length(t)/(2*tfinal)):end);
Anzahl = length(Stuetz);
Add_values = (1 + 0.03*rand(Anzahl,1)).*x1(1:round(length(t)/(2*tfinal)):end,1);
plot(Stuetz,Add_values, 'ob');
legend('Beute','Raeuber','Beutemesswerte');
else
legend('Beute','Raeuber');
end
hold off;
subplot(2,2,3:4);
%hold on;
plot(x(:,1),x(:,2),'b');
grid on;
title('Gleichgewicht');
xlabel('x1 - Beutetiere');
ylabel('x2 - Raubtiere');
%hold off;
function xp = ungedaempft(t, x)
% Berechnung
xp(1)= prey_g*x(1) - prey_f*x(1)*x(2); % Beutetiere
xp(2)= pred_g*x(1)*x(2) - pred_f*x(2); % Raubtiere
% Berechnung und übergeben
xp= xp';
end
function xp = gedaempft(t1, x1)
xp(1)= prey_g*x1(1) - prey_f*x1(1)*x1(2); - prey_d*x1(1).^2; % Beutetiere
xp(2)= pred_g*x1(1)*x1(2) - pred_f*x1(2); - pred_d*x1(2).^2; % Raubtiere
xp= xp';
end
Alles anzeigen
bzw.... hier: http://www.inverudio.com/programs/PredatorPrey/predator-prey-multi-agent-repast-simulation.zip
Aber , wenn du nichtmal selbst googlen kannst,.. hast du deine Informatiknote bestimmt nicht verdient..:lauscher: