optim blah

% Kybertrike - Kyberpod Loadout Optimization

int: num_systems = 5;
set of int: Systems = 1..num_systems;

% System stats
array[Systems] of string: system_name = [
  “Plasma Rifle”, 
  “Armor Plating”, 
  “Booster”, 
  “Shield”, 
  “Sensor”
];

array[Systems] of int: energy_cost = [5, 3, 8, 6, 2];
array[Systems] of int: mass_cost   = [4, 2, 7, 3, 1];
array[Systems] of int: offense     = [7, 0, 10, 5, 1];
array[Systems] of int: defense     = [0, 6, 2, 8, 1];

% Kyberpod capacity
int: max_energy = 12;
int: max_mass   = 10;

% Decision: equip or not
array[Systems] of var bool: equip;

% Constraints: capacity
constraint sum([energy_cost[s] * bool2int(equip[s]) | s in Systems]) max_energy;
constraint sum([mass_cost[s]   * bool2int(equip[s]) | s in Systems]) max_mass;

% Constraint: must equip at least one weapon system
set of int: Weapons = {1, 3}; % Plasma Rifle, Booster
constraint sum([bool2int(equip[w]) | w in Weapons]) >= 1;

% Derived values
var int: total_offense = sum([offense[s] * bool2int(equip[s]) | s in Systems]);
var int: total_defense = sum([defense[s] * bool2int(equip[s]) | s in Systems]);
var int: used_energy   = sum([energy_cost[s] * bool2int(equip[s]) | s in Systems]);
var int: used_mass     = sum([mass_cost[s]   * bool2int(equip[s]) | s in Systems]);

% Objective
solve maximize total_offense + total_defense;

output [
  ”= Kyberpod Loadout Optimization =\n”,
  “Equipped Systems: ”, 
    show([system_name[s] | s in Systems where fix(equip[s])]), “\n\n”,
  ”⚡ Energy Usage: ”, show(used_energy), ”/”, show(max_energy), “\n”,
  ”⚙ Mass Usage:   ”, show(used_mass), ”/”, show(max_mass), “\n\n”,
  ”🔫 Offense: ”, show(total_offense), “\n”,
  ”🛡 Defense: ”, show(total_defense), “\n”,
  ”✨ Total Power: ”, show(total_offense + total_defense), “\n”,
  ”=====================================\n”
];