Compare commits
5 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| bce15fe90f | |||
| 542ce9c8c0 | |||
| 3a3756f701 | |||
|
|
b624cfe11e | ||
| 1b6ad03057 |
@@ -41,10 +41,10 @@ dwelling_times = [
|
|||||||
medium['TempoMédioSistema'].mean(),
|
medium['TempoMédioSistema'].mean(),
|
||||||
high['TempoMédioSistema'].mean()
|
high['TempoMédioSistema'].mean()
|
||||||
]
|
]
|
||||||
plt.bar(['Low', 'Medium', 'High'], dwelling_times, color=['green', 'orange', 'red'])
|
plt.bar(['Baixa', 'Média', 'Alta'], dwelling_times, color=['green', 'orange', 'red'])
|
||||||
plt.ylabel('Average Dwelling Time (s)')
|
plt.ylabel('Tempo Médio no Sistema (s)')
|
||||||
plt.title('System Performance vs Load')
|
plt.title('Desempenho do Sistema vs Carga')
|
||||||
plt.xlabel('Load Scenario')
|
plt.xlabel('Cenário de Carga')
|
||||||
plt.grid(axis='y', alpha=0.3)
|
plt.grid(axis='y', alpha=0.3)
|
||||||
for i, v in enumerate(dwelling_times):
|
for i, v in enumerate(dwelling_times):
|
||||||
plt.text(i, v + 1, f'{v:.2f}s', ha='center', va='bottom')
|
plt.text(i, v + 1, f'{v:.2f}s', ha='center', va='bottom')
|
||||||
@@ -59,10 +59,10 @@ completion_rates = [
|
|||||||
medium['TaxaConclusão'].mean(),
|
medium['TaxaConclusão'].mean(),
|
||||||
high['TaxaConclusão'].mean()
|
high['TaxaConclusão'].mean()
|
||||||
]
|
]
|
||||||
plt.bar(['Low', 'Medium', 'High'], completion_rates, color=['green', 'orange', 'red'])
|
plt.bar(['Baixa', 'Média', 'Alta'], completion_rates, color=['green', 'orange', 'red'])
|
||||||
plt.ylabel('Completion Rate (%)')
|
plt.ylabel('Taxa de Conclusão (%)')
|
||||||
plt.title('Vehicle Completion Rate vs Load')
|
plt.title('Taxa de Conclusão de Veículos vs Carga')
|
||||||
plt.xlabel('Load Scenario')
|
plt.xlabel('Cenário de Carga')
|
||||||
plt.grid(axis='y', alpha=0.3)
|
plt.grid(axis='y', alpha=0.3)
|
||||||
plt.ylim(0, 100)
|
plt.ylim(0, 100)
|
||||||
for i, v in enumerate(completion_rates):
|
for i, v in enumerate(completion_rates):
|
||||||
@@ -78,10 +78,10 @@ waiting_times = [
|
|||||||
medium['TempoMédioEspera'].mean(),
|
medium['TempoMédioEspera'].mean(),
|
||||||
high['TempoMédioEspera'].mean()
|
high['TempoMédioEspera'].mean()
|
||||||
]
|
]
|
||||||
plt.bar(['Low', 'Medium', 'High'], waiting_times, color=['green', 'orange', 'red'])
|
plt.bar(['Baixa', 'Média', 'Alta'], waiting_times, color=['green', 'orange', 'red'])
|
||||||
plt.ylabel('Average Waiting Time (s)')
|
plt.ylabel('Tempo Médio de Espera (s)')
|
||||||
plt.title('Average Waiting Time vs Load')
|
plt.title('Tempo Médio de Espera vs Carga')
|
||||||
plt.xlabel('Load Scenario')
|
plt.xlabel('Cenário de Carga')
|
||||||
plt.grid(axis='y', alpha=0.3)
|
plt.grid(axis='y', alpha=0.3)
|
||||||
for i, v in enumerate(waiting_times):
|
for i, v in enumerate(waiting_times):
|
||||||
plt.text(i, v + 1, f'{v:.2f}s', ha='center', va='bottom')
|
plt.text(i, v + 1, f'{v:.2f}s', ha='center', va='bottom')
|
||||||
@@ -91,44 +91,44 @@ plt.close()
|
|||||||
|
|
||||||
# 4. Gráfico: Summary Statistics
|
# 4. Gráfico: Summary Statistics
|
||||||
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(14, 10))
|
fig, ((ax1, ax2), (ax3, ax4)) = plt.subplots(2, 2, figsize=(14, 10))
|
||||||
loads = ['Low', 'Medium', 'High']
|
loads = ['Baixa', 'Média', 'Alta']
|
||||||
|
|
||||||
# Vehicles generated
|
# Vehicles generated
|
||||||
ax1.bar(loads, [low['VeículosGerados'].mean(), medium['VeículosGerados'].mean(), high['VeículosGerados'].mean()], color=['green', 'orange', 'red'])
|
ax1.bar(loads, [low['VeículosGerados'].mean(), medium['VeículosGerados'].mean(), high['VeículosGerados'].mean()], color=['green', 'orange', 'red'])
|
||||||
ax1.set_title('Vehicles Generated')
|
ax1.set_title('Veículos Gerados')
|
||||||
ax1.set_ylabel('Count')
|
ax1.set_ylabel('Quantidade')
|
||||||
ax1.grid(axis='y', alpha=0.3)
|
ax1.grid(axis='y', alpha=0.3)
|
||||||
|
|
||||||
# Vehicles completed
|
# Vehicles completed
|
||||||
ax2.bar(loads, [low['VeículosCompletados'].mean(), medium['VeículosCompletados'].mean(), high['VeículosCompletados'].mean()], color=['green', 'orange', 'red'])
|
ax2.bar(loads, [low['VeículosCompletados'].mean(), medium['VeículosCompletados'].mean(), high['VeículosCompletados'].mean()], color=['green', 'orange', 'red'])
|
||||||
ax2.set_title('Vehicles Completed')
|
ax2.set_title('Veículos Concluídos')
|
||||||
ax2.set_ylabel('Count')
|
ax2.set_ylabel('Quantidade')
|
||||||
ax2.grid(axis='y', alpha=0.3)
|
ax2.grid(axis='y', alpha=0.3)
|
||||||
|
|
||||||
# Min/Max dwelling time
|
# Min/Max dwelling time
|
||||||
x = range(3)
|
x = range(3)
|
||||||
width = 0.35
|
width = 0.35
|
||||||
ax3.bar([i - width/2 for i in x], [low['TempoMínimoSistema'].mean(), medium['TempoMínimoSistema'].mean(), high['TempoMínimoSistema'].mean()], width, label='Min', color='lightblue')
|
ax3.bar([i - width/2 for i in x], [low['TempoMínimoSistema'].mean(), medium['TempoMínimoSistema'].mean(), high['TempoMínimoSistema'].mean()], width, label='Mín', color='lightblue')
|
||||||
ax3.bar([i + width/2 for i in x], [low['TempoMáximoSistema'].mean(), medium['TempoMáximoSistema'].mean(), high['TempoMáximoSistema'].mean()], width, label='Max', color='darkblue')
|
ax3.bar([i + width/2 for i in x], [low['TempoMáximoSistema'].mean(), medium['TempoMáximoSistema'].mean(), high['TempoMáximoSistema'].mean()], width, label='Máx', color='darkblue')
|
||||||
ax3.set_title('Min/Max Dwelling Time')
|
ax3.set_title('Tempo no Sistema Mín/Máx')
|
||||||
ax3.set_ylabel('Time (s)')
|
ax3.set_ylabel('Tempo (s)')
|
||||||
ax3.set_xticks(x)
|
ax3.set_xticks(x)
|
||||||
ax3.set_xticklabels(loads)
|
ax3.set_xticklabels(loads)
|
||||||
ax3.legend()
|
ax3.legend()
|
||||||
ax3.grid(axis='y', alpha=0.3)
|
ax3.grid(axis='y', alpha=0.3)
|
||||||
|
|
||||||
# Performance summary
|
# Performance summary
|
||||||
metrics = ['Dwelling\nTime', 'Waiting\nTime', 'Completion\nRate']
|
metrics = ['Tempo no\nSistema', 'Tempo de\nEspera', 'Taxa de\nConclusão']
|
||||||
low_vals = [low['TempoMédioSistema'].mean(), low['TempoMédioEspera'].mean(), low['TaxaConclusão'].mean()]
|
low_vals = [low['TempoMédioSistema'].mean(), low['TempoMédioEspera'].mean(), low['TaxaConclusão'].mean()]
|
||||||
med_vals = [medium['TempoMédioSistema'].mean(), medium['TempoMédioEspera'].mean(), medium['TaxaConclusão'].mean()]
|
med_vals = [medium['TempoMédioSistema'].mean(), medium['TempoMédioEspera'].mean(), medium['TaxaConclusão'].mean()]
|
||||||
high_vals = [high['TempoMédioSistema'].mean(), high['TempoMédioEspera'].mean(), high['TaxaConclusão'].mean()]
|
high_vals = [high['TempoMédioSistema'].mean(), high['TempoMédioEspera'].mean(), high['TaxaConclusão'].mean()]
|
||||||
|
|
||||||
x = range(len(metrics))
|
x = range(len(metrics))
|
||||||
width = 0.25
|
width = 0.25
|
||||||
ax4.bar([i - width for i in x], low_vals, width, label='Low', color='green')
|
ax4.bar([i - width for i in x], low_vals, width, label='Baixa', color='green')
|
||||||
ax4.bar(x, med_vals, width, label='Medium', color='orange')
|
ax4.bar(x, med_vals, width, label='Média', color='orange')
|
||||||
ax4.bar([i + width for i in x], high_vals, width, label='High', color='red')
|
ax4.bar([i + width for i in x], high_vals, width, label='Alta', color='red')
|
||||||
ax4.set_title('Performance Summary')
|
ax4.set_title('Resumo de Desempenho')
|
||||||
ax4.set_xticks(x)
|
ax4.set_xticks(x)
|
||||||
ax4.set_xticklabels(metrics)
|
ax4.set_xticklabels(metrics)
|
||||||
ax4.legend()
|
ax4.legend()
|
||||||
|
|||||||
|
Before Width: | Height: | Size: 80 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 82 KiB After Width: | Height: | Size: 90 KiB |
|
Before Width: | Height: | Size: 198 KiB After Width: | Height: | Size: 215 KiB |
|
Before Width: | Height: | Size: 81 KiB After Width: | Height: | Size: 86 KiB |
@@ -40,6 +40,7 @@ import sd.protocol.SocketConnection;
|
|||||||
*/
|
*/
|
||||||
public class ExitNodeProcess {
|
public class ExitNodeProcess {
|
||||||
|
|
||||||
|
// --- Configuration and Networking ---
|
||||||
private final SimulationConfig config;
|
private final SimulationConfig config;
|
||||||
private ServerSocket serverSocket;
|
private ServerSocket serverSocket;
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@ package sd.protocol;
|
|||||||
|
|
||||||
import java.io.Serializable;
|
import java.io.Serializable;
|
||||||
|
|
||||||
import sd.model.MessageType; // Assuming MessageType is in sd.model or sd.protocol
|
import sd.model.MessageType;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Contrato para todas as mensagens trocadas no simulador.
|
* Contrato para todas as mensagens trocadas no simulador.
|
||||||
|
|||||||
@@ -30,9 +30,30 @@ import sd.serialization.SerializerFactory;
|
|||||||
*/
|
*/
|
||||||
public class SocketConnection implements Closeable {
|
public class SocketConnection implements Closeable {
|
||||||
|
|
||||||
|
// --- Network Resources ---
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The underlying TCP socket used for network communication.
|
||||||
|
*/
|
||||||
private final Socket socket;
|
private final Socket socket;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw output stream for writing bytes to the network.
|
||||||
|
* Wrapped by {@link DataOutputStream} during message sending.
|
||||||
|
*/
|
||||||
private final OutputStream outputStream;
|
private final OutputStream outputStream;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The raw input stream for reading bytes from the network.
|
||||||
|
* Wrapped by {@link DataInputStream} during message reception.
|
||||||
|
*/
|
||||||
private final InputStream inputStream;
|
private final InputStream inputStream;
|
||||||
|
|
||||||
|
// --- Serialization ---
|
||||||
|
|
||||||
|
/**
|
||||||
|
* The serializer strategy used to convert objects to/from byte arrays (e.g., JSON).
|
||||||
|
*/
|
||||||
private final MessageSerializer serializer;
|
private final MessageSerializer serializer;
|
||||||
|
|
||||||
/** Número máximo de tentativas de ligação antes de desistir (Fail-fast). */
|
/** Número máximo de tentativas de ligação antes de desistir (Fail-fast). */
|
||||||
@@ -169,7 +190,7 @@ public class SocketConnection implements Closeable {
|
|||||||
}
|
}
|
||||||
|
|
||||||
try {
|
try {
|
||||||
// Lê um prefixo de 4 bytes - indicador de tamanho
|
|
||||||
DataInputStream dataIn = new DataInputStream(inputStream);
|
DataInputStream dataIn = new DataInputStream(inputStream);
|
||||||
int length = dataIn.readInt();
|
int length = dataIn.readInt();
|
||||||
|
|
||||||
|
|||||||