diff --git a/econplayground/main/migrations/0116_graph_a5_name.py b/econplayground/main/migrations/0116_graph_a5_name.py new file mode 100644 index 000000000..5c0012e9d --- /dev/null +++ b/econplayground/main/migrations/0116_graph_a5_name.py @@ -0,0 +1,18 @@ +# Generated by Django 4.2.14 on 2024-07-29 14:01 + +from django.db import migrations, models + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0115_graph_a1_2_graph_a1_max_2_graph_a1_min_2_graph_a2_2_and_more'), + ] + + operations = [ + migrations.AddField( + model_name='graph', + name='a5_name', + field=models.TextField(blank=True, default=''), + ), + ] diff --git a/econplayground/main/migrations/0117_auto_20240729_1001.py b/econplayground/main/migrations/0117_auto_20240729_1001.py new file mode 100644 index 000000000..36cd828ae --- /dev/null +++ b/econplayground/main/migrations/0117_auto_20240729_1001.py @@ -0,0 +1,30 @@ +# Generated by Django 4.2.14 on 2024-07-29 14:01 + +from django.db import migrations + + +def migrate_cobb_douglas_fields(apps, schema_editor): + Graph = apps.get_model("main", "Graph") + for graph in Graph.objects.filter(graph_type=3): + # Cobb-Douglas + graph.a1 = graph.cobb_douglas_a + graph.a1_name = graph.cobb_douglas_a_name + graph.a2 = graph.cobb_douglas_l + graph.a2_name = graph.cobb_douglas_l_name + graph.a3 = graph.cobb_douglas_k + graph.a3_name = graph.cobb_douglas_k_name + graph.a4 = graph.cobb_douglas_alpha + graph.a4_name = graph.cobb_douglas_alpha_name + graph.a5_name = graph.cobb_douglas_y_name + graph.save() + + +class Migration(migrations.Migration): + + dependencies = [ + ('main', '0116_graph_a5_name'), + ] + + operations = [ + migrations.RunPython(migrate_cobb_douglas_fields), + ] diff --git a/econplayground/main/models.py b/econplayground/main/models.py index 5c88c5e2b..96f4a889a 100644 --- a/econplayground/main/models.py +++ b/econplayground/main/models.py @@ -297,56 +297,70 @@ class Meta(OrderedModel.Meta): # more typical float type, for fixed precision: # https://docs.python.org/3/library/decimal.html#module-decimal # + # A1 a1 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a1_max = models.IntegerField(default=10) a1_min = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a1_name = models.TextField(default='', blank=True,) + # Alternate value for a1 + a1_2 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + a1_max_2 = models.IntegerField(default=10) + a1_min_2 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + + # A2 a2 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a2_max = models.IntegerField(default=10) a2_min = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) + # Alternate value for a2 a2_name = models.TextField(default='', blank=True) + a2_2 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + a2_max_2 = models.IntegerField(default=10) + a2_min_2 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + + # A3 a3 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a3_max = models.IntegerField(default=10) a3_min = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a3_name = models.TextField(default='', blank=True) + # Alternate value for a3 + a3_2 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + a3_max_2 = models.IntegerField(default=10) + a3_min_2 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + + # A4 a4 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a4_max = models.IntegerField(default=10) a4_min = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a4_name = models.TextField(default='', blank=True) - a5 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - a5_max = models.IntegerField(default=10) - a5_min = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - - a1_2 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - a1_max_2 = models.IntegerField(default=10) - a1_min_2 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - a2_2 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - a2_max_2 = models.IntegerField(default=10) - a2_min_2 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - a3_2 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) - a3_max_2 = models.IntegerField(default=10) - a3_min_2 = models.DecimalField( - max_digits=12, decimal_places=4, default=Decimal('0')) + # Alternate value for a4 a4_2 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a4_max_2 = models.IntegerField(default=10) a4_min_2 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) + + # A5 + a5 = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + a5_max = models.IntegerField(default=10) + a5_min = models.DecimalField( + max_digits=12, decimal_places=4, default=Decimal('0')) + a5_name = models.TextField(default='', blank=True) + # Alternate value for a5 a5_2 = models.DecimalField( max_digits=12, decimal_places=4, default=Decimal('0')) a5_max_2 = models.IntegerField(default=10) diff --git a/media/js/src/GraphEditor.jsx b/media/js/src/GraphEditor.jsx index e4d380a95..7eae46443 100644 --- a/media/js/src/GraphEditor.jsx +++ b/media/js/src/GraphEditor.jsx @@ -458,33 +458,41 @@ GraphEditor.propTypes = { gAlpha: PropTypes.number, gA1: PropTypes.number, + gA1Name: PropTypes.string, gA1Max: PropTypes.number, gA1Min: PropTypes.number, - gA2: PropTypes.number, - gA2Max: PropTypes.number, - gA2Min: PropTypes.number, - gA3: PropTypes.number, - gA3Max: PropTypes.number, - gA3Min: PropTypes.number, - gA4: PropTypes.number, - gA4Max: PropTypes.number, - gA4Min: PropTypes.number, - gA5: PropTypes.number, - gA5Max: PropTypes.number, - gA5Min: PropTypes.number, - gA12: PropTypes.number, gA1Max2: PropTypes.number, gA1Min2: PropTypes.number, + + gA2: PropTypes.number, + gA2Name: PropTypes.string, + gA2Max: PropTypes.number, + gA2Min: PropTypes.number, gA22: PropTypes.number, gA2Max2: PropTypes.number, gA2Min2: PropTypes.number, + + gA3: PropTypes.number, + gA3Name: PropTypes.string, + gA3Max: PropTypes.number, + gA3Min: PropTypes.number, gA32: PropTypes.number, gA3Max2: PropTypes.number, gA3Min2: PropTypes.number, + + gA4: PropTypes.number, + gA4Name: PropTypes.string, + gA4Max: PropTypes.number, + gA4Min: PropTypes.number, gA42: PropTypes.number, gA4Max2: PropTypes.number, gA4Min2: PropTypes.number, + + gA5: PropTypes.number, + gA5Name: PropTypes.string, + gA5Max: PropTypes.number, + gA5Min: PropTypes.number, gA52: PropTypes.number, gA5Max2: PropTypes.number, gA5Min2: PropTypes.number, @@ -517,7 +525,7 @@ GraphEditor.propTypes = { gXAxisMin: PropTypes.number, gYAxisMax: PropTypes.number, gYAxisMin: PropTypes.number, - + gXAxisMax2: PropTypes.number, gXAxisMin2: PropTypes.number, gYAxisMax2: PropTypes.number, diff --git a/media/js/src/GraphMapping.js b/media/js/src/GraphMapping.js index eda9ce000..3b716d637 100644 --- a/media/js/src/GraphMapping.js +++ b/media/js/src/GraphMapping.js @@ -67,33 +67,41 @@ const exportGraph = function(state) { omega: forceFloat(state.gOmega), a1: forceFloat(state.gA1), + a1_name: state.gA1Name, a1_max: forceFloat(state.gA1Max), a1_min: forceFloat(state.gA1Min), - a2: forceFloat(state.gA2), - a2_max: forceFloat(state.gA2Max), - a2_min: forceFloat(state.gA2Min), - a3: forceFloat(state.gA3), - a3_max: forceFloat(state.gA3Max), - a3_min: forceFloat(state.gA3Min), - a4: forceFloat(state.gA4), - a4_max: forceFloat(state.gA4Max), - a4_min: forceFloat(state.gA4Min), - a5: forceFloat(state.gA5), - a5_max: forceFloat(state.gA5Max), - a5_min: forceFloat(state.gA5Min), - a1_2: forceFloat(state.gA12), a1_max_2: forceFloat(state.gA1Max2), a1_min_2: forceFloat(state.gA1Min2), + + a2: forceFloat(state.gA2), + a2_name: state.gA2Name, + a2_max: forceFloat(state.gA2Max), + a2_min: forceFloat(state.gA2Min), a2_2: forceFloat(state.gA22), a2_max_2: forceFloat(state.gA2Max2), a2_min_2: forceFloat(state.gA2Min2), + + a3: forceFloat(state.gA3), + a3_name: state.gA3Name, + a3_max: forceFloat(state.gA3Max), + a3_min: forceFloat(state.gA3Min), a3_2: forceFloat(state.gA32), a3_max_2: forceFloat(state.gA3Max2), a3_min_2: forceFloat(state.gA3Min2), + + a4: forceFloat(state.gA4), + a4_name: state.gA4Name, + a4_max: forceFloat(state.gA4Max), + a4_min: forceFloat(state.gA4Min), a4_2: forceFloat(state.gA42), a4_max_2: forceFloat(state.gA4Max2), a4_min_2: forceFloat(state.gA4Min2), + + a5: forceFloat(state.gA5), + a5_name: state.gA5Name, + a5_max: forceFloat(state.gA5Max), + a5_min: forceFloat(state.gA5Min), a5_2: forceFloat(state.gA52), a5_max_2: forceFloat(state.gA5Max2), a5_min_2: forceFloat(state.gA5Min2), @@ -227,33 +235,41 @@ const convertGraph = function(json) { gOmega: forceFloat(json.omega), gA1: forceFloat(json.a1), + gA1Name: json.a1_name, gA1Max: forceFloat(json.a1_max), gA1Min: forceFloat(json.a1_min), - gA2: forceFloat(json.a2), - gA2Max: forceFloat(json.a2_max), - gA2Min: forceFloat(json.a2_min), - gA3: forceFloat(json.a3), - gA3Max: forceFloat(json.a3_max), - gA3Min: forceFloat(json.a3_min), - gA4: forceFloat(json.a4), - gA4Max: forceFloat(json.a4_max), - gA4Min: forceFloat(json.a4_min), - gA5: forceFloat(json.a5), - gA5Max: forceFloat(json.a5_max), - gA5Min: forceFloat(json.a5_min), - gA12: forceFloat(json.a1_2), gA1Max2: forceFloat(json.a1_max_2), gA1Min2: forceFloat(json.a1_min_2), + + gA2: forceFloat(json.a2), + gA2Name: json.a2_name, + gA2Max: forceFloat(json.a2_max), + gA2Min: forceFloat(json.a2_min), gA22: forceFloat(json.a2_2), gA2Max2: forceFloat(json.a2_max_2), gA2Min2: forceFloat(json.a2_min_2), + + gA3: forceFloat(json.a3), + gA3Name: json.a3_name, + gA3Max: forceFloat(json.a3_max), + gA3Min: forceFloat(json.a3_min), gA32: forceFloat(json.a3_2), gA3Max2: forceFloat(json.a3_max_2), gA3Min2: forceFloat(json.a3_min_2), + + gA4: forceFloat(json.a4), + gA4Name: json.a4_name, + gA4Max: forceFloat(json.a4_max), + gA4Min: forceFloat(json.a4_min), gA42: forceFloat(json.a4_2), gA4Max2: forceFloat(json.a4_max_2), gA4Min2: forceFloat(json.a4_min_2), + + gA5: forceFloat(json.a5), + gA5Name: json.a5_name, + gA5Max: forceFloat(json.a5_max), + gA5Min: forceFloat(json.a5_min), gA52: forceFloat(json.a5_2), gA5Max2: forceFloat(json.a5_max_2), gA5Min2: forceFloat(json.a5_min_2), @@ -375,33 +391,41 @@ const importGraph = function(json, obj, callback=null) { gOmega: forceFloat(json.omega), gA1: forceFloat(json.a1), + gA1Name: json.a1_name, gA1Max: forceFloat(json.a1_max), gA1Min: forceFloat(json.a1_min), - gA2: forceFloat(json.a2), - gA2Max: forceFloat(json.a2_max), - gA2Min: forceFloat(json.a2_min), - gA3: forceFloat(json.a3), - gA3Max: forceFloat(json.a3_max), - gA3Min: forceFloat(json.a3_min), - gA4: forceFloat(json.a4), - gA4Max: forceFloat(json.a4_max), - gA4Min: forceFloat(json.a4_min), - gA5: forceFloat(json.a5), - gA5Max: forceFloat(json.a5_max), - gA5Min: forceFloat(json.a5_min), - gA12: forceFloat(json.a1_2), gA1Max2: forceFloat(json.a1_max_2), gA1Min2: forceFloat(json.a1_min_2), + + gA2: forceFloat(json.a2), + gA2Name: json.a2_name, + gA2Max: forceFloat(json.a2_max), + gA2Min: forceFloat(json.a2_min), gA22: forceFloat(json.a2_2), gA2Max2: forceFloat(json.a2_max_2), gA2Min2: forceFloat(json.a2_min_2), + + gA3: forceFloat(json.a3), + gA3Name: json.a3_name, + gA3Max: forceFloat(json.a3_max), + gA3Min: forceFloat(json.a3_min), gA32: forceFloat(json.a3_2), gA3Max2: forceFloat(json.a3_max_2), gA3Min2: forceFloat(json.a3_min_2), + + gA4: forceFloat(json.a4), + gA4Name: json.a4_name, + gA4Max: forceFloat(json.a4_max), + gA4Min: forceFloat(json.a4_min), gA42: forceFloat(json.a4_2), gA4Max2: forceFloat(json.a4_max_2), gA4Min2: forceFloat(json.a4_min_2), + + gA5: forceFloat(json.a5), + gA5Name: json.a5_name, + gA5Max: forceFloat(json.a5_max), + gA5Min: forceFloat(json.a5_min), gA52: forceFloat(json.a5_2), gA5Max2: forceFloat(json.a5_max_2), gA5Min2: forceFloat(json.a5_min_2), @@ -427,7 +451,7 @@ const importGraph = function(json, obj, callback=null) { gXAxisMin2: forceFloat(json.x_axis_min_2), gYAxisMax2: forceFloat(json.y_axis_max_2), gYAxisMin2: forceFloat(json.y_axis_min_2), - + gXAxis2Label: json.x_axis_2_label, gYAxis2Label: json.y_axis_2_label, @@ -536,33 +560,41 @@ const defaultEvaluation = { omega: 1, a1: 2.5, + a1_name: '', a1_max: 10, a1_min: 0, - a2: 2, - a2_max: 10, - a2_min: 0, - a3: 0.5, - a3_max: 10, - a3_min: 0, - a4: 0, - a4_max: 10, - a4_min: 0, - a5: 0.5, - a5_max: 10, - a5_min: 0, - a1_2: 2.5, a1_max_2: 10, a1_min_2: 0, + + a2: 2, + a2_name: '', + a2_max: 10, + a2_min: 0, a2_2: 2, a2_max_2: 10, a2_min_2: 0, + + a3: 0.5, + a3_name: '', + a3_max: 10, + a3_min: 0, a3_2: 0.5, a3_max_2: 10, a3_min_2: 0, + + a4: 0, + a4_name: '', + a4_max: 10, + a4_min: 0, a4_2: 0, a4_max_2: 10, a4_min_2: 0, + + a5: 0.5, + a5_name: '', + a5_max: 10, + a5_min: 0, a5_2: 0.5, a5_max_2: 10, a5_min_2: 0, @@ -733,33 +765,41 @@ const defaultGraph = { gOmega: 1, gA1: null, + gA1Name: '', gA1Min: 0, gA1Max: 10, - gA2: null, - gA2Min: 0, - gA2Max: 10, - gA3: null, - gA3Min: 0, - gA3Max: 10, - gA4: null, - gA4Min: 0, - gA4Max: 10, - gA5: null, - gA5Min: 0, - gA5Max: 10, - gA12: null, gA1Min2: 0, gA1Max2: 10, + + gA2: null, + gA2Name: '', + gA2Min: 0, + gA2Max: 10, gA22: null, gA2Min2: 0, gA2Max2: 10, + + gA3: null, + gA3Name: '', + gA3Min: 0, + gA3Max: 10, gA32: null, gA3Min2: 0, gA3Max2: 10, + + gA4: null, + gA4Name: '', + gA4Min: 0, + gA4Max: 10, gA42: null, gA4Min2: 0, gA4Max2: 10, + + gA5: null, + gA5Name: '', + gA5Min: 0, + gA5Max: 10, gA52: null, gA5Min2: 0, gA5Max2: 10, diff --git a/media/js/src/GraphViewer.jsx b/media/js/src/GraphViewer.jsx index e60c5cb47..ea8527551 100644 --- a/media/js/src/GraphViewer.jsx +++ b/media/js/src/GraphViewer.jsx @@ -467,16 +467,29 @@ GraphViewer.propTypes = { gAlpha: PropTypes.number, gA1: PropTypes.number, + gA1Name: PropTypes.string, gA1Initial: PropTypes.number, + gA2: PropTypes.number, + gA2Name: PropTypes.string, gA2Initial: PropTypes.number, + gA3: PropTypes.number, + gA3Name: PropTypes.string, gA3Initial: PropTypes.number, + gA4: PropTypes.number, + gA4Name: PropTypes.string, gA4Initial: PropTypes.number, + gA5: PropTypes.number, + gA5Name: PropTypes.string, gA5Initial: PropTypes.number, + gA6: PropTypes.number, + gA7: PropTypes.number, + gA8: PropTypes.number, + gA: PropTypes.number, gK: PropTypes.number, gR: PropTypes.number, diff --git a/media/js/src/JXGBoard.jsx b/media/js/src/JXGBoard.jsx index b5d1a8ce4..bddcbdc14 100644 --- a/media/js/src/JXGBoard.jsx +++ b/media/js/src/JXGBoard.jsx @@ -293,10 +293,15 @@ export default class JXGBoard extends React.Component { 'gLine2OffsetYInitial', 'gLine3OffsetX', 'gLine3OffsetY', 'gLine3OffsetXInitial', 'gLine3OffsetYInitial', 'gLine4OffsetX', 'gLine4OffsetY', 'gLine4OffsetXInitial', 'gLine4OffsetYInitial', - 'gLine1Dashed', 'gLine2Dashed', 'gLine3Dashed', 'gAlpha', 'gA1', - 'gA1Initial', 'gA2', 'gA2Initial', 'gA3', 'gA3Initial', 'gA4', - 'gA4Initial', 'gA5', 'gA5Initial', + 'gLine1Dashed', 'gLine2Dashed', 'gLine3Dashed', 'gAlpha', + + 'gA1', 'gA1Initial', 'gA1Name', + 'gA2', 'gA2Initial', 'gA2Name', + 'gA3', 'gA3Initial', 'gA3Name', + 'gA4', 'gA4Initial', 'gA4Name', + 'gA5', 'gA5Initial', 'gA5Name', 'gA6', 'gA7', 'gA8', + 'gA', 'gK', 'gR', 'gY1', 'gY2', 'gCobbDouglasA', 'gCobbDouglasAInitial', 'gCobbDouglasAName', 'gCobbDouglasL', 'gCobbDouglasLInitial', 'gCobbDouglasLName', diff --git a/media/js/src/Viewer.jsx b/media/js/src/Viewer.jsx index d6355b807..847282aac 100644 --- a/media/js/src/Viewer.jsx +++ b/media/js/src/Viewer.jsx @@ -102,20 +102,30 @@ class Viewer extends Component { gAlpha={this.state.gAlpha} gA1={this.state.gA1} + gA1Name={this.state.gA1Name} gA1Max={this.state.gA1Max} gA1Min={this.state.gA1Min} + gA2={this.state.gA2} + gA2Name={this.state.gA2Name} gA2Max={this.state.gA2Max} gA2Min={this.state.gA2Min} + gA3={this.state.gA3} + gA3Name={this.state.gA3Name} gA3Max={this.state.gA3Max} gA3Min={this.state.gA3Min} + gA4={this.state.gA4} + gA4Name={this.state.gA4Name} gA4Max={this.state.gA4Max} gA4Min={this.state.gA4Min} + gA5={this.state.gA5} + gA5Name={this.state.gA5Name} gA5Max={this.state.gA5Max} gA5Min={this.state.gA5Min} + gA6={this.state.gA6} gA7={this.state.gA7} gA8={this.state.gA8} diff --git a/media/js/src/editors/CobbDouglasEditor.jsx b/media/js/src/editors/CobbDouglasEditor.jsx index 8ad53fab3..165da9d8f 100644 --- a/media/js/src/editors/CobbDouglasEditor.jsx +++ b/media/js/src/editors/CobbDouglasEditor.jsx @@ -7,10 +7,10 @@ import { handleFormUpdate } from '../utils.js'; export default class CobbDouglasEditor extends React.Component { render() { - let tex = String.raw`= ${this.props.gCobbDouglasAName}${this.props.gCobbDouglasKName}^\alpha ${this.props.gCobbDouglasLName}^{1 - \alpha}`; + let tex = String.raw`= ${this.props.gA1Name}${this.props.gA3Name}^\alpha ${this.props.gA2Name}^{1 - \alpha}`; if (!this.props.isInstructor) { - tex = String.raw`${this.props.gCobbDouglasYName} ${tex}`; + tex = String.raw`${this.props.gA5Name} ${tex}`; } return ( @@ -18,7 +18,7 @@ export default class CobbDouglasEditor extends React.Component {
This is a projection of the Cobb-Douglas function - with {this.props.gCobbDouglasLName} plotted along + with {this.props.gA2Name} plotted along the X-axis.