Skip to content

Package: SimulationsErgebnis

SimulationsErgebnis

nameinstructionbranchcomplexitylinemethod
SimulationsErgebnis(PruefErgebnis, Map, Map, Map, Collection)
M: 0 C: 18
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 7
100%
M: 0 C: 1
100%
builder()
M: 0 C: 2
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
compareMaschinenauslastung(SimulationsErgebnis)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
compareMitarbeiterauslastung(SimulationsErgebnis)
M: 0 C: 16
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 5
100%
M: 0 C: 1
100%
compareSLA(SimulationsErgebnis)
M: 0 C: 18
100%
M: 0 C: 2
100%
M: 0 C: 2
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
compareTo(SimulationsErgebnis)
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
compareVerbrauchteZeit(SimulationsErgebnis)
M: 0 C: 8
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
equals(Object)
M: 5 C: 46
90%
M: 8 C: 8
50%
M: 8 C: 1
11%
M: 2 C: 8
80%
M: 0 C: 1
100%
erzeugeKalendereintraege()
M: 0 C: 5
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getAuslastungProMaschine()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getAuslastungProMitarbeiter()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getGesamtAuslastung(Collection)
M: 0 C: 10
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 2
100%
M: 0 C: 1
100%
getGesamtAuslastungDerMaschinen()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getGesamtAuslastungDerMitarbeiter()
M: 0 C: 6
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getGesamteVerbrauchteZeit()
M: 0 C: 9
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 4
100%
M: 0 C: 1
100%
getNichtEingehalteneSlas()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getPruefErgebnis()
M: 0 C: 3
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
getVerbrauchteZeitProProduktionsAuftrag()
M: 0 C: 4
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
hashCode()
M: 0 C: 29
100%
M: 0 C: 0
100%
M: 0 C: 1
100%
M: 0 C: 1
100%
M: 0 C: 1
100%

Coverage

1: package simulation;
2:
3: import auftraege.Dokumentenklasse;
4: import auftraege.ProduktionsAuftrag;
5: import maschine.Maschine;
6: import mensch.Mitarbeiter;
7: import simulation.SimulationsHelper.Auslastung;
8: import simulation.SimulationsHelper.SimulationsKonstanten;
9: import tec.uom.se.ComparableQuantity;
10: import util.Fraction;
11: import util.Immutable;
12:
13: import javax.measure.quantity.Time;
14: import java.util.Collection;
15: import java.util.Collections;
16: import java.util.Map;
17: import java.util.Objects;
18:
19:
20: /**
21: * Ergebnis des Simulationsalgorithmus.
22: */
23: @Immutable
24: public final class SimulationsErgebnis implements Comparable<SimulationsErgebnis> {
25:         
26:         private final PruefErgebnis pruefErgebnis;
27:         private final Map<ProduktionsAuftrag, ComparableQuantity<Time>> verbrauchteZeitProProduktionsAuftrag;
28:         private final Map<Maschine, Auslastung> auslastungProMaschine;
29:         private final Map<Mitarbeiter, Auslastung> auslastungProMitarbeiter;
30:         private final Collection<Dokumentenklasse> nichtEingehalteneSlas;
31:         
32:         /**
33:          * Konstruktor mit allen Parametern.
34:          * @param pruefErgebnis das PruefErgebnis nach welchem simuliert wurde
35:          * @param verbrauchteZeitProProduktionsAuftrag verbrauchteZeitProProduktionsAuftrag
36:          * @param auslastungProMaschine auslastungProMaschine
37:          * @param auslastungProMitarbeiter auslastungProMitarbeiter
38:          * @param nichtEingehalteneSlas nichtEingehalteneSlas
39:          */
40:         SimulationsErgebnis(final PruefErgebnis pruefErgebnis,
41:                         final Map<ProduktionsAuftrag, ComparableQuantity<Time>> verbrauchteZeitProProduktionsAuftrag,
42:                         final Map<Maschine, Auslastung> auslastungProMaschine,
43:                         final Map<Mitarbeiter, Auslastung> auslastungProMitarbeiter,
44:                         final Collection<Dokumentenklasse> nichtEingehalteneSlas) {
45:                 this.pruefErgebnis = pruefErgebnis;
46:                 this.verbrauchteZeitProProduktionsAuftrag = verbrauchteZeitProProduktionsAuftrag;
47:                 this.auslastungProMaschine = auslastungProMaschine;
48:                 this.auslastungProMitarbeiter = auslastungProMitarbeiter;
49:                 this.nichtEingehalteneSlas = nichtEingehalteneSlas;
50:         }
51:         
52:         /**
53:          *
54:          * @return Builder, um das Simulationsergebnis komfortabler erstellen zu können.
55:          */
56:         static SimulationsErgebnisBuilder builder() {
57:                 return SimulationsErgebnisBuilder.create();
58:         }
59:         
60:         /**
61:          *
62:          * @return PruefErgebnis
63:          */
64:         public PruefErgebnis getPruefErgebnis() {
65:                 return this.pruefErgebnis;
66:         }
67:         
68:         /**
69:          *
70:          * @return verbrauchteZeitProProduktionsAuftrag read-only
71:          */
72:         public Map<ProduktionsAuftrag, ComparableQuantity<Time>> getVerbrauchteZeitProProduktionsAuftrag() {
73:                 return Collections.unmodifiableMap(this.verbrauchteZeitProProduktionsAuftrag);
74:         }
75:         /**
76:          *
77:          * @return auslastungProMaschine read-only
78:          */
79:         public Map<Maschine, Auslastung> getAuslastungProMaschine() {
80:                 return Collections.unmodifiableMap(this.auslastungProMaschine);
81:         }
82:         
83:         /**
84:          *
85:          * @return auslastungProMitarbeiter read-only
86:          */
87:         public Map<Mitarbeiter, Auslastung> getAuslastungProMitarbeiter() {
88:                 return Collections.unmodifiableMap(this.auslastungProMitarbeiter);
89:         }
90:         
91:         /**
92:          *
93:          * @return getNichtEingehalteneSlas read-only
94:          */
95:         public Collection<Dokumentenklasse> getNichtEingehalteneSlas() {
96:                 return Collections.unmodifiableCollection(this.nichtEingehalteneSlas);
97:         }
98:         
99:         /**
100:          * derived.
101:          * @return gesamtAuslastungDerMitarbeiter als Bruch (1/2 --> 50 %)
102:          */
103:         public Fraction getGesamtAuslastungDerMitarbeiter() {
104:                 return this.getGesamtAuslastung(this.auslastungProMitarbeiter.values());
105:         }
106:         
107:         /**
108:          * derived.
109:          * @return gesamtAuslastungDerMaschinen als Bruch (1/2 --> 50 %)
110:          */
111:         public Fraction getGesamtAuslastungDerMaschinen() {
112:                 return this.getGesamtAuslastung(this.auslastungProMaschine.values());
113:         }
114:         
115:         private Fraction getGesamtAuslastung(final Collection<Auslastung> values) {
116:                 final Auslastung aggregierteAuslastung = values.stream().reduce(Auslastung.NEUTRAL_AUSLASTUNG, Auslastung::add);
117:                 return aggregierteAuslastung.asFraction();
118:         }
119:         
120:         /**
121:          * derived.
122:          * @return gesamteVerbrauchteZeit für die Bearbeitung aller Produktionsauftraege.
123:          */
124:         public ComparableQuantity<Time> getGesamteVerbrauchteZeit() {
125:                 return this.verbrauchteZeitProProduktionsAuftrag
126:                                 .values()
127:                                 .stream()
128:                                 .reduce(SimulationsKonstanten.NEUTRALE_ZEIT, ComparableQuantity::add);
129:         }
130:         
131:         @Override
132:         public int compareTo(final SimulationsErgebnis o) {
133:                 return this.compareSLA(o);
134:         }
135:         
136:         /**
137:          * Vergleicht Simulationsergebnisse mit höchster Priorität auf der Anzahl nicht eingehaltener SLAs. Je weniger
138:          * nichtEingehalteneSLAs, desto besser.
139:          *
140:          * @param o
141:          * das zu vergleichende SimulationsErgebnis
142:          * @return Ergebnis des Vergleichs nach dem compareTo-Schema. Größer = Besser.
143:          */
144:         private int compareSLA(final SimulationsErgebnis o) {
145:                 final int compareSLA = Integer.compare(this.nichtEingehalteneSlas.size(), o.getNichtEingehalteneSlas().size()) * -1;
146:•                if (compareSLA == 0) {
147:                         return this.compareMaschinenauslastung(o);
148:                 } else {
149:                         return compareSLA;
150:                 }
151:         }
152:         
153:         /**
154:          * Vergleicht Simulationsergebnisse mit höchster Priorität auf der Maschinenauslastung. Je niedriger die Auslastung, desto besser.
155:          *
156:          * @param o
157:          * das zu vergleichende SimulationsErgebnis
158:          * @return Ergebnis des Vergleichs nach dem compareTo-Schema. Größer = Besser.
159:          */
160:         private int compareMaschinenauslastung(final SimulationsErgebnis o) {
161:                 final int compareMaschinenauslastung =
162:                                 this.getGesamtAuslastungDerMaschinen().compareTo(o.getGesamtAuslastungDerMaschinen()) * -1;
163:•                if (compareMaschinenauslastung == 0) {
164:                         return this.compareMitarbeiterauslastung(o);
165:                 } else {
166:                         return compareMaschinenauslastung;
167:                 }
168:         }
169:         
170:         /**
171:          * Vergleicht Simulationsergebnisse mit höchster Priorität auf der Mitarbeiterauslastung. Je niedriger die Auslastung, desto besser.
172:          *
173:          * @param o
174:          * das zu vergleichende SimulationsErgebnis
175:          * @return Ergebnis des Vergleichs nach dem compareTo-Schema. Größer = Besser.
176:          */
177:         private int compareMitarbeiterauslastung(final SimulationsErgebnis o) {
178:                 final int compareMitarbeiterauslastung =
179:                                 this.getGesamtAuslastungDerMitarbeiter().compareTo(o.getGesamtAuslastungDerMitarbeiter()) * -1;
180:•                if (compareMitarbeiterauslastung == 0) {
181:                         return this.compareVerbrauchteZeit(o);
182:                 } else {
183:                         return compareMitarbeiterauslastung;
184:                 }
185:         }
186:         
187:         /**
188:          * Vergleicht Simulationsergebnisse mit höchster Priorität auf der VerbrauchtenZeit. Je geringer die Verbrauchte
189:          * Zeit, desto besser.
190:          *
191:          * @param o
192:          * das zu vergleichende SimulationsErgebnis
193:          * @return Ergebnis des Vergleichs nach dem compareTo-Schema. Größer = Besser.
194:          */
195:         private int compareVerbrauchteZeit(final SimulationsErgebnis o) {
196:                 return this.getGesamteVerbrauchteZeit().compareTo(o.getGesamteVerbrauchteZeit()) * -1;
197:         }
198:         
199:         /**
200:          * Erzeugt auf Basis der ermittelten Belegungen des {@link PruefErgebnis PruefErgebnises} die zum {@link SimulationsErgebnis} gehörenden
201:          * Kalendereinträge.
202:          */
203:         public void erzeugeKalendereintraege() {
204:                 this.pruefErgebnis.getGepruefteBelegungen().erzeugeKalendereintraege();
205:         }
206:         
207:         // Man kann darüber nachdenken eine Operation getUngenutztesMaterial() zu programmieren.
208:         
209:         @Override
210:         public boolean equals(final Object o) {
211:•                if (this == o) {
212:                         return true;
213:                 }
214:•                if (o == null || this.getClass() != o.getClass()) {
215:                         return false;
216:                 }
217:                 final SimulationsErgebnis that = (SimulationsErgebnis) o;
218:•                return Objects.equals(this.pruefErgebnis, that.pruefErgebnis)
219:•                                && Objects.equals(this.verbrauchteZeitProProduktionsAuftrag, that.verbrauchteZeitProProduktionsAuftrag)
220:•                                && Objects.equals(this.auslastungProMaschine, that.auslastungProMaschine)
221:•                                && Objects.equals(this.auslastungProMitarbeiter, that.auslastungProMitarbeiter)
222:•                                && Objects.equals(this.nichtEingehalteneSlas, that.nichtEingehalteneSlas);
223:         }
224:         
225:         @Override
226:         public int hashCode() {
227:                 return Objects.hash(this.pruefErgebnis,
228:                                 this.verbrauchteZeitProProduktionsAuftrag,
229:                                 this.auslastungProMaschine,
230:                                 this.auslastungProMitarbeiter,
231:                                 this.nichtEingehalteneSlas);
232:         }
233: }