// Numbas version: finer_feedback_settings {"name": "Luis's copy of Solve a linear programming problem", "extensions": ["jsxgraph", "optimisation"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"extensions": ["jsxgraph", "optimisation"], "statement": "
{business_long} ({business_short}) makes two products: {product_1s} and {product_2s}.
\nExisting orders require {business} to make at least {xconstraint} {product_1s} and {yconstraint} {product_2s} each day.
\nEach unit of {product_1s} produced uses {resource1x} {resource_1_units} {resource_1} and {resource2x} {resource_2_units} {resource_2}.
\nEach unit of {product_2s} produced uses {resource1y} {resource_1_units} {resource_1} and {resource2y} {resource_2_units} {resource_2}.
\nHowever, the resources are limited: {business} can only obtain {totalresource1} {resource_1_units} {resource_1} and {totalresource2} {resource_2_units} {resource_2} each day.
\nEach sale of a unit of {product_1s} gives £{profitx} profit. Each sale of a unit of {product_2s} gives £{profity} profit.
", "variablesTest": {"maxRuns": 100, "condition": ""}, "tags": ["constraints", "linear programming", "objective function", "template"], "metadata": {"description": "Student is given a set of constraints for a linear program. Asked to enter the constraints as inequalities, and then to identify the optimal solution.
\nProblem with solving the simultaneous equations gven by the constraints - too unwieldy and not given enough marks for doing so. Best if the point of intersection is given graphically by putting the mouse over the intersection.
", "licence": "Creative Commons Attribution 4.0 International"}, "parts": [{"showFeedbackIcon": true, "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "gaps": [{"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "xconstraint", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "xconstraint", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "yconstraint", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "yconstraint", "correctAnswerStyle": "plain"}], "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 0, "type": "gapfill", "showCorrectAnswer": true, "scripts": {}, "prompt": "Let $x$, $y$ be the number of units of {product_1s} and {product_2s} produced, respectively.
\nWhat are the constraints on production resulting from the existing orders?
\n$x \\geq$ [[0]]
\n$y \\geq$ [[1]]
"}, {"showFeedbackIcon": true, "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "gaps": [{"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "resource1x", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "resource1x", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "resource1y", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "resource1y", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "totalresource1", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "totalresource1", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "resource2x", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "resource2x", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "resource2y", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "resource2y", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [], "minValue": "totalresource2", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "totalresource2", "correctAnswerStyle": "plain"}], "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 0, "type": "gapfill", "showCorrectAnswer": true, "scripts": {}, "prompt": "Now enter the constraints given by the availability of {resource_1} and {resource_2}:
\n{capitalise(resource_1)}: [[0]] $x + $ [[1]] $y \\le $ [[2]]
\n{capitalise(resource_2)}: [[3]] $x + $ [[4]] $y \\le $ [[5]]
"}, {"showFeedbackIcon": true, "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "gaps": [{"checkVariableNames": false, "showFeedbackIcon": true, "marks": 1, "customMarkingAlgorithm": "", "showPreview": true, "answerSimplification": "all", "expectedVariableNames": [], "checkingAccuracy": 0.001, "failureRate": 1, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "checkingType": "absdiff", "extendBaseMarkingAlgorithm": true, "unitTests": [], "vsetRange": [0, 1], "type": "jme", "showCorrectAnswer": true, "vsetRangePoints": 5, "scripts": {}, "answer": "{profitx}*x+{profity}*y"}], "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 0, "type": "gapfill", "showCorrectAnswer": true, "scripts": {}, "prompt": "Given the information on profits for {product_1s} and {product_2s}, write down the objective function which is to be maximised: [[0]]
"}, {"showFeedbackIcon": true, "customMarkingAlgorithm": "", "sortAnswers": false, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "gaps": [{"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "alwaysreplace", "correctAnswerFraction": false, "variableReplacements": [{"part": "p0g0", "variable": "xconstraint", "must_go_first": true}, {"part": "p0g1", "variable": "yconstraint", "must_go_first": true}, {"part": "p1g0", "variable": "resource1x", "must_go_first": true}, {"part": "p1g1", "variable": "resource1y", "must_go_first": true}, {"part": "p1g2", "variable": "totalresource1", "must_go_first": true}, {"part": "p1g3", "variable": "resource2x", "must_go_first": true}, {"part": "p1g4", "variable": "resource2y", "must_go_first": true}, {"part": "p1g5", "variable": "totalresource2", "must_go_first": true}], "minValue": "best_x", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "best_x", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "alwaysreplace", "correctAnswerFraction": false, "variableReplacements": [{"part": "p0g0", "variable": "xconstraint", "must_go_first": true}, {"part": "p0g1", "variable": "yconstraint", "must_go_first": true}, {"part": "p1g0", "variable": "resource1x", "must_go_first": true}, {"part": "p1g1", "variable": "resource1y", "must_go_first": true}, {"part": "p1g2", "variable": "totalresource1", "must_go_first": true}, {"part": "p1g3", "variable": "resource2x", "must_go_first": true}, {"part": "p1g4", "variable": "resource2y", "must_go_first": true}, {"part": "p1g5", "variable": "totalresource2", "must_go_first": true}], "minValue": "best_y", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "best_y", "correctAnswerStyle": "plain"}, {"showFeedbackIcon": true, "allowFractions": false, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "mustBeReducedPC": 0, "variableReplacementStrategy": "originalfirst", "correctAnswerFraction": false, "variableReplacements": [{"part": "p3g0", "variable": "best_x", "must_go_first": false}, {"part": "p3g1", "variable": "best_y", "must_go_first": false}], "minValue": "best_profit", "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 1, "type": "numberentry", "mustBeReduced": false, "notationStyles": ["plain", "en", "si-en"], "scripts": {}, "maxValue": "best_profit", "correctAnswerStyle": "plain"}], "extendBaseMarkingAlgorithm": true, "unitTests": [], "marks": 0, "type": "gapfill", "showCorrectAnswer": true, "scripts": {}, "prompt": "Input diagram goes here
\nDrag the objective line on the diagram above to find the position which gives the maximum profit.
\nRound your answers down to the nearest integer, end enter them below:
\nProduce [[0]] {product_1s} and [[1]] {product_2s}, earning £ [[2]] in profit.
"}], "ungrouped_variables": [], "name": "Luis's copy of Solve a linear programming problem", "advice": "The existing orders give two constraints:
\n\\begin{align}
x &\\geq \\var{xconstraint} \\\\
y &\\geq \\var{yconstraint}
\\end{align}
The limits on the two resources, and the amounts of each resource used to produce a unit of each product, give two further constraints:
\n\\begin{align}
\\simplify{{resource1x}x + {resource1y}y} &\\leq \\var{totalresource1} \\\\
\\simplify{{resource2x}x + {resource2y}y} &\\leq \\var{totalresource2}
\\end{align}
The objective function to be maximised is the total profit earned, that is, the sum of the profits earned from each unit made:
\n\\[ \\simplify{{profitx}x + {profity}y} \\]
\nThe solution graph goes here
\nIt is clear that the minimum profit is given by producing enough {product_1s} and {product_2s} so that the existing demand is met and no more. You can see this by moving the objective function line down to the intersection of the two minimum constraint lines - there are no other points inside the feasible region under the objective line.
\nNext, drag the objective function line upwards until there are no points above the objective line in the feasible region. At this point, the objective line touches the intersection of the lines representing the constraints for {line_names[best_lines[0]]} and {line_names[best_lines[1]]}.
\nYou can find the coordinates of this point by solving the equations for these two lines:
\n\\[ \\simplify{{resource1x}x + {resource1y}y = {totalresource1}} \\]\\[ \\simplify{{resource2x}x + {resource2y}y = {totalresource2}} \\]
\n\\[ \\simplify{{resource2x}x + {resource2y}y = {totalresource2}} \\]\\[ x = \\var{xconstraint} \\]\\[ y = \\var{yconstraint} \\]
\nThe solution to this system of equations is $x = \\var{best_x}$, $y = \\var{best_y}$, giving a profit of
\n\\[ \\text{Profit} = \\simplify[]{{profitx}*{best_x} + {profity}*{best_y}} = \\text{£}\\var{best_profit} \\]
", "variables": {"best_profit_float": {"name": "best_profit_float", "definition": "profit(best_x_float,best_y_float)", "group": "Optimum strategy", "description": "The profit at the best intersection point, if fractions of units are allowed
", "templateType": "anything"}, "constraint2xvalue": {"name": "constraint2xvalue", "definition": "round(scalingfactor2*resource2y+xconstraint)", "group": "Bounds", "description": "Where the constraint line for resource 2 cuts the y-constraint
", "templateType": "anything"}, "resource2y": {"name": "resource2y", "definition": "\nrandom(1500..3000#100)", "group": "Constraints", "description": "How much of resource 2 the second product uses per unit
", "templateType": "anything"}, "totalresource2": {"name": "totalresource2", "definition": "siground(\n scalingfactor2*resource2x*resource2y +\n resource2y*yconstraint +\n resource2x*xconstraint\n,3)", "group": "Constraints", "description": "Total amount of resource 2 available
", "templateType": "anything"}, "constraint1yvalue": {"name": "constraint1yvalue", "definition": "r2+constraint2yvalue", "group": "Bounds", "description": "Where line given by resource 1 constraint cuts the x-constraint line.
\nIt is always greater than the point at which the second resource line cuts.
", "templateType": "anything"}, "resource_1_units": {"name": "resource_1_units", "definition": "\"kg\"", "group": "Text strings", "description": "Dimension of the first resource
", "templateType": "string"}, "product_1s": {"name": "product_1s", "definition": "\"bulletproof tea cosies\"", "group": "Text strings", "description": "Plural name of the first product
", "templateType": "string"}, "best_y": {"name": "best_y", "definition": "floor(best_y_float)", "group": "Optimum strategy", "description": "The integer number of units of the second product to produce to earn the highest profit
", "templateType": "anything"}, "resource1y": {"name": "resource1y", "definition": "random(50..70)", "group": "Constraints", "description": "How much of resource 1 the second product uses per unit
", "templateType": "anything"}, "xconstraint": {"name": "xconstraint", "definition": "\nrandom(4..10)", "group": "Constraints", "description": "Minimum production of the first product
", "templateType": "anything"}, "resource_2_units": {"name": "resource_2_units", "definition": "\"tonnes\"", "group": "Text strings", "description": "Dimension of the second resource
", "templateType": "string"}, "best_x_float": {"name": "best_x_float", "definition": "intersection_points[best_point][0]", "group": "Optimum strategy", "description": "The number of units of X to produce to earn the highest profit, if fractions are allowed
", "templateType": "anything"}, "constraint2yvalue": {"name": "constraint2yvalue", "definition": "r1+yconstraint", "group": "Bounds", "description": "Where the constraint line for the second resource cuts the x-constraint.
\nSecond resource line cuts x-constraint at a point greater than the y-constraint
", "templateType": "anything"}, "constraint1xvalue": {"name": "constraint1xvalue", "definition": "round(scalingfactor1*resource1y+xconstraint)", "group": "Bounds", "description": "Where the constraint line for resource 1 crosses the y-constraint
", "templateType": "anything"}, "profity": {"name": "profity", "definition": "//the coeff of y in the objective function\nceil(profitx*(resource1y/resource1x)*random(1.5..3))", "group": "Profit", "description": "Profit for each unit of the second product sold
", "templateType": "anything"}, "r1": {"name": "r1", "definition": "random(10..20)", "group": "Constraints", "description": "The second constraint line cuts the x-constraint line at this value more than the y-constraint
", "templateType": "anything"}, "best_profit": {"name": "best_profit", "definition": "profit(best_x,best_y)", "group": "Optimum strategy", "description": "The profit at the best intersection point
", "templateType": "anything"}, "product_2": {"name": "product_2", "definition": "\"double-edged cardigan\"", "group": "Text strings", "description": "Singular name of the second product
", "templateType": "string"}, "resource2x": {"name": "resource2x", "definition": "\nrandom(250..450#10)", "group": "Constraints", "description": "How much of resource 2 the first product uses per unit
", "templateType": "anything"}, "resource_2": {"name": "resource_2", "definition": "\"iron\"", "group": "Text strings", "description": "The name of the second resource
", "templateType": "string"}, "line_names": {"name": "line_names", "definition": "[ \"the amount of resource 1 used\", \"the amount of resource 2 used\", \"the minimum amount of X produced\", \"the maximum amount of Y produced\" ]", "group": "Optimum strategy", "description": "Names of the lines, coded as in the definition of best_lines
A shorter name for the business, to be repeated throughout the text. If the business name is short enough for repeated use, leave this empty.
", "templateType": "string"}, "resource_1": {"name": "resource_1", "definition": "\"wool\"", "group": "Text strings", "description": "The name of the first resource
", "templateType": "string"}, "best_lines": {"name": "best_lines", "definition": "[[0,2],[1,2],[0,3],[1,3],[0,1]][best_point]", "group": "Optimum strategy", "description": "Which lines are involed in the best point? Coded as follows:
\n0 - resource 1
\n1 - resource 2
\n2 - minimum x
\n3 - minimum y
\nNote that (minimum x,minimum y) is never the best point
", "templateType": "anything"}, "boundx": {"name": "boundx", "definition": "max(constraint1xvalue,constraint2xvalue)", "group": "Bounds", "description": "Right bound of the diagram
", "templateType": "anything"}, "yconstraint": {"name": "yconstraint", "definition": "random(4..10)", "group": "Constraints", "description": "Minimum production of the second product
", "templateType": "anything"}, "scalingfactor2": {"name": "scalingfactor2", "definition": "precround((r1)/resource2x,2)", "group": "Constraints", "description": "", "templateType": "anything"}, "scalingfactor1": {"name": "scalingfactor1", "definition": "precround((r1+r2)/resource1x,1)", "group": "Constraints", "description": "", "templateType": "anything"}, "r2": {"name": "r2", "definition": "random(5..15)", "group": "Constraints", "description": "The first constraint line cuts the x-constraint line at this value greater than where the second constraint cuts.
", "templateType": "anything"}, "business_long": {"name": "business_long", "definition": "\"Amalgamated Mines and Sheep, Inc.\"", "group": "Text strings", "description": "The full name of the business
", "templateType": "string"}, "profits": {"name": "profits", "definition": "map(let(x,p[0],y,p[1],profitx*x+profity*y),p,intersection_points)", "group": "Optimum strategy", "description": "Profit earned at each intersection point
", "templateType": "anything"}, "best_y_float": {"name": "best_y_float", "definition": "intersection_points[best_point][1]", "group": "Optimum strategy", "description": "The number of units of the second product to produce to earn the highest profit, if fractions are allowed
", "templateType": "anything"}, "product_1": {"name": "product_1", "definition": "\"bulletproof tea cosy\"", "group": "Text strings", "description": "Singular name of the first product
", "templateType": "string"}, "totalresource1": {"name": "totalresource1", "definition": "siground(\n scalingfactor1*resource1x*resource1y +\n resource1y*yconstraint +\n resource1x*xconstraint\n,3)", "group": "Constraints", "description": "Total amount of resource 1 available
", "templateType": "anything"}, "possible_points": {"name": "possible_points", "definition": "filter(\n let(x,floor(intersection_points[j][0]),y,floor(intersection_points[j][1]),\n resource1x*x+resource1y*y <= totalresource1+1 and \n resource2x*x+resource2y*y <= totalresource2+1 and\n x>=xconstraint and\n y>=yconstraint\n ),\n j,\n 0..len(intersection_points)-1\n)", "group": "Optimum strategy", "description": "Indices of intersection points which satisfy all the constraints.
", "templateType": "anything"}, "resource1x": {"name": "resource1x", "definition": "random(20..40)", "group": "Constraints", "description": "How much of resource 1 the first product uses per unit
", "templateType": "anything"}, "intersection_points": {"name": "intersection_points", "definition": "[\n [xconstraint, (totalresource1-resource1x*xconstraint)/resource1y], //resource 1 intersecting with minimum x\n [xconstraint, (totalresource2-resource2x*xconstraint)/resource2y], //resource 2 intersecting with minimum x\n [(totalresource1-resource1y*yconstraint)/resource1x, yconstraint], //resource 1 intersecting with minimum y\n [(totalresource2-resource2y*yconstraint)/resource2x, yconstraint], //resource 2 intersecting with minimum y\n let(y, (totalresource1-totalresource2*resource1x/resource2x)/(resource1y - resource1x/resource2x * resource2y),\n [(totalresource1-resource1y*y)/resource1x, y] // intersection of the two resource constraints\n )\n]", "group": "Optimum strategy", "description": "Intersection points of the constraints - the optimum strategy will be one of these
", "templateType": "anything"}, "business": {"name": "business", "definition": "if(business_short=\"\",business_long,business_short)", "group": "Text strings", "description": "", "templateType": "anything"}, "best_x": {"name": "best_x", "definition": "floor(best_x_float)", "group": "Optimum strategy", "description": "The integer number of units of the first product to produce to earn the highest profit
", "templateType": "anything"}, "boundy": {"name": "boundy", "definition": "max(constraint1yvalue,constraint2yvalue)", "group": "Bounds", "description": "Upper bound of the diagram
", "templateType": "anything"}, "profitx": {"name": "profitx", "definition": "//the coeff of x in the objective function\nrandom(2..4)", "group": "Profit", "description": "Profit for each unit of the first product sold
", "templateType": "anything"}, "best_point": {"name": "best_point", "definition": "best_by(possible_points,profits)", "group": "Optimum strategy", "description": "The index of the valid intersection point with the highest profit
", "templateType": "anything"}, "product_2s": {"name": "product_2s", "definition": "\"double-edged cardigans\"", "group": "Text strings", "description": "Plural name of the second product
", "templateType": "string"}}, "preamble": {"js": "function userinput_diagram() {\n\nwith(question.unwrappedVariables) {\n\n var options = {\n x_bound: boundx, \n y_bound: boundy\n };\n\n options.objective_line_coordinates = [[0,0],[1,-profitx/profity]];\n \n function getStudentAnswer(path) {\n var part = question.getPart(path);\n return ko.computed(function() {\n return parseFloat(part.display.studentAnswer());\n });\n }\n \n options.minimum_x = getStudentAnswer('p0g0');\n options.minimum_y = getStudentAnswer('p0g1');\n\n var x_coefficient_1 = getStudentAnswer('p1g0');\n var y_coefficient_1 = getStudentAnswer('p1g1');\n var total_1 = getStudentAnswer('p1g2');\n options.inequality_1_coordinates = [ko.computed(function() {\n return [-total_1(),x_coefficient_1(),y_coefficient_1()];\n })];\n\n options.inequality_1_ok = ko.computed(function() {\n return !(isNaN(x_coefficient_1()) || isNaN(y_coefficient_1()) || isNaN(total_1()));\n });\n\n var x_coefficient_2 = getStudentAnswer('p1g3');\n var y_coefficient_2 = getStudentAnswer('p1g4');\n var total_2 = getStudentAnswer('p1g5');\n options.inequality_2_coordinates = [ko.computed(function() {\n return [-total_2(),x_coefficient_2(),y_coefficient_2()];\n })];\n\n options.inequality_2_ok = ko.computed(function() {\n return !(isNaN(x_coefficient_2()) || isNaN(y_coefficient_2()) || isNaN(total_2()));\n });\n\n var result = Numbas.extensions.optimisation.linear_programming_board(options);\n $(question.display.html).find('.lp-graph').html('').append(result.div);\n}\n}\n\nfunction advice_diagram() {\nwith(question.unwrappedVariables) {\n\n var result = Numbas.extensions.optimisation.linear_programming_board({\n x_bound: boundx,\n y_bound: boundy,\n objective_line_coordinates: [[0,best_profit_float/profity],[1,(best_profit_float-profitx)/profity]],\n minimum_x: xconstraint,\n minimum_y: yconstraint,\n inequality_1_coordinates: [-totalresource1, resource1x, resource1y],\n inequality_2_coordinates: [-totalresource2, resource2x, resource2y]\n });\n $(question.display.html).find('#advicediagram').html('').append(result.div);\n}\n}\n\nquestion.signals.on('HTMLAttached',function() {\n userinput_diagram();\n advice_diagram();\n});\n", "css": ""}, "functions": {"profit": {"language": "jme", "definition": "profitx*x+profity*y", "parameters": [["x", "number"], ["y", "number"]], "type": "number"}, "best_by": {"language": "javascript", "definition": "// l1 is a list of indices on l2\n// return the element of l1 which has the biggest corresponding value in l2 \n// (i.e. i such that l2[l1[i]] is biggest)\n\nvar best_1 = null;\nvar best_2 = null;\nfor(var i=0;i