Fuzzy Inference System Tsukamoto

Saya menemukan FIS yang cukup bagus yang dishare Rizal Ardhi Rahmadani di https://github.com/reyzeal/fuzzy

berikut contoh penggunaannya :

use Reyzeal\Fuzzy;

$fuzzy = new Fuzzy(“Penerimaan SNMPTN”,”Tsukamoto”);

$fuzzy->input()-> addCategory(‘Alumni’)
-> addMembership(‘Sedikit’,”trapmf”,[0,0,40,1])
-> addMembership(‘Banyak’,”trapmf”,[40,60,1,1]);

$fuzzy->input()-> addCategory(‘UN’)
-> addMembership(‘Rendah’,”trapmf”,[0,0,30,50])
-> addMembership(‘Sedang’,”trapmf”,[40,60,70,90])
-> addMembership(‘Tinggi’,”trapmf”,[75,85,1,1]);

$fuzzy->output()-> addCategory(‘Diterima’)
-> addMembership(‘Sedikit’,”trapmf”,[0,0,10,20])
-> addMembership(‘Sedang’,”trapmf”,[10,40,50,60])
-> addMembership(‘Banyak’,”trapmf”,[50,80,1,1]);

$fuzzy->rules()-> add(‘Alumni_Sedikit AND UN_Rendah’) -> then(‘Diterima_Sedikit’);
$fuzzy->rules()-> add(‘Alumni_Sedikit AND UN_Tinggi’) -> then(‘Diterima_Sedang’);
$fuzzy->rules()-> add(‘Alumni_Banyak AND UN_Tinggi’) -> then(‘Diterima_Banyak’);

print_r($fuzzy -> calc([‘Alumni’ => 90,’UN’ => 80]));

Tetapi code awal hanya dapat digunakan untuk logika if xxxx and xxxx then zzzz
untuk keperluan tiga kondisi semisal if aaaa and bbbb and cccc then xxxxx maka kita perlu modifikasi kode awal.

use Reyzeal\Fuzzy;

$fuzzy = new Fuzzy(“Kualitas_Layanan”,”Tsukamoto”);

$fuzzy->input()-> addCategory(‘Persepsi’)
-> addMembership(‘STP’,”limf”,[1,2])
-> addMembership(‘TP’,”trimf”,[1,2,3])
-> addMembership(‘CP’,”trimf”,[2,3,4])
-> addMembership(‘P’,”trimf”,[3,4,5])
-> addMembership(‘SP’,”rimf”,[4,5]);

$fuzzy->input()-> addCategory(‘Minimum’)
-> addMembership(‘STP’,”limf”,[1,2])
-> addMembership(‘TP’,”trimf”,[1,2,3])
-> addMembership(‘CP’,”trimf”,[2,3,4])
-> addMembership(‘P’,”trimf”,[3,4,5])
-> addMembership(‘SP’,”rimf”,[4,5]);

$fuzzy->input()-> addCategory(‘Ideal’)
-> addMembership(‘STP’,”limf”,[1,2])
-> addMembership(‘TP’,”trimf”,[1,2,3])
-> addMembership(‘CP’,”trimf”,[2,3,4])
-> addMembership(‘P’,”trimf”,[3,4,5])
-> addMembership(‘SP’,”rimf”,[4,5]);

$fuzzy->output()-> addCategory(‘Kualitas’)
-> addMembership(‘STP’,”limf”,[1,2])
-> addMembership(‘TP’,”trimf”,[1,2,3])
-> addMembership(‘CP’,”trimf”,[2,3,4])
-> addMembership(‘P’,”trimf”,[3,4,5])
-> addMembership(‘SP’,”rimf”,[4,5]);

$fuzzy->rules()
-> add(‘Persepsi_STP AND Minimum_STP AND Ideal_STP’)
-> then(‘Kualitas_STP’);
$fuzzy->rules()
-> add(‘Persepsi_TP AND Minimum_TP AND Ideal_TP’)
-> then(‘Kualitas_TP’);
$fuzzy->rules()
-> add(‘Persepsi_CP AND Minimum_CP AND Ideal_CP’)
-> then(‘Kualitas_CP’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_P AND Ideal_P’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_SP AND Minimum_SP AND Ideal_SP’)
-> then(‘Kualitas_SP’);
$fuzzy->rules()
-> add(‘Persepsi_STP AND Minimum_STP AND Ideal_STP’)
-> then(‘Kualitas_STP’);
$fuzzy->rules()
-> add(‘Persepsi_TP AND Minimum_STP AND Ideal_STP’)
-> then(‘Kualitas_TP’);
$fuzzy->rules()
-> add(‘Persepsi_STP AND Minimum_TP AND Ideal_STP’)
-> then(‘Kualitas_TP’);
$fuzzy->rules()
-> add(‘Persepsi_TP AND Minimum_CP AND Ideal_CP’)
-> then(‘Kualitas_TP’);
$fuzzy->rules()
-> add(‘Persepsi_CP AND Minimum_TP AND Ideal_CP’)
-> then(‘Kualitas_CP’);
$fuzzy->rules()
-> add(‘Persepsi_CP AND Minimum_CP AND Ideal_TP’)
-> then(‘Kualitas_CP’);
$fuzzy->rules()
-> add(‘Persepsi_CP AND Minimum_P AND Ideal_P’)
-> then(‘Kualitas_CP’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_CP AND Ideal_P’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_P AND Ideal_CP’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_SP AND Ideal_SP’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_SP AND Minimum_P AND Ideal_SP’)
-> then(‘Kualitas_SP’);
$fuzzy->rules()
-> add(‘Persepsi_SP AND Minimum_SP AND Ideal_P’)
-> then(‘Kualitas_SP’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_CP AND Ideal_CP’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_CP AND Minimum_CP AND Ideal_P’)
-> then(‘Kualitas_CP’);
$fuzzy->rules()
-> add(‘Persepsi_CP AND Minimum_P AND Ideal_CP’)
-> then(‘Kualitas_CP’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_TP AND Ideal_P’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_SP AND Ideal_P’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_P AND Minimum_P AND Ideal_SP’)
-> then(‘Kualitas_P’);
$fuzzy->rules()
-> add(‘Persepsi_STP AND Minimum_P AND Ideal_P’)
-> then(‘Kualitas_STP’);
$fuzzy->rules()
-> add(‘Persepsi_TP AND Minimum_P AND Ideal_P’)
-> then(‘Kualitas_TP’);

$z = $fuzzy -> calc([
‘Persepsi’ => 3.67,
‘Minimum’ => 2.20,
‘Ideal’ => 3.40
]);