Gab AI · research example

Inspect the feasible options. Reproduce the optimum.

An executed twelve-combination model. Compare a stated capacity scenario and inspect the code; the result is conditional on inputs.

INTEGER ALLOCATION / TWO OPTIONScoefficients

A resource limit. A choice you can explain.

Best feasible choice1 A + 2 B
Supplied value points13
Staff · 8 / 8 hours
Materials · 11 / 12 units

Eight feasible pairs out of twelve. The staff limit binds; one material unit remains.

ABStaff hMaterialPointsConstraint check

Points are supplied priorities, not revenue or measured impact. Extra capacity is an assumption.

Inspect the runnable enumerator
/* ALLOCATION CORE START */
const options = [{"name": "A", "staff": 4, "material": 3, "value": 5, "maximum": 2}, {"name": "B", "staff": 2, "material": 4, "value": 4, "maximum": 3}];
function enumerateAllocation(staffCapacity, materialCapacity) {
  if (!Number.isSafeInteger(staffCapacity) || !Number.isSafeInteger(materialCapacity) || staffCapacity < 0 || materialCapacity < 0) throw new TypeError('Resource capacities must be nonnegative safe integers.');
  const pairs = [];
  for (let a = 0; a <= options[0].maximum; a++) for (let b = 0; b <= options[1].maximum; b++) {
    const staff = a * options[0].staff + b * options[1].staff;
    const material = a * options[0].material + b * options[1].material;
    const value = a * options[0].value + b * options[1].value;
    const feasible = staff <= staffCapacity && material <= materialCapacity;
    const reason = feasible ? 'Feasible' : staff > staffCapacity && material > materialCapacity ? 'Both limits' : staff > staffCapacity ? 'Staff limit' : 'Material limit';
    pairs.push({a, b, staff, material, value, feasible, reason});
  }
  const feasible = pairs.filter(pair => pair.feasible);
  const maximum = Math.max(...feasible.map(pair => pair.value));
  return {pairs, feasible, best: feasible.filter(pair => pair.value === maximum), maximum};
}
/* ALLOCATION CORE END */