isLoggedIn() || !$auth->isAdmin()) {
header('Location: login.php');
exit;
}
$currentUser = $auth->getCurrentUser();
$db = Database::getInstance();
// ONLY RESET STUCK RUNNING STATE - PRESERVE PROGRESS
try {
// Reset ONLY the running flag, preserve all progress data
$db->query("UPDATE optimization_analysis_state SET is_running = 0, should_pause = 0 WHERE is_running = 1");
// Ensure we have an analysis state record but don't reset progress
$stateCheck = $db->query("SELECT COUNT(*) as count FROM optimization_analysis_state");
if ($stateCheck && $stateCheck->fetch_assoc()['count'] == 0) {
// Only create if doesn't exist, don't reset existing progress
$db->query("INSERT INTO optimization_analysis_state (total_combinations, processed_combinations, is_running, started_at, should_pause) VALUES (0, 0, 0, NOW(), 0)");
}
} catch (Exception $e) {
// Ignore errors - table might not exist yet
}
// Get current statistics
$stats = [];
try {
// Total directives
$totalResult = $db->query("SELECT COUNT(*) as count FROM panel_directives");
$stats['total'] = $totalResult ? $totalResult->fetch_assoc()['count'] : 0;
// Processed directives
$processedResult = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1");
$stats['processed'] = $processedResult ? $processedResult->fetch_assoc()['count'] : 0;
// Impossible combinations
$impossibleResult = $db->query("SELECT COUNT(*) as count FROM panel_directives WHERE llm_checked = 1 AND is_impossible = 1");
$stats['impossible'] = $impossibleResult ? $impossibleResult->fetch_assoc()['count'] : 0;
// Progress percentage
$stats['progress'] = $stats['total'] > 0 ? ($stats['processed'] / $stats['total']) * 100 : 0;
} catch (Exception $e) {
$stats = ['total' => 0, 'processed' => 0, 'impossible' => 0, 'progress' => 0];
}
// Get recent impossible combinations for display (analyzed only)
$impossibleCombinations = [];
try {
// Only get combinations that have been analyzed and found impossible
$impossibleQuery = $db->query("
SELECT
id,
attribute1_name,
choice1,
attribute2_name,
choice2,
status,
llm_reasoning,
updated_at
FROM panel_directives
WHERE llm_checked = 1 AND is_impossible = 1
ORDER BY updated_at DESC
LIMIT 50
");
if ($impossibleQuery) {
while ($row = $impossibleQuery->fetch_assoc()) {
$impossibleCombinations[] = $row;
}
}
} catch (Exception $e) {
// Ignore errors
}
?>
Total Combinations
Demographic combinations to analyze
Analyzed
Combinations processed by AI
Impossible Found
Unrealistic combinations identified
Optimization Rate
0 ? number_format(($stats['impossible'] / $stats['total']) * 100, 1) : '0'; ?>%
Panel accuracy improvement
Click "Start Analysis" to begin AI-powered demographic combination analysis.
Note: Generate combination directives first in the Base section.
Ready to analyze remaining combinations.
π§ OptimAIze interface loaded and ready
Directive ID
Impossible Combination Detail
Status
Actions
OPT-
=
+
=
100 ? '...' : ''; ?>
β Approved
β Declined
Approve
Decline
No impossible combinations found yet. Start analysis to discover unrealistic demographic combinations.