= REQ['load_N'] and m['temp_ok']\n return dict(unit=round(unit_cost,2), days=round(days,1),\n feasible=feasible, strength_ok=strength_ok, notes=notes)\n\nfor pair in [('Al6061','cnc'), ('PLA','fdm'), ('ABS','molding')]:\n print(pair, estimate(*pair))","label":"2 — Deterministic estimator"},{"code":"# EDIT: your chosen pairing, and >= 2 alternatives each with the axis it LOSES on.\nchoice = ('ABS', 'molding')\njustify = [ # (material, process, losing_axis in {'cost','strength','count','lead'})\n ('Al6061', 'cnc', 'cost'),\n ('PLA', 'fdm', 'strength'),\n]\ne = estimate(*choice)\nprint('chosen', choice, '->', e)","label":"3 — Your choice + justification"},{"code":"def meets(material, process):\n e = estimate(material, process)\n weeks = e['days']/5.0\n return (e['feasible'] and e['strength_ok'] and\n e['unit'] <= REQ['cost_target'] and weeks <= REQ['lead_weeks']), e, weeks\n\nok, e, weeks = meets(*choice)\nproblems = []\nif not ok:\n if not e['strength_ok']: problems.append(f'{choice[0]} fails strength/temp for the 40 N + outdoor requirement.')\n if e['unit'] > REQ['cost_target']: problems.append(f'unit ${e[\"unit\"]} > ${REQ[\"cost_target\"]} target at 5,000 count.')\n if weeks > REQ['lead_weeks']: problems.append(f'lead {weeks:.1f} wk > {REQ[\"lead_weeks\"]} wk.')\n# validate justification: >=2 alternatives, each truly losing on its named axis\naxis_val = {'cost': lambda x: x['unit'], 'strength': lambda x: 0 if x['strength_ok'] else 1}\njok = len(justify) >= 2\nfor mat, proc, axis in justify:\n a = estimate(mat, proc)\n if axis == 'cost' and not (a['unit'] > e['unit']): jok = False; problems.append(f'{mat}+{proc} does not actually lose on cost.')\n if axis == 'strength' and a['strength_ok']: jok = False; problems.append(f'{mat}+{proc} does not actually lose on strength.')\n\nif ok and jok and not problems:\n print(f'PASS - {choice[0]}+{choice[1]} meets all four lines (unit ${e[\"unit\"]}, strength OK, '\n f'lead {weeks:.1f} wk). You beat 2 alternatives on their losing axes. A defended pairing.')\nelse:\n print('FAIL - ' + ' '.join(problems[:2] if problems else ['Need >= 2 alternatives, each with a real losing axis.']))","label":"4 — Autograder (seed 1102)"}],"intro":"The twin's cost/time/feasibility model is a deterministic function of (material, process, count, geometry); here it is in numpy. Edit your chosen pairing and run.","key":"manufacturing/choosing-material-and-process","kind":"python","title":"Choosing a material and a process"}">
PYTHON · NUMPY · IN-BROWSER

Choosing a material and a process

The twin's cost/time/feasibility model is a deterministic function of (material, process, count, geometry); here it is in numpy. Edit your chosen pairing and run.