77 lines
3.5 KiB
PHP
77 lines
3.5 KiB
PHP
<?php
|
|
|
|
namespace App\Exports;
|
|
|
|
use Maatwebsite\Excel\Concerns\FromCollection;
|
|
use Maatwebsite\Excel\Concerns\WithTitle;
|
|
use Maatwebsite\Excel\Concerns\WithHeadings;
|
|
use Maatwebsite\Excel\Concerns\WithStyles;
|
|
use Maatwebsite\Excel\Concerns\ShouldAutoSize;
|
|
use PhpOffice\PhpSpreadsheet\Worksheet\Worksheet;
|
|
use Illuminate\Support\Collection;
|
|
|
|
class GaSummarySheet implements FromCollection, WithTitle, WithHeadings, WithStyles, ShouldAutoSize
|
|
{
|
|
protected array $gaResult;
|
|
|
|
public function __construct(array $gaResult)
|
|
{
|
|
$this->gaResult = $gaResult;
|
|
}
|
|
|
|
public function title(): string
|
|
{
|
|
return '1. Ringkasan & Parameter';
|
|
}
|
|
|
|
public function headings(): array
|
|
{
|
|
return [
|
|
['SIMULASI & METRIK EVALUASI ALGORITMA GENETIKA (GA)'],
|
|
['LKP ROBOTKU - SISTEM PENJADWALAN OTOMATIS'],
|
|
[],
|
|
['Parameter / Metrik Engine', 'Nilai Evaluasi', 'Keterangan'],
|
|
];
|
|
}
|
|
|
|
public function collection(): Collection
|
|
{
|
|
$best = $this->gaResult['bestChromosome'] ?? null;
|
|
$fitness = $best ? $best->fitness : 0;
|
|
$penalty = $best ? $best->totalPenalty : 0;
|
|
|
|
$data = [
|
|
['Status Optimal', $fitness == 1.0 ? 'SUKSES (FITNESS OPTIMAL 1.0)' : 'TERCAPAI BATAS MAX GENERASI', 'Tidak ada bentrok jadwal (Total Penalti = 0)'],
|
|
['Nilai Fitness Terbaik', $fitness, 'Dihitung dengan rumus: 1 / (1 + Total Penalti)'],
|
|
['Total Penalti Aturan Batasan (Constraints)', $penalty, 'Jumlah total pelanggaran aturan B1 s.d B7'],
|
|
['Jumlah Generasi Ditempuh', $this->gaResult['generations'] ?? 0, 'Iterasi siklus seleksi, crossover, & mutasi'],
|
|
['Waktu Eksekusi (Execution Time)', ($this->gaResult['executionTime'] ?? 0) . ' Detik', 'Waktu komputasi engine GA'],
|
|
['Penggunaan Memori (Memory Usage)', ($this->gaResult['memoryUsage'] ?? 0) . ' KB', 'Penggunaan RAM server'],
|
|
[],
|
|
['RINCIAN BREAKDOWN PENALTI TERDETEKSI (BEST SOLUTION)', '', ''],
|
|
['B1 : Bentrok Guru', $best->penaltyBreakdown['B1'] ?? 0, 'Guru mengajar >1 kelas di (Hari, Sesi) sama'],
|
|
['B2 : Bentrok Ruangan LKP', $best->penaltyBreakdown['B2'] ?? 0, 'Ruangan dipakai >1 kelas di (Hari, Sesi) sama'],
|
|
['B3 : Ketersediaan Guru', $best->penaltyBreakdown['B3'] ?? 0, 'Guru diplot di jam ketidaktersediaannya'],
|
|
['B4 : Bentrok Kelompok Kelas', $best->penaltyBreakdown['B4'] ?? 0, '1 Kelas diplot di 2 tempat di jam sama'],
|
|
['B5 : Kualifikasi Level Guru', $best->penaltyBreakdown['B5'] ?? 0, 'Level maks guru < level kelas'],
|
|
['B6 : Sebaran Hari (2x/minggu)', $best->penaltyBreakdown['B6'] ?? 0, 'Hari sama atau selisih hari < 2 hari'],
|
|
['B7 : Konsistensi Guru (2x/minggu)', $best->penaltyBreakdown['B7'] ?? 0, 'Guru pertemuan 1 & 2 berbeda'],
|
|
];
|
|
|
|
return new Collection($data);
|
|
}
|
|
|
|
public function styles(Worksheet $sheet)
|
|
{
|
|
$sheet->mergeCells('A1:C1');
|
|
$sheet->mergeCells('A2:C2');
|
|
$sheet->getStyle('A1:A2')->getFont()->setBold(true)->setSize(12);
|
|
$sheet->getStyle('A4:C4')->getFont()->setBold(true);
|
|
$sheet->getStyle('A4:C4')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('E2E8F0');
|
|
$sheet->getStyle('A11:C11')->getFont()->setBold(true);
|
|
$sheet->getStyle('A11:C11')->getFill()->setFillType(\PhpOffice\PhpSpreadsheet\Style\Fill::FILL_SOLID)->getStartColor()->setARGB('CBD5E1');
|
|
|
|
return [];
|
|
}
|
|
}
|