Abt. Brute-Force Ansatz für 12 Speisen auf 4 Kochplatten
===========================================
Die Kochzeiten sind diesmal:
50,45,40,35
30,25,20,15
10, 7, 5, 3 min.
Gruss
P.S.: Das "brutale Durchprobierberverfahren" stößt hier bereits an seine Grenzen: Nur mit Mühe konnte die reine XProfan-Rechenzeit auf 1.09 Minuten gedrückt werden. dabei wird auf Feinabstimmung derbeiden kleinsten Zeiten zu Gunsten der Geschwindigkeit bereits verzichtet. Höchste Zeit für intelligentere Verfahren!
WindowTitle "Gesamtzeit-Optimierung für 4 Kochplatten und 12 Speisen":WindowStyle 24
cls:font 2:set("numwidth",3)
declare t&[12],p&[12],min!,z0&,z1&,z2&,z3&,z&,p$,q$,r$,s$,tm&,n&,opt!,tmp&,i&,j&
t&[1]=50
t&[4]=45
t&[7]=40
t&[10]=35
t&[2]=30
t&[5]=25
t&[8]=20
t&[11]=15
t&[3]=10
t&[6]=7
t&[9]=5
t&[12]=3
whileloop 12:i&=&Loop:whileloop 12:j&=&Loop:case i&=j&:continue
if t&[i&]>t&[j&]:tmp&=t&[i&]:t&[i&]=t&[j&]:t&[j&]=tmp&:endif
endwhile:endwhile:whileloop 12:print t&[&Loop],:endwhile:waitinput 2000
opt!=(t&[1]+t&[2]+t&[3]+t&[4]+t&[5]+t&[6]+t&[7]+t&[8]+t&[9]+t&[10]+t&[11]+t&[12])/4
min!=1e306:print "\n 15 min Geduld bitte ...\n":tm&=&gettickcount
whileloop 0,3:p&[1]=&Loop:Whileloop 0,3:p&[2]=&Loop:whileloop 0,3:p&[3]=&Loop
whileloop 0,3:p&[4]=&Loop:whileloop 0,3:p&[5]=&Loop:whileloop 0,3:p&[6]=&Loop
whileloop 0,3:p&[7]=&Loop:whileloop 0,3:p&[8]=&Loop:whileloop 0,3:p&[9]=&Loop
whileloop 0,3:p&[10]=&Loop':whileloop 0,3:p&[11]=&Loop
'whileloop 0,3:p&[12]=&Loop
inc n&
z0&=(p&[1]=0)*t&[1]+(p&[2]=0)*t&[2]+(p&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theoretisches Optimum: ";int(opt!+0.999999999)
print "\n ";n&;". Lauf: ";int(min!);" min \n"
p$=translate$(p$," 0,",""):q$=translate$(q$," 0,","")
r$=translate$(r$," 0,",""):s$=translate$(s$," 0,","")
print " ";z0&;": ";left$(p$,len(p$)-1)
print " ";z1&;": ";left$(q$,len(q$)-1)
print " ";z2&;": ";left$(r$,len(r$)-1)
print " ";z3&;": ";left$(s$,len(s$)-1)
case (min!-opt!)<2:goto "hupfraus"
endif
endwhile:endwhile:endwhile:endwhile':endwhile':endwhile
endwhile:endwhile:endwhile:endwhile:endwhile:endwhile
hupfraus:
beep:tm&=&gettickcount-tm&
print "\n ermittelt in ";format$("####0.00 min",tm&/1000/60)
waitkey
end
Alles anzeigen