equilibria-mcp-server 1.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (164) hide show
  1. package/CHANGELOG.md +142 -0
  2. package/LICENSE +21 -0
  3. package/README.md +240 -0
  4. package/dist/builders/YAMLBuilder.d.ts +77 -0
  5. package/dist/builders/YAMLBuilder.d.ts.map +1 -0
  6. package/dist/builders/YAMLBuilder.js +251 -0
  7. package/dist/builders/YAMLBuilder.js.map +1 -0
  8. package/dist/economics/constants.d.ts +39 -0
  9. package/dist/economics/constants.d.ts.map +1 -0
  10. package/dist/economics/constants.js +46 -0
  11. package/dist/economics/constants.js.map +1 -0
  12. package/dist/economics/formulas.d.ts +19 -0
  13. package/dist/economics/formulas.d.ts.map +1 -0
  14. package/dist/economics/formulas.js +260 -0
  15. package/dist/economics/formulas.js.map +1 -0
  16. package/dist/economics/index.d.ts +9 -0
  17. package/dist/economics/index.d.ts.map +1 -0
  18. package/dist/economics/index.js +9 -0
  19. package/dist/economics/index.js.map +1 -0
  20. package/dist/economics/validators.d.ts +18 -0
  21. package/dist/economics/validators.d.ts.map +1 -0
  22. package/dist/economics/validators.js +111 -0
  23. package/dist/economics/validators.js.map +1 -0
  24. package/dist/errors/index.d.ts +172 -0
  25. package/dist/errors/index.d.ts.map +1 -0
  26. package/dist/errors/index.js +313 -0
  27. package/dist/errors/index.js.map +1 -0
  28. package/dist/formatters/index.d.ts +8 -0
  29. package/dist/formatters/index.d.ts.map +1 -0
  30. package/dist/formatters/index.js +8 -0
  31. package/dist/formatters/index.js.map +1 -0
  32. package/dist/formatters/redux.d.ts +15 -0
  33. package/dist/formatters/redux.d.ts.map +1 -0
  34. package/dist/formatters/redux.js +35 -0
  35. package/dist/formatters/redux.js.map +1 -0
  36. package/dist/formatters/yaml.d.ts +18 -0
  37. package/dist/formatters/yaml.d.ts.map +1 -0
  38. package/dist/formatters/yaml.js +40 -0
  39. package/dist/formatters/yaml.js.map +1 -0
  40. package/dist/index.d.ts +11 -0
  41. package/dist/index.d.ts.map +1 -0
  42. package/dist/index.js +19 -0
  43. package/dist/index.js.map +1 -0
  44. package/dist/server.d.ts +14 -0
  45. package/dist/server.d.ts.map +1 -0
  46. package/dist/server.js +86 -0
  47. package/dist/server.js.map +1 -0
  48. package/dist/templates/advancedMicro.d.ts +8 -0
  49. package/dist/templates/advancedMicro.d.ts.map +1 -0
  50. package/dist/templates/advancedMicro.js +834 -0
  51. package/dist/templates/advancedMicro.js.map +1 -0
  52. package/dist/templates/consumer.d.ts +12 -0
  53. package/dist/templates/consumer.d.ts.map +1 -0
  54. package/dist/templates/consumer.js +1978 -0
  55. package/dist/templates/consumer.js.map +1 -0
  56. package/dist/templates/elasticity.d.ts +8 -0
  57. package/dist/templates/elasticity.d.ts.map +1 -0
  58. package/dist/templates/elasticity.js +500 -0
  59. package/dist/templates/elasticity.js.map +1 -0
  60. package/dist/templates/externalities.d.ts +11 -0
  61. package/dist/templates/externalities.d.ts.map +1 -0
  62. package/dist/templates/externalities.js +997 -0
  63. package/dist/templates/externalities.js.map +1 -0
  64. package/dist/templates/financeBehavioral.d.ts +8 -0
  65. package/dist/templates/financeBehavioral.d.ts.map +1 -0
  66. package/dist/templates/financeBehavioral.js +860 -0
  67. package/dist/templates/financeBehavioral.js.map +1 -0
  68. package/dist/templates/growth.d.ts +8 -0
  69. package/dist/templates/growth.d.ts.map +1 -0
  70. package/dist/templates/growth.js +740 -0
  71. package/dist/templates/growth.js.map +1 -0
  72. package/dist/templates/index.d.ts +31 -0
  73. package/dist/templates/index.d.ts.map +1 -0
  74. package/dist/templates/index.js +91 -0
  75. package/dist/templates/index.js.map +1 -0
  76. package/dist/templates/inequality.d.ts +8 -0
  77. package/dist/templates/inequality.d.ts.map +1 -0
  78. package/dist/templates/inequality.js +562 -0
  79. package/dist/templates/inequality.js.map +1 -0
  80. package/dist/templates/intertemporalMacro.d.ts +8 -0
  81. package/dist/templates/intertemporalMacro.d.ts.map +1 -0
  82. package/dist/templates/intertemporalMacro.js +550 -0
  83. package/dist/templates/intertemporalMacro.js.map +1 -0
  84. package/dist/templates/isLM.d.ts +8 -0
  85. package/dist/templates/isLM.d.ts.map +1 -0
  86. package/dist/templates/isLM.js +747 -0
  87. package/dist/templates/isLM.js.map +1 -0
  88. package/dist/templates/macro.d.ts +8 -0
  89. package/dist/templates/macro.d.ts.map +1 -0
  90. package/dist/templates/macro.js +600 -0
  91. package/dist/templates/macro.js.map +1 -0
  92. package/dist/templates/marketStructures.d.ts +11 -0
  93. package/dist/templates/marketStructures.d.ts.map +1 -0
  94. package/dist/templates/marketStructures.js +1135 -0
  95. package/dist/templates/marketStructures.js.map +1 -0
  96. package/dist/templates/newKeynesian.d.ts +8 -0
  97. package/dist/templates/newKeynesian.d.ts.map +1 -0
  98. package/dist/templates/newKeynesian.js +633 -0
  99. package/dist/templates/newKeynesian.js.map +1 -0
  100. package/dist/templates/oligopoly.d.ts +11 -0
  101. package/dist/templates/oligopoly.d.ts.map +1 -0
  102. package/dist/templates/oligopoly.js +1113 -0
  103. package/dist/templates/oligopoly.js.map +1 -0
  104. package/dist/templates/ppf.d.ts +8 -0
  105. package/dist/templates/ppf.d.ts.map +1 -0
  106. package/dist/templates/ppf.js +439 -0
  107. package/dist/templates/ppf.js.map +1 -0
  108. package/dist/templates/producer.d.ts +11 -0
  109. package/dist/templates/producer.d.ts.map +1 -0
  110. package/dist/templates/producer.js +979 -0
  111. package/dist/templates/producer.js.map +1 -0
  112. package/dist/templates/production.d.ts +8 -0
  113. package/dist/templates/production.d.ts.map +1 -0
  114. package/dist/templates/production.js +574 -0
  115. package/dist/templates/production.js.map +1 -0
  116. package/dist/templates/supplyDemand.d.ts +8 -0
  117. package/dist/templates/supplyDemand.d.ts.map +1 -0
  118. package/dist/templates/supplyDemand.js +1282 -0
  119. package/dist/templates/supplyDemand.js.map +1 -0
  120. package/dist/templates/tradeGrowth.d.ts +8 -0
  121. package/dist/templates/tradeGrowth.d.ts.map +1 -0
  122. package/dist/templates/tradeGrowth.js +637 -0
  123. package/dist/templates/tradeGrowth.js.map +1 -0
  124. package/dist/tools/index.d.ts +25 -0
  125. package/dist/tools/index.d.ts.map +1 -0
  126. package/dist/tools/index.js +54 -0
  127. package/dist/tools/index.js.map +1 -0
  128. package/dist/tools/models.d.ts +8 -0
  129. package/dist/tools/models.d.ts.map +1 -0
  130. package/dist/tools/models.js +828 -0
  131. package/dist/tools/models.js.map +1 -0
  132. package/dist/tools/output.d.ts +8 -0
  133. package/dist/tools/output.d.ts.map +1 -0
  134. package/dist/tools/output.js +236 -0
  135. package/dist/tools/output.js.map +1 -0
  136. package/dist/tools/templates.d.ts +8 -0
  137. package/dist/tools/templates.d.ts.map +1 -0
  138. package/dist/tools/templates.js +247 -0
  139. package/dist/tools/templates.js.map +1 -0
  140. package/dist/tools/validation.d.ts +8 -0
  141. package/dist/tools/validation.d.ts.map +1 -0
  142. package/dist/tools/validation.js +181 -0
  143. package/dist/tools/validation.js.map +1 -0
  144. package/dist/types/index.d.ts +187 -0
  145. package/dist/types/index.d.ts.map +1 -0
  146. package/dist/types/index.js +7 -0
  147. package/dist/types/index.js.map +1 -0
  148. package/dist/utils/cache.d.ts +99 -0
  149. package/dist/utils/cache.d.ts.map +1 -0
  150. package/dist/utils/cache.js +192 -0
  151. package/dist/utils/cache.js.map +1 -0
  152. package/dist/utils/index.d.ts +8 -0
  153. package/dist/utils/index.d.ts.map +1 -0
  154. package/dist/utils/index.js +8 -0
  155. package/dist/utils/index.js.map +1 -0
  156. package/dist/utils/logger.d.ts +128 -0
  157. package/dist/utils/logger.d.ts.map +1 -0
  158. package/dist/utils/logger.js +251 -0
  159. package/dist/utils/logger.js.map +1 -0
  160. package/dist/validation/index.d.ts +42 -0
  161. package/dist/validation/index.d.ts.map +1 -0
  162. package/dist/validation/index.js +282 -0
  163. package/dist/validation/index.js.map +1 -0
  164. package/package.json +73 -0
@@ -0,0 +1,979 @@
1
+ /**
2
+ * Producer Theory Templates
3
+ *
4
+ * Templates for producer theory models including isoquants, isocosts,
5
+ * cost minimization, and returns to scale analysis.
6
+ *
7
+ * Phase 3.3: Producer Theory
8
+ */
9
+ // ============================================================================
10
+ // PHASE 3.3: PRODUCER THEORY
11
+ // ============================================================================
12
+ /**
13
+ * Cobb-Douglas Isoquants
14
+ *
15
+ * Production function: Q = A * L^α * K^β
16
+ * Isoquants show combinations of labor (L) and capital (K) that produce same output.
17
+ */
18
+ const isoquantsCobbDouglas = {
19
+ id: 'isoquants_cobb_douglas',
20
+ name: 'Cobb-Douglas Isoquants',
21
+ description: 'Production isoquants from Cobb-Douglas production function Q = A·L^α·K^β. Shows diminishing MRTS along each isoquant.',
22
+ category: 'production',
23
+ level: 'undergraduate',
24
+ tags: ['isoquants', 'production function', 'Cobb-Douglas', 'MRTS', 'producer theory'],
25
+ parameters: {
26
+ productivity: {
27
+ type: 'number',
28
+ default: 1,
29
+ min: 0.5,
30
+ max: 3,
31
+ description: 'Total factor productivity (A)',
32
+ },
33
+ alphaLabor: {
34
+ type: 'number',
35
+ default: 0.5,
36
+ min: 0.1,
37
+ max: 0.9,
38
+ description: 'Output elasticity of labor (α)',
39
+ },
40
+ betaCapital: {
41
+ type: 'number',
42
+ default: 0.5,
43
+ min: 0.1,
44
+ max: 0.9,
45
+ description: 'Output elasticity of capital (β)',
46
+ },
47
+ outputLevel: {
48
+ type: 'number',
49
+ default: 10,
50
+ min: 1,
51
+ max: 50,
52
+ description: 'Output level for main isoquant',
53
+ },
54
+ },
55
+ generate: (params) => {
56
+ const A = params.productivity ?? 1;
57
+ const alpha = params.alphaLabor ?? 0.5;
58
+ const beta = params.betaCapital ?? 0.5;
59
+ const Q = params.outputLevel ?? 10;
60
+ return {
61
+ metadata: {
62
+ specVersion: '1.3',
63
+ title: 'Cobb-Douglas Isoquants',
64
+ description: 'Q = A·L^α·K^β',
65
+ },
66
+ parameters: {
67
+ A: { value: A, label: 'TFP (A)', min: 0.5, max: 3, step: 0.1 },
68
+ alpha: { value: alpha, label: 'α (labor)', min: 0.1, max: 0.9, step: 0.05 },
69
+ beta: { value: beta, label: 'β (capital)', min: 0.1, max: 0.9, step: 0.05 },
70
+ Q: { value: Q, label: 'Output Level', min: 1, max: 50 },
71
+ Q_low: { expression: 'Q * 0.6', hidden: true },
72
+ Q_high: { expression: 'Q * 1.4', hidden: true },
73
+ // Returns to scale
74
+ rts: { expression: 'alpha + beta', label: 'α + β (RTS)', readonly: true },
75
+ // Current point on isoquant
76
+ pointL: { value: Q ** (1 / (alpha + beta)), label: 'Labor (L)', min: 1, max: 30 },
77
+ pointK: {
78
+ expression: '(Q / (A * (pointL ^ alpha))) ^ (1 / beta)',
79
+ label: 'Capital (K)',
80
+ readonly: true,
81
+ },
82
+ // MRTS at current point: MRTS = (α/β) * (K/L)
83
+ MRTS: {
84
+ expression: '(alpha / beta) * (pointK / pointL)',
85
+ label: 'MRTS',
86
+ readonly: true,
87
+ },
88
+ // Chart bounds
89
+ chartMax: { expression: 'max(pointL, pointK) * 2.5', hidden: true },
90
+ },
91
+ charts: [
92
+ {
93
+ id: 'main',
94
+ title: 'Production Isoquants',
95
+ xAxis: { label: 'Labor (L)', min: 0.5, max: 'chartMax' },
96
+ yAxis: { label: 'Capital (K)', min: 0.5, max: 'chartMax' },
97
+ elements: [
98
+ // Lower output isoquant
99
+ {
100
+ id: 'isoquant-low',
101
+ type: 'line',
102
+ equation: '(Q_low / (A * (x ^ alpha))) ^ (1 / beta)',
103
+ color: '#93C5FD',
104
+ strokeWidth: 2,
105
+ label: 'Q = ${Q_low:.1f}',
106
+ domain: { min: 0.5, max: 'chartMax * 0.95' },
107
+ },
108
+ // Main output isoquant
109
+ {
110
+ id: 'isoquant-main',
111
+ type: 'line',
112
+ equation: '(Q / (A * (x ^ alpha))) ^ (1 / beta)',
113
+ color: '#2563EB',
114
+ strokeWidth: 3,
115
+ label: 'Q = ${Q:.1f}',
116
+ domain: { min: 0.5, max: 'chartMax * 0.95' },
117
+ },
118
+ // Higher output isoquant
119
+ {
120
+ id: 'isoquant-high',
121
+ type: 'line',
122
+ equation: '(Q_high / (A * (x ^ alpha))) ^ (1 / beta)',
123
+ color: '#1D4ED8',
124
+ strokeWidth: 2,
125
+ label: 'Q = ${Q_high:.1f}',
126
+ domain: { min: 0.5, max: 'chartMax * 0.95' },
127
+ },
128
+ // Current point
129
+ {
130
+ id: 'current-point',
131
+ type: 'point',
132
+ x: 'pointL',
133
+ y: 'pointK',
134
+ color: '#16A34A',
135
+ label: 'Current',
136
+ droplines: { x: true, y: true },
137
+ draggable: true,
138
+ dragConfig: {
139
+ mode: 'expression',
140
+ parameters: { expressions: { pointL: 'x' } },
141
+ constraints: { bounds: { minX: 1, maxX: 'chartMax * 0.8' } },
142
+ },
143
+ },
144
+ // Tangent line showing MRTS
145
+ {
146
+ id: 'tangent',
147
+ type: 'line',
148
+ equation: 'pointK - MRTS * (x - pointL)',
149
+ color: '#DC2626',
150
+ strokeWidth: 1,
151
+ lineStyle: 'dashed',
152
+ domain: { min: 'max(0.5, pointL - 5)', max: 'pointL + 5' },
153
+ },
154
+ ],
155
+ annotations: [
156
+ {
157
+ id: 'mrts-label',
158
+ text: 'MRTS = ${MRTS:.2f}',
159
+ x: 'pointL + chartMax * 0.08',
160
+ y: 'pointK',
161
+ color: '#DC2626',
162
+ },
163
+ {
164
+ id: 'rts-label',
165
+ text: 'α + β = ${rts:.2f}',
166
+ x: 'chartMax * 0.7',
167
+ y: 'chartMax * 0.9',
168
+ color: '#6B7280',
169
+ },
170
+ {
171
+ id: 'rts-type',
172
+ text: '${rts > 1 ? "Increasing" : (rts < 1 ? "Decreasing" : "Constant")} RTS',
173
+ x: 'chartMax * 0.7',
174
+ y: 'chartMax * 0.82',
175
+ color: '#6B7280',
176
+ },
177
+ ],
178
+ },
179
+ ],
180
+ };
181
+ },
182
+ };
183
+ /**
184
+ * Isocost Lines
185
+ *
186
+ * Shows combinations of inputs that cost the same total amount.
187
+ * C = wL + rK → K = C/r - (w/r)L
188
+ */
189
+ const isocostLines = {
190
+ id: 'isocost_lines',
191
+ name: 'Isocost Lines',
192
+ description: 'Isocost lines showing combinations of labor and capital with equal total cost. Slope = -w/r (negative wage-rental ratio).',
193
+ category: 'production',
194
+ level: 'undergraduate',
195
+ tags: ['isocost', 'input costs', 'wage', 'rental rate', 'producer theory'],
196
+ parameters: {
197
+ totalCost: {
198
+ type: 'number',
199
+ default: 100,
200
+ min: 20,
201
+ max: 300,
202
+ description: 'Total cost budget (C)',
203
+ },
204
+ wage: {
205
+ type: 'number',
206
+ default: 10,
207
+ min: 1,
208
+ max: 30,
209
+ description: 'Wage rate (w)',
210
+ },
211
+ rentalRate: {
212
+ type: 'number',
213
+ default: 10,
214
+ min: 1,
215
+ max: 30,
216
+ description: 'Rental rate of capital (r)',
217
+ },
218
+ },
219
+ generate: (params) => {
220
+ const C = params.totalCost ?? 100;
221
+ const w = params.wage ?? 10;
222
+ const r = params.rentalRate ?? 10;
223
+ return {
224
+ metadata: {
225
+ specVersion: '1.3',
226
+ title: 'Isocost Lines',
227
+ description: 'C = wL + rK',
228
+ },
229
+ parameters: {
230
+ C: { value: C, label: 'Total Cost', min: 20, max: 300, step: 10 },
231
+ w: { value: w, label: 'Wage (w)', min: 1, max: 30 },
232
+ r: { value: r, label: 'Rental Rate (r)', min: 1, max: 30 },
233
+ C_low: { expression: 'C * 0.6', hidden: true },
234
+ C_high: { expression: 'C * 1.4', hidden: true },
235
+ // Intercepts
236
+ maxL: { expression: 'C / w', label: 'Max L', readonly: true },
237
+ maxK: { expression: 'C / r', label: 'Max K', readonly: true },
238
+ // Slope
239
+ slope: { expression: '-w / r', label: 'Slope (-w/r)', readonly: true },
240
+ // Chart bounds
241
+ chartMaxL: { expression: 'C_high / w * 1.1', hidden: true },
242
+ chartMaxK: { expression: 'C_high / r * 1.1', hidden: true },
243
+ // Example point on isocost
244
+ pointL: { value: C / (2 * w), label: 'Labor', min: 0, max: 'maxL' },
245
+ pointK: { expression: '(C - w * pointL) / r', label: 'Capital', readonly: true },
246
+ },
247
+ charts: [
248
+ {
249
+ id: 'main',
250
+ title: 'Isocost Lines: C = wL + rK',
251
+ xAxis: { label: 'Labor (L)', min: 0, max: 'chartMaxL' },
252
+ yAxis: { label: 'Capital (K)', min: 0, max: 'chartMaxK' },
253
+ elements: [
254
+ // Lower cost isocost
255
+ {
256
+ id: 'isocost-low',
257
+ type: 'line',
258
+ equation: 'C_low / r - (w / r) * x',
259
+ color: '#9CA3AF',
260
+ strokeWidth: 2,
261
+ lineStyle: 'dashed',
262
+ label: 'C = $${C_low:.0f}',
263
+ domain: { min: 0, max: 'C_low / w' },
264
+ },
265
+ // Main isocost
266
+ {
267
+ id: 'isocost-main',
268
+ type: 'line',
269
+ equation: 'C / r - (w / r) * x',
270
+ color: '#2563EB',
271
+ strokeWidth: 3,
272
+ label: 'C = $${C:.0f}',
273
+ domain: { min: 0, max: 'maxL' },
274
+ },
275
+ // Higher cost isocost
276
+ {
277
+ id: 'isocost-high',
278
+ type: 'line',
279
+ equation: 'C_high / r - (w / r) * x',
280
+ color: '#6B7280',
281
+ strokeWidth: 2,
282
+ lineStyle: 'dashed',
283
+ label: 'C = $${C_high:.0f}',
284
+ domain: { min: 0, max: 'C_high / w' },
285
+ },
286
+ // Intercept points
287
+ {
288
+ id: 'l-intercept',
289
+ type: 'point',
290
+ x: 'maxL',
291
+ y: 0,
292
+ color: '#7C3AED',
293
+ label: 'C/w',
294
+ },
295
+ {
296
+ id: 'k-intercept',
297
+ type: 'point',
298
+ x: 0,
299
+ y: 'maxK',
300
+ color: '#7C3AED',
301
+ label: 'C/r',
302
+ },
303
+ // Current point
304
+ {
305
+ id: 'current',
306
+ type: 'point',
307
+ x: 'pointL',
308
+ y: 'pointK',
309
+ color: '#16A34A',
310
+ label: 'Bundle',
311
+ droplines: { x: true, y: true },
312
+ draggable: true,
313
+ dragConfig: {
314
+ mode: 'expression',
315
+ parameters: { expressions: { pointL: 'x' } },
316
+ constraints: { bounds: { minX: 0, maxX: 'maxL' } },
317
+ },
318
+ },
319
+ ],
320
+ annotations: [
321
+ {
322
+ id: 'slope-label',
323
+ text: 'Slope = -w/r = ${slope:.2f}',
324
+ x: 'maxL * 0.5',
325
+ y: 'maxK * 0.7',
326
+ color: '#2563EB',
327
+ },
328
+ {
329
+ id: 'cost-breakdown',
330
+ text: 'wL = $${w * pointL:.0f}, rK = $${r * pointK:.0f}',
331
+ x: 'chartMaxL * 0.6',
332
+ y: 'chartMaxK * 0.9',
333
+ color: '#16A34A',
334
+ },
335
+ ],
336
+ },
337
+ ],
338
+ };
339
+ },
340
+ };
341
+ /**
342
+ * Cost Minimization
343
+ *
344
+ * Optimal input combination where isoquant is tangent to isocost.
345
+ * MRTS = w/r at the optimum.
346
+ */
347
+ const costMinimization = {
348
+ id: 'cost_minimization',
349
+ name: 'Cost Minimization',
350
+ description: 'Optimal input mix where isoquant is tangent to isocost line. At optimum: MRTS = w/r (marginal rate of technical substitution equals input price ratio).',
351
+ category: 'production',
352
+ level: 'undergraduate',
353
+ tags: ['cost minimization', 'optimal inputs', 'MRTS', 'tangency', 'producer theory'],
354
+ parameters: {
355
+ outputTarget: {
356
+ type: 'number',
357
+ default: 10,
358
+ min: 5,
359
+ max: 30,
360
+ description: 'Target output level',
361
+ },
362
+ wage: {
363
+ type: 'number',
364
+ default: 10,
365
+ min: 1,
366
+ max: 30,
367
+ description: 'Wage rate (w)',
368
+ },
369
+ rentalRate: {
370
+ type: 'number',
371
+ default: 10,
372
+ min: 1,
373
+ max: 30,
374
+ description: 'Rental rate of capital (r)',
375
+ },
376
+ alpha: {
377
+ type: 'number',
378
+ default: 0.5,
379
+ min: 0.2,
380
+ max: 0.8,
381
+ description: 'Labor elasticity (α)',
382
+ },
383
+ },
384
+ generate: (params) => {
385
+ const Q = params.outputTarget ?? 10;
386
+ const w = params.wage ?? 10;
387
+ const r = params.rentalRate ?? 10;
388
+ const alpha = params.alpha ?? 0.5;
389
+ return {
390
+ metadata: {
391
+ specVersion: '1.3',
392
+ title: 'Cost Minimization',
393
+ description: 'Optimal input combination',
394
+ },
395
+ parameters: {
396
+ Q: { value: Q, label: 'Target Output', min: 5, max: 30 },
397
+ w: { value: w, label: 'Wage (w)', min: 1, max: 30 },
398
+ r: { value: r, label: 'Rental Rate (r)', min: 1, max: 30 },
399
+ alpha: { value: alpha, label: 'α', min: 0.2, max: 0.8, step: 0.05 },
400
+ beta: { expression: '1 - alpha', label: 'β', readonly: true },
401
+ // Optimal inputs (from cost minimization FOCs)
402
+ // L* = Q * (α/β * r/w)^β and K* = Q * (β/α * w/r)^α
403
+ optL: {
404
+ expression: 'Q * ((alpha / (1 - alpha)) * (r / w)) ^ (1 - alpha)',
405
+ label: 'Optimal L',
406
+ readonly: true,
407
+ },
408
+ optK: {
409
+ expression: 'Q * (((1 - alpha) / alpha) * (w / r)) ^ alpha',
410
+ label: 'Optimal K',
411
+ readonly: true,
412
+ },
413
+ // Minimum cost
414
+ minCost: {
415
+ expression: 'w * optL + r * optK',
416
+ label: 'Min Cost',
417
+ readonly: true,
418
+ },
419
+ // MRTS at optimum
420
+ MRTS: {
421
+ expression: '(alpha / (1 - alpha)) * (optK / optL)',
422
+ label: 'MRTS',
423
+ readonly: true,
424
+ },
425
+ priceRatio: { expression: 'w / r', label: 'w/r', readonly: true },
426
+ // Suboptimal cost line
427
+ higherCost: { expression: 'minCost * 1.3', hidden: true },
428
+ // Chart bounds
429
+ chartMaxL: { expression: 'higherCost / w * 1.1', hidden: true },
430
+ chartMaxK: { expression: 'higherCost / r * 1.1', hidden: true },
431
+ },
432
+ charts: [
433
+ {
434
+ id: 'main',
435
+ title: 'Cost Minimization: MRTS = w/r',
436
+ xAxis: { label: 'Labor (L)', min: 0.5, max: 'chartMaxL' },
437
+ yAxis: { label: 'Capital (K)', min: 0.5, max: 'chartMaxK' },
438
+ elements: [
439
+ // Higher cost isocost (tangent but suboptimal)
440
+ {
441
+ id: 'isocost-high',
442
+ type: 'line',
443
+ equation: 'higherCost / r - (w / r) * x',
444
+ color: '#EF4444',
445
+ strokeWidth: 1,
446
+ lineStyle: 'dashed',
447
+ label: 'C = $${higherCost:.0f}',
448
+ domain: { min: 0, max: 'higherCost / w' },
449
+ },
450
+ // Minimum cost isocost
451
+ {
452
+ id: 'isocost-min',
453
+ type: 'line',
454
+ equation: 'minCost / r - (w / r) * x',
455
+ color: '#16A34A',
456
+ strokeWidth: 3,
457
+ label: 'C* = $${minCost:.0f}',
458
+ domain: { min: 0, max: 'minCost / w' },
459
+ },
460
+ // Isoquant
461
+ {
462
+ id: 'isoquant',
463
+ type: 'line',
464
+ equation: '(Q / (x ^ alpha)) ^ (1 / (1 - alpha))',
465
+ color: '#2563EB',
466
+ strokeWidth: 3,
467
+ label: 'Q = ${Q}',
468
+ domain: { min: 0.5, max: 'chartMaxL * 0.95' },
469
+ },
470
+ // Optimal point
471
+ {
472
+ id: 'optimum',
473
+ type: 'point',
474
+ x: 'optL',
475
+ y: 'optK',
476
+ color: '#16A34A',
477
+ size: 10,
478
+ label: 'Optimum',
479
+ droplines: { x: true, y: true },
480
+ },
481
+ // Tangent line
482
+ {
483
+ id: 'tangent',
484
+ type: 'line',
485
+ equation: 'optK - priceRatio * (x - optL)',
486
+ color: '#7C3AED',
487
+ strokeWidth: 1,
488
+ lineStyle: 'dotted',
489
+ domain: { min: 'max(0.5, optL - 5)', max: 'optL + 5' },
490
+ },
491
+ ],
492
+ annotations: [
493
+ {
494
+ id: 'opt-label',
495
+ text: 'L* = ${optL:.2f}, K* = ${optK:.2f}',
496
+ x: 'optL + chartMaxL * 0.05',
497
+ y: 'optK + chartMaxK * 0.05',
498
+ color: '#16A34A',
499
+ },
500
+ {
501
+ id: 'tangency-label',
502
+ text: 'MRTS = w/r = ${priceRatio:.2f}',
503
+ x: 'chartMaxL * 0.6',
504
+ y: 'chartMaxK * 0.9',
505
+ color: '#7C3AED',
506
+ },
507
+ {
508
+ id: 'cost-label',
509
+ text: 'Minimum Cost = $${minCost:.2f}',
510
+ x: 'chartMaxL * 0.6',
511
+ y: 'chartMaxK * 0.82',
512
+ color: '#16A34A',
513
+ },
514
+ ],
515
+ },
516
+ ],
517
+ };
518
+ },
519
+ };
520
+ /**
521
+ * Expansion Path
522
+ *
523
+ * Locus of cost-minimizing input combinations as output varies.
524
+ * For Cobb-Douglas, this is a ray through the origin.
525
+ */
526
+ const expansionPath = {
527
+ id: 'expansion_path',
528
+ name: 'Expansion Path',
529
+ description: 'Long-run expansion path showing optimal input combinations as output scales. For Cobb-Douglas, the path is a ray through the origin with slope K/L = (β/α)(w/r).',
530
+ category: 'production',
531
+ level: 'undergraduate',
532
+ tags: ['expansion path', 'long-run', 'scaling', 'cost minimization', 'producer theory'],
533
+ parameters: {
534
+ wage: {
535
+ type: 'number',
536
+ default: 10,
537
+ description: 'Wage rate (w)',
538
+ },
539
+ rentalRate: {
540
+ type: 'number',
541
+ default: 10,
542
+ description: 'Rental rate of capital (r)',
543
+ },
544
+ alpha: {
545
+ type: 'number',
546
+ default: 0.6,
547
+ description: 'Labor elasticity (α)',
548
+ },
549
+ outputLow: {
550
+ type: 'number',
551
+ default: 5,
552
+ description: 'Low output level',
553
+ },
554
+ outputMid: {
555
+ type: 'number',
556
+ default: 10,
557
+ description: 'Medium output level',
558
+ },
559
+ outputHigh: {
560
+ type: 'number',
561
+ default: 15,
562
+ description: 'High output level',
563
+ },
564
+ },
565
+ generate: (params) => {
566
+ const w = params.wage ?? 10;
567
+ const r = params.rentalRate ?? 10;
568
+ const alpha = params.alpha ?? 0.6;
569
+ const Q_low = params.outputLow ?? 5;
570
+ const Q_mid = params.outputMid ?? 10;
571
+ const Q_high = params.outputHigh ?? 15;
572
+ return {
573
+ metadata: {
574
+ specVersion: '1.3',
575
+ title: 'Expansion Path',
576
+ description: 'Long-run optimal input combinations',
577
+ },
578
+ parameters: {
579
+ w: { value: w, label: 'Wage (w)', min: 1, max: 30 },
580
+ r: { value: r, label: 'Rental Rate (r)', min: 1, max: 30 },
581
+ alpha: { value: alpha, label: 'α', min: 0.2, max: 0.8, step: 0.05 },
582
+ beta: { expression: '1 - alpha', hidden: true },
583
+ Q_low: { value: Q_low, label: 'Q (low)', min: 1, max: 10 },
584
+ Q_mid: { value: Q_mid, label: 'Q (mid)', min: 5, max: 20 },
585
+ Q_high: { value: Q_high, label: 'Q (high)', min: 10, max: 30 },
586
+ // Expansion path slope: K/L = (β/α)(w/r)
587
+ expansionSlope: {
588
+ expression: '((1 - alpha) / alpha) * (w / r)',
589
+ label: 'K/L Ratio',
590
+ readonly: true,
591
+ },
592
+ // Optimal inputs at each output
593
+ L_low: {
594
+ expression: 'Q_low * ((alpha / (1 - alpha)) * (r / w)) ^ (1 - alpha)',
595
+ hidden: true,
596
+ },
597
+ K_low: {
598
+ expression: 'Q_low * (((1 - alpha) / alpha) * (w / r)) ^ alpha',
599
+ hidden: true,
600
+ },
601
+ L_mid: {
602
+ expression: 'Q_mid * ((alpha / (1 - alpha)) * (r / w)) ^ (1 - alpha)',
603
+ hidden: true,
604
+ },
605
+ K_mid: {
606
+ expression: 'Q_mid * (((1 - alpha) / alpha) * (w / r)) ^ alpha',
607
+ hidden: true,
608
+ },
609
+ L_high: {
610
+ expression: 'Q_high * ((alpha / (1 - alpha)) * (r / w)) ^ (1 - alpha)',
611
+ hidden: true,
612
+ },
613
+ K_high: {
614
+ expression: 'Q_high * (((1 - alpha) / alpha) * (w / r)) ^ alpha',
615
+ hidden: true,
616
+ },
617
+ // Costs at each level
618
+ C_low: { expression: 'w * L_low + r * K_low', label: 'Cost (low)', readonly: true },
619
+ C_mid: { expression: 'w * L_mid + r * K_mid', label: 'Cost (mid)', readonly: true },
620
+ C_high: { expression: 'w * L_high + r * K_high', label: 'Cost (high)', readonly: true },
621
+ // Chart bounds
622
+ chartMaxL: { expression: 'L_high * 1.3', hidden: true },
623
+ chartMaxK: { expression: 'K_high * 1.3', hidden: true },
624
+ },
625
+ charts: [
626
+ {
627
+ id: 'main',
628
+ title: 'Expansion Path',
629
+ xAxis: { label: 'Labor (L)', min: 0, max: 'chartMaxL' },
630
+ yAxis: { label: 'Capital (K)', min: 0, max: 'chartMaxK' },
631
+ elements: [
632
+ // Expansion path (ray through origin)
633
+ {
634
+ id: 'expansion-path',
635
+ type: 'line',
636
+ equation: 'expansionSlope * x',
637
+ color: '#7C3AED',
638
+ strokeWidth: 3,
639
+ label: 'Expansion Path',
640
+ domain: { min: 0, max: 'chartMaxL' },
641
+ },
642
+ // Isoquants
643
+ {
644
+ id: 'isoquant-low',
645
+ type: 'line',
646
+ equation: '(Q_low / (x ^ alpha)) ^ (1 / (1 - alpha))',
647
+ color: '#93C5FD',
648
+ strokeWidth: 2,
649
+ label: 'Q = ${Q_low}',
650
+ domain: { min: 0.3, max: 'chartMaxL * 0.95' },
651
+ },
652
+ {
653
+ id: 'isoquant-mid',
654
+ type: 'line',
655
+ equation: '(Q_mid / (x ^ alpha)) ^ (1 / (1 - alpha))',
656
+ color: '#2563EB',
657
+ strokeWidth: 2,
658
+ label: 'Q = ${Q_mid}',
659
+ domain: { min: 0.3, max: 'chartMaxL * 0.95' },
660
+ },
661
+ {
662
+ id: 'isoquant-high',
663
+ type: 'line',
664
+ equation: '(Q_high / (x ^ alpha)) ^ (1 / (1 - alpha))',
665
+ color: '#1D4ED8',
666
+ strokeWidth: 2,
667
+ label: 'Q = ${Q_high}',
668
+ domain: { min: 0.3, max: 'chartMaxL * 0.95' },
669
+ },
670
+ // Isocost lines (tangent at optimal points)
671
+ {
672
+ id: 'isocost-low',
673
+ type: 'line',
674
+ equation: 'C_low / r - (w / r) * x',
675
+ color: '#9CA3AF',
676
+ strokeWidth: 1,
677
+ lineStyle: 'dashed',
678
+ domain: { min: 0, max: 'C_low / w' },
679
+ },
680
+ {
681
+ id: 'isocost-mid',
682
+ type: 'line',
683
+ equation: 'C_mid / r - (w / r) * x',
684
+ color: '#9CA3AF',
685
+ strokeWidth: 1,
686
+ lineStyle: 'dashed',
687
+ domain: { min: 0, max: 'C_mid / w' },
688
+ },
689
+ {
690
+ id: 'isocost-high',
691
+ type: 'line',
692
+ equation: 'C_high / r - (w / r) * x',
693
+ color: '#9CA3AF',
694
+ strokeWidth: 1,
695
+ lineStyle: 'dashed',
696
+ domain: { min: 0, max: 'C_high / w' },
697
+ },
698
+ // Optimal points
699
+ {
700
+ id: 'opt-low',
701
+ type: 'point',
702
+ x: 'L_low',
703
+ y: 'K_low',
704
+ color: '#16A34A',
705
+ label: 'A',
706
+ },
707
+ {
708
+ id: 'opt-mid',
709
+ type: 'point',
710
+ x: 'L_mid',
711
+ y: 'K_mid',
712
+ color: '#16A34A',
713
+ size: 8,
714
+ label: 'B',
715
+ },
716
+ {
717
+ id: 'opt-high',
718
+ type: 'point',
719
+ x: 'L_high',
720
+ y: 'K_high',
721
+ color: '#16A34A',
722
+ label: 'C',
723
+ },
724
+ ],
725
+ annotations: [
726
+ {
727
+ id: 'slope-label',
728
+ text: 'K/L = (β/α)(w/r) = ${expansionSlope:.2f}',
729
+ x: 'chartMaxL * 0.6',
730
+ y: 'chartMaxK * 0.9',
731
+ color: '#7C3AED',
732
+ },
733
+ {
734
+ id: 'path-label',
735
+ text: 'Expansion Path',
736
+ x: 'L_high * 1.1',
737
+ y: 'K_high * 1.1',
738
+ color: '#7C3AED',
739
+ },
740
+ ],
741
+ },
742
+ ],
743
+ };
744
+ },
745
+ };
746
+ /**
747
+ * Returns to Scale Visualization
748
+ *
749
+ * Shows increasing, constant, and decreasing returns to scale
750
+ * by comparing input scaling with output scaling.
751
+ */
752
+ const returnsToScale = {
753
+ id: 'returns_to_scale',
754
+ name: 'Returns to Scale',
755
+ description: 'Visualizes returns to scale: when inputs double, output may more than double (IRS), exactly double (CRS), or less than double (DRS). Determined by α + β.',
756
+ category: 'production',
757
+ level: 'undergraduate',
758
+ tags: ['returns to scale', 'IRS', 'CRS', 'DRS', 'scaling', 'producer theory'],
759
+ parameters: {
760
+ alpha: {
761
+ type: 'number',
762
+ default: 0.6,
763
+ min: 0.1,
764
+ max: 0.9,
765
+ description: 'Labor elasticity (α)',
766
+ },
767
+ beta: {
768
+ type: 'number',
769
+ default: 0.6,
770
+ min: 0.1,
771
+ max: 0.9,
772
+ description: 'Capital elasticity (β)',
773
+ },
774
+ baseLabor: {
775
+ type: 'number',
776
+ default: 5,
777
+ description: 'Base labor input',
778
+ },
779
+ baseCapital: {
780
+ type: 'number',
781
+ default: 5,
782
+ description: 'Base capital input',
783
+ },
784
+ },
785
+ generate: (params) => {
786
+ const alpha = params.alpha ?? 0.6;
787
+ const beta = params.beta ?? 0.6;
788
+ const L0 = params.baseLabor ?? 5;
789
+ const K0 = params.baseCapital ?? 5;
790
+ return {
791
+ metadata: {
792
+ specVersion: '1.3',
793
+ title: 'Returns to Scale',
794
+ description: 'Q = L^α · K^β, RTS = α + β',
795
+ },
796
+ parameters: {
797
+ alpha: { value: alpha, label: 'α (labor)', min: 0.1, max: 0.9, step: 0.05 },
798
+ beta: { value: beta, label: 'β (capital)', min: 0.1, max: 0.9, step: 0.05 },
799
+ L0: { value: L0, label: 'Base L', min: 1, max: 20 },
800
+ K0: { value: K0, label: 'Base K', min: 1, max: 20 },
801
+ // Returns to scale parameter
802
+ rts: { expression: 'alpha + beta', label: 'α + β', readonly: true },
803
+ // Base output
804
+ Q0: { expression: '(L0 ^ alpha) * (K0 ^ beta)', label: 'Base Q', readonly: true },
805
+ // Scaled inputs (2x)
806
+ L1: { expression: '2 * L0', hidden: true },
807
+ K1: { expression: '2 * K0', hidden: true },
808
+ // Output with doubled inputs
809
+ Q1: { expression: '(L1 ^ alpha) * (K1 ^ beta)', label: 'Q (2x inputs)', readonly: true },
810
+ // Output ratio
811
+ outputRatio: { expression: 'Q1 / Q0', label: 'Q ratio', readonly: true },
812
+ // For the chart: scaling factor on x-axis, output on y-axis
813
+ chartMaxScale: { value: 3, hidden: true },
814
+ chartMaxQ: { expression: 'Q0 * (chartMaxScale ^ rts) * 1.1', hidden: true },
815
+ // Reference lines for different RTS
816
+ irsQ: { expression: 'Q0 * (2 ^ 1.2)', hidden: true },
817
+ crsQ: { expression: 'Q0 * 2', hidden: true },
818
+ drsQ: { expression: 'Q0 * (2 ^ 0.8)', hidden: true },
819
+ },
820
+ charts: [
821
+ {
822
+ id: 'main',
823
+ title: 'Returns to Scale: Output vs Input Scaling',
824
+ xAxis: { label: 'Input Scale Factor (t)', min: 0.5, max: 'chartMaxScale' },
825
+ yAxis: { label: 'Output Q(tL, tK)', min: 0, max: 'chartMaxQ' },
826
+ elements: [
827
+ // Actual RTS curve: Q = Q0 * t^(α+β)
828
+ {
829
+ id: 'rts-curve',
830
+ type: 'line',
831
+ equation: 'Q0 * (x ^ rts)',
832
+ color: '#2563EB',
833
+ strokeWidth: 3,
834
+ label: 'Actual (α+β=${rts:.2f})',
835
+ },
836
+ // Reference: CRS (α+β = 1)
837
+ {
838
+ id: 'crs-reference',
839
+ type: 'line',
840
+ equation: 'Q0 * x',
841
+ color: '#6B7280',
842
+ strokeWidth: 2,
843
+ lineStyle: 'dashed',
844
+ label: 'CRS (α+β=1)',
845
+ },
846
+ // Base point (scale = 1)
847
+ {
848
+ id: 'base-point',
849
+ type: 'point',
850
+ x: 1,
851
+ y: 'Q0',
852
+ color: '#16A34A',
853
+ label: 'Base',
854
+ droplines: { x: true, y: true },
855
+ },
856
+ // Doubled point (scale = 2)
857
+ {
858
+ id: 'doubled-point',
859
+ type: 'point',
860
+ x: 2,
861
+ y: 'Q1',
862
+ color: '#7C3AED',
863
+ label: '2x inputs',
864
+ droplines: { x: true, y: true },
865
+ },
866
+ // CRS reference point
867
+ {
868
+ id: 'crs-point',
869
+ type: 'point',
870
+ x: 2,
871
+ y: 'crsQ',
872
+ color: '#6B7280',
873
+ size: 5,
874
+ },
875
+ ],
876
+ annotations: [
877
+ {
878
+ id: 'rts-type',
879
+ text: '${rts > 1 ? "Increasing" : (rts < 1 ? "Decreasing" : "Constant")} Returns to Scale',
880
+ x: 'chartMaxScale * 0.5',
881
+ y: 'chartMaxQ * 0.9',
882
+ color: '#2563EB',
883
+ },
884
+ {
885
+ id: 'ratio-label',
886
+ text: 'When inputs double: Q × ${outputRatio:.2f}',
887
+ x: 'chartMaxScale * 0.5',
888
+ y: 'chartMaxQ * 0.8',
889
+ color: '#7C3AED',
890
+ },
891
+ {
892
+ id: 'formula',
893
+ text: 'Q(tL,tK) = t^(α+β) · Q(L,K)',
894
+ x: 'chartMaxScale * 0.5',
895
+ y: 'chartMaxQ * 0.15',
896
+ color: '#6B7280',
897
+ },
898
+ ],
899
+ },
900
+ {
901
+ id: 'isoquant-map',
902
+ title: 'Isoquant Spacing',
903
+ xAxis: { label: 'Labor (L)', min: 0, max: 'L1 * 1.3' },
904
+ yAxis: { label: 'Capital (K)', min: 0, max: 'K1 * 1.3' },
905
+ elements: [
906
+ // Ray from origin
907
+ {
908
+ id: 'ray',
909
+ type: 'line',
910
+ equation: '(K0 / L0) * x',
911
+ color: '#7C3AED',
912
+ strokeWidth: 2,
913
+ lineStyle: 'dashed',
914
+ label: 'Scaling Ray',
915
+ },
916
+ // Base isoquant
917
+ {
918
+ id: 'isoquant-base',
919
+ type: 'line',
920
+ equation: '(Q0 / (x ^ alpha)) ^ (1 / beta)',
921
+ color: '#16A34A',
922
+ strokeWidth: 2,
923
+ label: 'Q = ${Q0:.1f}',
924
+ domain: { min: 0.5, max: 'L1 * 1.2' },
925
+ },
926
+ // Double output isoquant
927
+ {
928
+ id: 'isoquant-double',
929
+ type: 'line',
930
+ equation: '(crsQ / (x ^ alpha)) ^ (1 / beta)',
931
+ color: '#2563EB',
932
+ strokeWidth: 2,
933
+ label: 'Q = ${crsQ:.1f}',
934
+ domain: { min: 0.5, max: 'L1 * 1.2' },
935
+ },
936
+ // Base point
937
+ {
938
+ id: 'base',
939
+ type: 'point',
940
+ x: 'L0',
941
+ y: 'K0',
942
+ color: '#16A34A',
943
+ label: '(L₀, K₀)',
944
+ },
945
+ // Doubled inputs point
946
+ {
947
+ id: 'doubled',
948
+ type: 'point',
949
+ x: 'L1',
950
+ y: 'K1',
951
+ color: '#7C3AED',
952
+ label: '(2L₀, 2K₀)',
953
+ },
954
+ ],
955
+ annotations: [
956
+ {
957
+ id: 'spacing-note',
958
+ text: '${rts > 1 ? "Closer spacing = IRS" : (rts < 1 ? "Wider spacing = DRS" : "Equal spacing = CRS")}',
959
+ x: 'L1 * 0.8',
960
+ y: 'K1 * 1.2',
961
+ color: '#6B7280',
962
+ },
963
+ ],
964
+ },
965
+ ],
966
+ };
967
+ },
968
+ };
969
+ // ============================================================================
970
+ // EXPORTS
971
+ // ============================================================================
972
+ export const producerTheoryTemplates = [
973
+ isoquantsCobbDouglas,
974
+ isocostLines,
975
+ costMinimization,
976
+ expansionPath,
977
+ returnsToScale,
978
+ ];
979
+ //# sourceMappingURL=producer.js.map