// Numbas version: exam_results_page_options {"name": "Transportation problem - stepping stones", "extensions": ["optimisation"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"variable_groups": [{"variables": ["num_sources", "num_destinations", "total"], "name": "Setup"}, {"variables": ["supply", "demand", "costs"], "name": "Initial data"}, {"variables": ["initial_assignment", "initial_cost"], "name": "Minimum costs"}, {"variables": ["final_assignment", "final_is_optimal", "final_cost"], "name": "Stepping stone"}], "variables": {"final_cost": {"group": "Stepping stone", "templateType": "anything", "definition": "assignment_cost(final_assignment,costs)", "description": "", "name": "final_cost"}, "costs": {"group": "Initial data", "templateType": "anything", "definition": "matrix(repeat(\n repeat(\n random(1..9),\n num_destinations\n ),\n num_sources\n))", "description": "", "name": "costs"}, "num_sources": {"group": "Setup", "templateType": "anything", "definition": "3", "description": "", "name": "num_sources"}, "final_is_optimal": {"group": "Stepping stone", "templateType": "anything", "definition": "assignment_is_optimal(final_assignment,costs)", "description": "", "name": "final_is_optimal"}, "initial_assignment": {"group": "Minimum costs", "templateType": "anything", "definition": "minimum_cost(supply,demand,costs)", "description": "", "name": "initial_assignment"}, "total": {"group": "Setup", "templateType": "anything", "definition": "random(50..500)", "description": "", "name": "total"}, "num_destinations": {"group": "Setup", "templateType": "anything", "definition": "4", "description": "", "name": "num_destinations"}, "initial_cost": {"group": "Minimum costs", "templateType": "anything", "definition": "assignment_cost(initial_assignment,costs)", "description": "", "name": "initial_cost"}, "final_assignment": {"group": "Stepping stone", "templateType": "anything", "definition": "stepping_stone(initial_assignment,costs)", "description": "", "name": "final_assignment"}, "supply": {"group": "Initial data", "templateType": "anything", "definition": "random_partition(total,num_sources)", "description": "", "name": "supply"}, "demand": {"group": "Initial data", "templateType": "anything", "definition": "random_partition(total,num_destinations)", "description": "", "name": "demand"}}, "ungrouped_variables": [], "name": "Transportation problem - stepping stones", "functions": {"show_variable_list": {"type": "string", "language": "javascript", "definition": "return data.map(function(n,i) {\n return '$'+name+'_{'+(i+1)+'} = '+Numbas.math.niceNumber(n)+'$';\n}).join(', ');", "parameters": [["data", "list"], ["name", "string"]]}}, "parts": [{"prompt": "

What is the cost of this initial assignment?

\n

£ [[0]]

", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "useCustomName": false, "customName": "", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "initial_cost", "useCustomName": false, "maxValue": "initial_cost", "unitTests": [], "showFractionHint": true, "correctAnswerStyle": "plain", "showFeedbackIcon": true, "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"prompt": "

Use the stepping stones method to find an optimal solution, and enter it below.

", "markPerCell": false, "useCustomName": false, "customName": "", "allowFractions": false, "correctAnswer": "final_assignment", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "constraints_unsatisfied:\n assert(assignment_is_valid(studentmatrix,supply,demand),\n incorrect(\"Your answer does not satisfy one of the constraints of supply or demand.\");\n end();\n true\n )\n\nis_optimal:\n if(assignment_is_optimal(studentmatrix, costs),\n correct(\"Your answer is optimal.\")\n ,\n incorrect(\"Your answer is not optimal.\")\n )\n\nmark:\n apply(any_empty);\n apply(any_invalid);\n apply(constraints_unsatisfied);\n apply(is_optimal)", "allowResize": false, "unitTests": [], "correctAnswerFractions": false, "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "matrix", "numColumns": "num_destinations", "tolerance": 0, "showCorrectAnswer": true, "variableReplacements": [], "marks": 1, "numRows": "num_sources"}, {"prompt": "

What is the cost of the optimal solution?

\n

£ [[0]]

", "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "useCustomName": false, "customName": "", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "customName": "", "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "final_cost", "useCustomName": false, "maxValue": "final_cost", "unitTests": [], "showFractionHint": true, "correctAnswerStyle": "plain", "showFeedbackIcon": true, "scripts": {}, "notationStyles": ["plain", "en", "si-en"], "type": "numberentry", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "showCorrectAnswer": true, "variableReplacements": [], "marks": 0, "sortAnswers": false}], "variablesTest": {"condition": "not assignment_is_optimal(initial_assignment,costs)", "maxRuns": 100}, "statement": "

Four power stations labelled $j = 1,2,3,4$ require {show_variable_list(demand,'b')} units of coal, respectively. These are to be provided by three pits labelled $i=1,2,3$, which have supplies of {show_variable_list(supply,'a')} units of coal, respectively.

\n

The cost $c_{ij}$, in pounds, of transporting one unit of coal from pit $i$ to power station $j$ is in the following table (with supplies and demand shown in the margin).

\n

{cost_table(supply,demand,costs)}

\n

The NW corner algorithm has been used to come up with an initial feasible solution, shown below.

\n

{assignment_table(initial_assignment,supply,demand)}

", "tags": [], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "extensions": ["optimisation"], "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": ""}, "advice": "

a)

\n

The cost of the initial solution is $\\var{show_cost_calculation(initial_assignment,costs)}$.

\n

b)

\n

The steps of the method are shown below.

\n

{stepping_stone_display(initial_assignment,costs)}

\n

At this point, no cells have shadow costs greater than their real costs, so the solution is optimal.

\n

c)

\n

The cost of the optimal solution is $\\var{show_cost_calculation(final_assignment,costs)}$.

", "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}]}], "contributors": [{"name": "Christian Lawson-Perfect", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/7/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}]}