<?php /** * @ASCOOS-NAME : Ascoos OS * @ASCOOS-VERSION : 26.0.0 * @ASCOOS-SUPPORT : [email protected] * @ASCOOS-BUGS : https://issues.ascoos.com * * @desc <English> Learns from system history and composes optimal macro workflows using neural networks. * @desc <Greek> ???????? ??? ?? ???????? ??? ?????????? ??? ???????? ????????? ???????????? ?? ????? ?????????? ???????. * * @since PHP 8.2.0 */ declare(strict_types=1); use ASCOOS\OS\Kernel\AI\NeuralNet\TNeuralNetworkHandler; use ASCOOS\OS\Kernel\Arrays\Macros\TMacroHandler; // ? ???????? ???????? ?????????? $systemData = [ [0.2, 0.8, 0.5], // CPU, RAM, Disk [0.9, 0.1, 0.3], [0.4, 0.6, 0.7] ]; $actions = [1, 0, 1]; // 1 = ???????? macro, 0 = ????????? // ? ?????????? ??????? $composer = new TNeuralNetworkHandler(); $composer->compile([ ['input' => 3, 'output' => 4, 'activation' => 'relu'], ['input' => 4, 'output' => 1, 'activation' => 'sigmoid'] ]); $composer->fit($systemData, $actions, epochs: 1000, lr: 0.01); // ? ???????? ????????? ?????????? $currentState = [0.6, 0.7, 0.4]; // ? ???????? ???????? ????????? $score = $composer->predictNetwork([$currentState])[0]; // ? ???????? macro ?? ? ???????? ????? ?????? if ($score > 0.5) { $macroHandler = new TMacroHandler(); $macroHandler->addMacro(fn() => print("? Executing optimized macro"), [], delay: 0, priority: 1); $macroHandler->runNext(); } else { print("?? Macro skipped based on neural prediction\n"); } |