penjadwalan-ga/app/Services/Scheduling/Gene.php

48 lines
1.1 KiB
PHP

<?php
namespace App\Services\Scheduling;
use App\Services\Scheduling\Data\SchedulingSlot;
/**
* Gene merepresentasikan 1 alokasi sesi kelas dalam Algoritma Genetika.
*
* Untuk kelas 1x/minggu: ada 1 Gene (indexPertemuan = 1)
* Untuk kelas 2x/minggu: ada 2 Gene (indexPertemuan = 1 dan indexPertemuan = 2)
*/
class Gene
{
public function __construct(
public readonly int $kelasId,
public readonly int $indexPertemuan, // 1 atau 2
public int $guruId,
public int $hariId,
public int $sesiId,
public int $ruanganId
) {
}
/**
* Mengembalikan SchedulingSlot (kombinasi Hari & Sesi) dari gen ini.
*/
public function getSlot(): SchedulingSlot
{
return new SchedulingSlot($this->hariId, $this->sesiId);
}
/**
* Kloning gen untuk keperluan individu baru
*/
public function clone(): self
{
return new self(
$this->kelasId,
$this->indexPertemuan,
$this->guruId,
$this->hariId,
$this->sesiId,
$this->ruanganId
);
}
}