WICHTIG: Der Betrieb von goMatlab.de wird privat finanziert fortgesetzt. - Mehr Infos...

Mein MATLAB Forum - goMatlab.de

Mein MATLAB Forum

 
Gast > Registrieren       Autologin?   

Partner:




Forum
      Option
[Erweitert]
  • Diese Seite per Mail weiterempfehlen
     


Gehe zu:  
Neues Thema eröffnen Neue Antwort erstellen

Problem mit Code und Fehlersuche

 

grandmasta

Gast


Beiträge: ---
Anmeldedatum: ---
Wohnort: ---
Version: ---
     Beitrag Verfasst am: 16.01.2019, 17:51     Titel: Problem mit Code und Fehlersuche
  Antworten mit Zitat      
Hey Leute,

ich soll dieses Problem lösen:

4 gleichartige, unabhängig voneinander operierende Maschinen werden derzeit von einem Monteur betreut. Die Betriebszeiten jeder Maschine zwischen zwei aufeinanderfolgenden Ausfällen seien unabhängig und exponentialverteilt mit dem für alle Maschinen gleichen Parameter lambda = 1/6. Entsprechend seien die Reparaturzeiten der Maschinen unabhängig voneinander und jeweils exponentialverteilt mit dem Parameter mu = 1. Fällt eine Maschine
aus, so wird sofort mit ihrer Reparatur begonnen, die von genau einem Monteur
auszuführen ist. Es wird nun überlegt, einen zweiten Monteur anzustellen.
Vergleichen sie die Auslastungen zwischen der Strategie mit einem Monteur und der Strategie mit zwei Monteuren. Wählen Sie selbst sinnvolle Zahlen für Kosten von Stillstand und Monteur und bestimmen Sie dadurch die bessere Strategie. Stellen Sie im Rahmen der Präsentation den Ablauf des Programmes anhand von selbstgewählten Zufallszahlen vor.
• Input: Kosten für Stillstand und Lohnkosten für Monteur
• Output: Status der Maschinen je Periode, Arbeitsauslastung Monteur je Periode

Ich habe versucht einen Code zu schreiben. Für mich als Anfänger ist er einfach viel zu lange und frage mich ob man ihn irgendwie vereinfachen kann. Zusätzlich bin ich mir sicher, dass irgendwo ein Fehler sein muss, da die Reperaturzeit nicht meine Simulationszeit überschreiten kann...

Ich finde aber leider nicht den Fehler, bin leider schon ganz verzweifelt.

Ich danke für eure Hilfe.

LG

Hier noch der Code:
Code:
clc
clear all

simulation_time = input('\nBitte geben Sie die Simulationszeit in Minuten ein: ');
hold_up_costs_machine_hours = input('Bitte geben Sie die Kosten für den Stillstand der Maschine für eine Stunde an: ');
costs_mechanic_hour = input('Bitte geben Sie die Kosten für einen Mechaniker für eine Stunde an: ');

hold_up_costs_machine_minutes = hold_up_costs_machine_hours/60; % cost for hold up machine per minute
costs_mechanic__minute = costs_mechanic_hour/60;     % costs for one mechanic per minute

quantity_machines = 4;                                       % quantity of machines
lambda = 1/6;                                                 % lambda
mu = 1;                                                       % my = 1/lambda

quantity_mechanics = [1,2];                                  % quantity of mechanics
quantity_mechanics_strategy2 = quantity_mechanics(1,2);            

total_time = 0;                                                % total time of simulation                    
total_time_strategy1 = 0;                                             % total time of strategy 1
mechanic_working_minutes_strategy1 = 0;                                % how long the mechanic works
repaired_machines_strategy1 = 0;                                      % quantity of repaired machines
costs_strategy1 = 0;                                                 % total costs
waiting_machines_strategy1 = zeros(1,quantity_machines);            % machines which wait for repair
working_time_repair_time_strategy1 = zeros(quantity_machines,2);      % working time until break and repair time in a vector
finish_time_strategy1 = 0;                                         % repair finished time

time_strategy2 = zeros(1,quantity_mechanics_strategy2);
total_time_strategy2 = 0;
mechanic_working_minutes_strategy2 = zeros(1,quantity_mechanics_strategy2);
repaired_machines_strategy2 = 0;
costs_strategy2 = 0;
waiting_machines_strategy2 = zeros(1,quantity_machines);
working_repair_strategy2 = zeros(quantity_machines,2);
finish_time_strategy2 = zeros(1,quantity_mechanics_strategy2);
waiting_for_next_mechanic_strategy2 = zeros(1,quantity_machines);
working_time_waiting_machine_strategy2 = zeros(1,quantity_machines);

while total_time <= simulation_time                                           % while total time <= simulation time
    % calculation of working and repair times
    for k = 1:quantity_machines                                           % for 1 to quantity of machines calculate the working and repair times of the machines
        random_number1(k) = rand();
        working_time_machine(k) = ((-1/lambda)*(log(random_number1(k))))*60;     % vector with working times of the machines * 60 (to get minutes)
        random_number2(k) = rand();
        repair_time_machine(k) = ((-mu)*(log(random_number2(k))))*60;            % vector with repair times of the machines * 60
        finished_repair_machine(k) = working_time_machine(k) + repair_time_machine(k);   % finished repair = working time + repair time
        working_repair(k,:) = [working_time_machine(k),repair_time_machine(k)]; % matrix with working times and repair times
    end
   
    % sorting of the working times
    for i = 1:quantity_mechanics(1)
        working_time_repair_time_strategy1(:,:) = working_time_repair_time_strategy1(:,:) + working_repair(:,:);
        for mu = 1:quantity_machines-1
            for n = quantity_machines:-1:mu+1
                if working_time_repair_time_strategy1(n,1) < working_time_repair_time_strategy1(mu,1)       % compare the working times of the last machine with the working times of the first machine
                    helper = working_time_repair_time_strategy1(n,:);                             % if the working times of the first machine is higher than the working times of the last machine put the first machine working times on the helpvariable that we do not lose the first working times
                    working_time_repair_time_strategy1(n,:) = working_time_repair_time_strategy1(mu,:);     % and the last working times put on the first machine
                    working_time_repair_time_strategy1(mu,:) = helper;
                end
            end
        end
       
        for p = 1:quantity_machines
            % repair of the first broken machine
            if p == 1
                if working_time_repair_time_strategy1(p,1) > finish_time_strategy1                     % if the working time > than the finished time mechanic is free and can repair
                    total_time_strategy1 = total_time_strategy1 + (working_time_repair_time_strategy1(p,1) + working_time_repair_time_strategy1(p,2)); % total time = working time + repair time
                    mechanic_working_minutes_strategy1 = mechanic_working_minutes_strategy1 + working_time_repair_time_strategy1(p,2); % time the mechanic works = time the mechanic works until now + repair time yet
                    repaired_machines_strategy1 = repaired_machines_strategy1 + 1;                        % repaired machines + 1
                    costs_strategy1 = costs_strategy1 + (working_time_repair_time_strategy1(p,2) * hold_up_costs_machine_minutes + working_time_repair_time_strategy1(p,2)* costs_mechanic__minute); % costs are the repair time * hold up costs + repair time * mechanic costs
                    finished_S1(p) = working_time_repair_time_strategy1(p,1) + working_time_repair_time_strategy1(p,2); % finished time = working time + repair time
                    waiting_machines_strategy1(p) = 0;                % the machine is repaired so it does not have to wait
                    machine_is_repaired_Strategy1(p) = 1;             % set the machine repaired
                    finish_time_strategy1 = finished_S1(p);         % finished time of the mechanic
                else
                    costs_strategy1 = costs_strategy1 + ((finish_time_strategy1 - working_time_repair_time_strategy1(p,1)) * hold_up_costs_machine_minutes); % if the mechanic has no time the machine has hold up costs
                    waiting_machines_strategy1(p) = 1;                % the machine has to wait
                end
            else
                finished_S1(p) = working_time_repair_time_strategy1(p,1) + working_time_repair_time_strategy1(p,2); % finished time = working time + repair time
                machine_is_repaired_Strategy1(p) = 0;                 % set the machine not repaired
                if working_time_repair_time_strategy1(p,1) < finish_time_strategy1 %if the working time is under the time the mechanic has finished his last repair
                    costs_strategy1 = costs_strategy1 + ((finish_time_strategy1 - working_time_repair_time_strategy1(p,1)) * hold_up_costs_machine_minutes); % the machine causes hold up costs
                    waiting_machines_strategy1(p) = 1;                % the machine has to wait
                end
            end
        end
       
        % handle the waiting machines
        for q = 1:length(waiting_machines_strategy1)
            if waiting_machines_strategy1(q) == 1                             % first machine which is waiting
                working_time_repair_time_strategy1(q,1) = finish_time_strategy1;     % working time = finished time
                finish_time_strategy1 = working_time_repair_time_strategy1(q,1) + working_time_repair_time_strategy1(q,2); % finished time = workingtime + repair time
                mechanic_working_minutes_strategy1 = mechanic_working_minutes_strategy1 + working_time_repair_time_strategy1(q,2); % time the mechanic works = time the mechanic works until now + repair time yet
                repaired_machines_strategy1 = repaired_machines_strategy1 + 1;          % repaired machines + 1
                costs_strategy1 = costs_strategy1 + (working_time_repair_time_strategy1(q,2) * hold_up_costs_machine_minutes + working_time_repair_time_strategy1(q,2)* costs_mechanic__minute);  % costs are the repair time * hold up costs + repair time * mechanic costs
                waiting_machines_strategy1(q) = 0;                            % the machine no longer waits
                machine_is_repaired_Strategy1(q) = 1;                         % set the machine repaired
                total_time_strategy1 = total_time_strategy1 + finish_time_strategy1;         % total time = total time + finished time
            end
        end
       
        % handle the machines which were not repaired until now
        for s = 1:length(machine_is_repaired_Strategy1)
            if machine_is_repaired_Strategy1(s) == 0
                if working_time_repair_time_strategy1(s,1) <  finish_time_strategy1    % if the working time is under the time the mechanic has finished his last repair
                    costs_strategy1 = costs_strategy1 + ((finish_time_strategy1 - working_time_repair_time_strategy1(s,1)) * hold_up_costs_machine_minutes); % if the mechanic has no time the machine has hold up costs
                    working_time_repair_time_strategy1(s,1) = finish_time_strategy1;   % working time of the machine is the finished time
                else
                    finish_time_strategy1 = working_time_repair_time_strategy1(s,1) + working_time_repair_time_strategy1(s,2);   % else the finished time = working time + repair time
                end
                mechanic_working_minutes_strategy1 = mechanic_working_minutes_strategy1 + working_time_repair_time_strategy1(s,2);    % time the mechanic works = time the mechanic works until now + repair time yet
                repaired_machines_strategy1 = repaired_machines_strategy1 + 1;            % repaired machines + 1
                costs_strategy1 = costs_strategy1 + (working_time_repair_time_strategy1(s,2) * hold_up_costs_machine_minutes + working_time_repair_time_strategy1(s,2)* costs_mechanic__minute); % costs are the repair time * hold up costs + repair time * mechanic costs
                machine_is_repaired_Strategy1(s) = 1;                           % set the machine repaired
                total_time_strategy1 = total_time_strategy1 + finish_time_strategy1;           % total time = total time + finished time
            end
        end
    end
    total_time = total_time_strategy1;       % total time = total time_S1
end

   fprintf('Strategy 2:')
   
   
    for j = 1:quantity_mechanics_strategy2
        % first mechanic
         if j == 1
            working_repair_strategy2(:,:) = working_repair_strategy2(:,:) + working_repair(:,:);
            for t = 1:quantity_machines-1
                 for u = quantity_machines:-1:t+1
                     if working_repair_strategy2(u,1) < working_repair_strategy2(t,1)      
                         helper = working_repair_strategy2(u,:);          
                         working_repair_strategy2(u,:) = working_repair_strategy2(t,:);    
                         working_repair_strategy2(t,:) = helper;
                     end
                 end
             end
             for v = 1:quantity_machines
                 if v == 1
                     if working_repair_strategy2(v,1) > finish_time_strategy2(j)
                         time_strategy2(j) = time_strategy2(j) + (working_repair_strategy2(v,1) + working_repair_strategy2(v,2));
                         mechanic_working_minutes_strategy2(j) = mechanic_working_minutes_strategy2(j) + working_repair_strategy2(v,2);
                         repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                         costs_strategy2 = costs_strategy2 + (working_repair_strategy2(v,2) * hold_up_costs_machine_minutes + working_repair_strategy2(v,2)* costs_mechanic__minute);
                         finished_strategy2(v) = working_repair_strategy2(v,1) + working_repair_strategy2(v,2);
                         waiting_machines_strategy2(v) = 0;
                         machine_is_repaired_strategy2(v) = 1;
                         finish_time_strategy2(j) = finished_strategy2(v);
                     else
                         waiting_machines_strategy2(v) = 1;
                         waiting_for_next_mechanic_strategy2(v) = 1;
                         repaire_time_waiting_machine_strategy2(v) = working_repair_strategy2(v,2);
                         working_time_waiting_machine_strategy2(v) = working_repair_strategy2(v,1);
                         finished_waiting_machine_strategy2(v) = finish_time_strategy2(j);
                         machine_is_repaired_strategy2(v) = 1;
                         waiting_machines_strategy2(v) = 0;
                     end
                 else
                     finished_strategy2(v) = working_repair_strategy2(v,1) + working_repair_strategy2(v,2);
                     machine_is_repaired_strategy2(v) = 0;
                     if working_repair_strategy2(v,1) < finish_time_strategy2(j)
                        waiting_for_next_mechanic_strategy2(v) = 1;
                        repaire_time_waiting_machine_strategy2(v) = working_repair_strategy2(v,2);
                        working_time_waiting_machine_strategy2(v) = working_repair_strategy2(v,1);
                        finished_waiting_machine_strategy2(v) = finish_time_strategy2(j);
                        waiting_machines_strategy2(v) = 0;
                        machine_is_repaired_strategy2(v) = 1;
                     end
                end
             end
             
             for w = 1:length(waiting_machines_strategy2)
                 if waiting_machines_strategy2(w) == 1
                    working_repair_strategy2(w,1) = finish_time_strategy2(j);
                    finish_time_strategy2(j) = working_repair_strategy2(w,1) + working_repair_strategy2(w,2);
                    mechanic_working_minutes_strategy2(j) = mechanic_working_minutes_strategy2(j) + working_repair_strategy2(w,2);
                    repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                    costs_strategy1 = costs_strategy2 + (working_repair_strategy2(w,2) * hold_up_costs_machine_minutes + working_repair_strategy2(w,2)* costs_mechanic__minute);
                    waiting_machines_strategy2(w) = 0;
                    machine_is_repaired_strategy2(w) = 1;
                    time_strategy2(j) = time_strategy2(j) + finish_time_strategy2(j);
                 end
             end
             for x = 1:length(machine_is_repaired_strategy2)
                 if machine_is_repaired_strategy2(x) == 0
                     if working_repair_strategy2(x,1) <  finish_time_strategy2(j)
                        waiting_for_next_mechanic_strategy2(x) = 1;
                        repaire_time_waiting_machine_strategy2(x) = working_repair_strategy2(x,2);
                        working_time_waiting_machine_strategy2(x) = working_repair_strategy2(x,1);
                        finished_waiting_machine_strategy2(x) = repaire_time_waiting_machine_strategy2(x) + working_time_waiting_machine_strategy2(x);
                        waiting_machines_strategy2(x) = 0;
                        machine_is_repaired_strategy2(x) = 1;
                        continue;
                     else
                         finish_time_strategy2(j) = working_repair_strategy2(x,1) + working_repair_strategy2(x,2);
                     end
                     mechanic_working_minutes_strategy2(j) = mechanic_working_minutes_strategy2(j) + working_repair_strategy2(x,2);
                     repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                     costs_strategy2 = costs_strategy2 + (working_repair_strategy2(x,2) * hold_up_costs_machine_minutes + working_repair_strategy2(x,2)* costs_mechanic__minute);
                     machine_is_repaired_strategy2(x) = 1;
                     time_strategy2(j) = time_strategy2(j) + finish_time_strategy2(j);
                 end
             end
         else
             if sum(waiting_for_next_mechanic_strategy2) > 0
                 for h = 1:length(waiting_for_next_mechanic_strategy2)
                     if waiting_for_next_mechanic_strategy2(h) == 1
                         if working_time_waiting_machine_strategy2(h) < finish_time_strategy2(j)
                             if working_time_waiting_machine_strategy2(h) < finish_time_strategy2(j-1)
                                 costs_strategy2 = costs_strategy2 + (((min(finish_time_strategy2(j-1),finish_time_strategy2(j))) - working_time_waiting_machine_strategy2(h))*hold_up_costs_machine_minutes);
                                 working_time_waiting_machine_strategy2(h) = min(finish_time_strategy2(j-1),finish_time_strategy2(j));
                                 waiting_for_next_mechanic_strategy2(h) = 1;
                             else
                                 finish_time_strategy2(j-1) = finish_time_strategy2(j-1) + repaire_time_waiting_machine_strategy2(h);
                                 costs_strategy2 = costs_strategy2 + (repaire_time_waiting_machine_strategy2(h) * hold_up_costs_machine_minutes + repaire_time_waiting_machine_strategy2(h) * costs_mechanic__minute);
                                 waiting_for_next_mechanic_strategy2(h) = 0;
                                 repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                                 mechanic_working_minutes_strategy2(j-1) = mechanic_working_minutes_strategy2(j-1) + repaire_time_waiting_machine_strategy2(h);
                             end
                         else
                             waiting_for_next_mechanic_strategy2(h) = 0;
                             mechanic_working_minutes_strategy2(j) = mechanic_working_minutes_strategy2(j) + repaire_time_waiting_machine_strategy2(h);
                             repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                             costs_strategy2 = costs_strategy2 + (repaire_time_waiting_machine_strategy2(h) * hold_up_costs_machine_minutes + repaire_time_waiting_machine_strategy2(h) * costs_mechanic__minute);
                             finish_time_strategy2(j) = finish_time_strategy2(j) + finished_waiting_machine_strategy2(h);
                         end
                     end
                 end
                 if sum(waiting_for_next_mechanic_strategy2) > 0
                     for g = 1:length(waiting_for_next_mechanic_strategy2)
                         if waiting_for_next_mechanic_strategy2(g) == 1
                             if working_time_waiting_machine_strategy2(g) < finish_time_strategy2(j)
                                 if working_time_waiting_machine_strategy2(g) < finish_time_strategy2(j-1)
                                     costs_strategy2 = costs_strategy2 + (((min(finish_time_strategy2(j-1),finish_time_strategy2(j))) - working_time_waiting_machine_strategy2(g))*hold_up_costs_machine_minutes);
                                     working_time_waiting_machine_strategy2(g) = min(finish_time_strategy2(j-1),finish_time_strategy2(j));
                                     waiting_for_next_mechanic_strategy2(g) = 1;
                                 else
                                     finish_time_strategy2(j-1) = finish_time_strategy2(j-1) + repaire_time_waiting_machine_strategy2(g);
                                     costs_strategy2 = costs_strategy2 + (repaire_time_waiting_machine_strategy2(g) * hold_up_costs_machine_minutes + repaire_time_waiting_machine_strategy2(g) * costs_mechanic__minute);
                                     waiting_for_next_mechanic_strategy2(g) = 0;
                                     repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                                     mechanic_working_minutes_strategy2(j-1) = mechanic_working_minutes_strategy2(j-1) + repaire_time_waiting_machine_strategy2(g);
                                 end
                             else
                                 waiting_for_next_mechanic_strategy2(g) = 0;
                                 mechanic_working_minutes_strategy2(j) = mechanic_working_minutes_strategy2(j) + repaire_time_waiting_machine_strategy2(g);
                                 repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                                 costs_strategy2 = costs_strategy2 + (repaire_time_waiting_machine_strategy2(g) * hold_up_costs_machine_minutes + repaire_time_waiting_machine_strategy2(g) * costs_mechanic__minute);
                                 finish_time_strategy2(j) = finish_time_strategy2(j) + finished_waiting_machine_strategy2(g);
                             end
                         end
                     end
                 end
             end
             if sum(waiting_for_next_mechanic_strategy2) > 0
                 for g = 1:length(waiting_for_next_mechanic_strategy2)
                     if waiting_for_next_mechanic_strategy2(g) == 1
                         if working_time_waiting_machine_strategy2(g) < finish_time_strategy2(j)
                             if working_time_waiting_machine_strategy2(g) < finish_time_strategy2(j-1)
                                 costs_strategy2 = costs_strategy2 + (((min(finish_time_strategy2(j-1),finish_time_strategy2(j))) - working_time_waiting_machine_strategy2(g))*hold_up_costs_machine_minutes);
                                 working_time_waiting_machine_strategy2(g) = min(finish_time_strategy2(j-1),finish_time_strategy2(j));
                                 waiting_for_next_mechanic_strategy2(g) = 1;
                             else
                                 finish_time_strategy2(j-1) = finish_time_strategy2(j-1) + repaire_time_waiting_machine_strategy2(g);
                                 costs_strategy2 = costs_strategy2 + (repaire_time_waiting_machine_strategy2(g) * hold_up_costs_machine_minutes + repaire_time_waiting_machine_strategy2(g) * costs_mechanic__minute);
                                 waiting_for_next_mechanic_strategy2(g) = 0;
                                 repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                                 mechanic_working_minutes_strategy2(j-1) = mechanic_working_minutes_strategy2(j-1) + repaire_time_waiting_machine_strategy2(g);
                             end
                         else
                             waiting_for_next_mechanic_strategy2(g) = 0;
                             mechanic_working_minutes_strategy2(j) = mechanic_working_minutes_strategy2(j) + repaire_time_waiting_machine_strategy2(g);
                             repaired_machines_strategy2 = repaired_machines_strategy2 + 1;
                             costs_strategy2 = costs_strategy2 + (repaire_time_waiting_machine_strategy2(g) * hold_up_costs_machine_minutes + repaire_time_waiting_machine_strategy2(g) * costs_mechanic__minute);
                             finish_time_strategy2(j) = finish_time_strategy2(j) + finished_waiting_machine_strategy2(g);
                         end
                     end
                 end
             end
             
             total_time_strategy2 = total_time_strategy2 + max(finish_time_strategy2(j),finish_time_strategy2(j-1));
         end
     end
     
     total_time = max(total_time_strategy1,total_time_strategy2);
     
     machine_is_repaired_Strategy1 = zeros(1,quantity_machines);
     machine_is_repaired_strategy2 = zeros(1,quantity_machines);
     waiting_for_next_mechanic_strategy2 = zeros(1,quantity_machines);
 
utilization_Mechanic_strategy1 = (mechanic_working_minutes_strategy1/total_time)*100;

fprintf('\nStrategie 1: Ein Monteur\n');
fprintf('Das sind die gesamten Kosten mit einem Monteur: € %g\n', costs_strategy1);
fprintf('So viele Maschinen hat er repariert: %g, innerhalb von %g Minuten.\n', repaired_machines_strategy1, total_time);
fprintf('Der Mechaniker hat eine Auslastung von: %g Prozent.\n', utilization_Mechanic_strategy1);

fprintf('\nStrategie 2: Zwei Monteure\n');
fprintf('Das sind die gesamten Kosten mit zwei Monteuren: € %g\n', costs_strategy2);
fprintf('So viele Maschinen hat er repariert: %g, innerhalb von %g Minuten.', repaired_machines_strategy2, total_time);
for z = 1:quantity_mechanics_strategy2
    utilization_Mechanic_strategy2(z) = (mechanic_working_minutes_strategy2(z)/total_time)*100;
    fprintf('\nDer %g. Mechaniker hat eine Auslastung von: %g Prozent.', z, utilization_Mechanic_strategy2(z));
end

%Interpretation: Wenn die Kosten für den Stillstand viel höher sind, als
%die Kosten für einen Mechaniker, dann ist Strategie 2 mit 2 Mechanikern
%besser. Sonst ist Strategie 1 mit einem Mechaniker besser.


Jan S
Moderator

Moderator


Beiträge: 11.057
Anmeldedatum: 08.07.10
Wohnort: Heidelberg
Version: 2009a, 2016b
     Beitrag Verfasst am: 17.01.2019, 15:26     Titel: Re: Problem mit Code und Fehlersuche
  Antworten mit Zitat      
Hallo grandmasta,

Der Code ist wirklich schwer zu lesen. Bei der Genauigkeit der Variablennamen sollte man nicht übertreiben. "hold_up_costs_machine_minutes" ist schon ein Overkill. Statt "quantity_X" könnte "nX" auch ausreichen, wäre aber viel einfacher zu lesen.

Zitat:
Zusätzlich bin ich mir sicher, dass irgendwo ein Fehler sein muss, da die Reperaturzeit nicht meine Simulationszeit überschreiten kann...

Während du weißt, um welche Variablen es geht und was du erwartest, haben die Leser im Forum keine Ahnung davon. Es würde recht lange dauern sich in die Programmlogik einzuarbeiten um den Fehler zu finden.

Die Fehlersuche wäre deutlich einfacher, wenn der Code reproduzierbare Ergebnisse liefern würde, indem man ihn als Funktion mit Input-Argumenten aufruft. Bei den input Aufrufen könnte man ja auch einen Tippfehler machen.

Der Code ist zu lang um übersichtlich debugbar zu sein. Sinnvoller ist es einzelne Teile als Unterfunktion zu schreiben, die man dann separat testen kann.

Gruß, Jan
Private Nachricht senden Benutzer-Profile anzeigen
 
Neues Thema eröffnen Neue Antwort erstellen



Einstellungen und Berechtigungen
Beiträge der letzten Zeit anzeigen:

Du kannst Beiträge in dieses Forum schreiben.
Du kannst auf Beiträge in diesem Forum antworten.
Du kannst deine Beiträge in diesem Forum nicht bearbeiten.
Du kannst deine Beiträge in diesem Forum nicht löschen.
Du kannst an Umfragen in diesem Forum nicht mitmachen.
Du kannst Dateien in diesem Forum posten
Du kannst Dateien in diesem Forum herunterladen
.





 Impressum  | Nutzungsbedingungen  | Datenschutz | FAQ | goMatlab RSS Button RSS

Hosted by:


Copyright © 2007 - 2024 goMatlab.de | Dies ist keine offizielle Website der Firma The Mathworks

MATLAB, Simulink, Stateflow, Handle Graphics, Real-Time Workshop, SimBiology, SimHydraulics, SimEvents, and xPC TargetBox are registered trademarks and The MathWorks, the L-shaped membrane logo, and Embedded MATLAB are trademarks of The MathWorks, Inc.