// Numbas version: exam_results_page_options {"questions": [{"variable_groups": [{"variables": ["num_sources", "num_destinations", "total"], "name": "Setup"}, {"variables": ["supply", "demand", "costs"], "name": "Initial data"}, {"variables": ["assignment", "assignment_cost"], "name": "Minimum costs"}], "variables": {"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": "random(3..5)", "description": "", "name": "num_sources"}, "supply": {"group": "Initial data", "templateType": "anything", "definition": "random_partition(total,num_sources)", "description": "", "name": "supply"}, "num_destinations": {"group": "Setup", "templateType": "anything", "definition": "7-num_sources+random(0,1)", "description": "", "name": "num_destinations"}, "assignment_cost": {"group": "Minimum costs", "templateType": "anything", "definition": "assignment_cost(assignment,costs)", "description": "", "name": "assignment_cost"}, "total": {"group": "Setup", "templateType": "anything", "definition": "random(50..500)", "description": "", "name": "total"}, "assignment": {"group": "Minimum costs", "templateType": "anything", "definition": "minimum_cost(supply,demand,costs)", "description": "", "name": "assignment"}, "demand": {"group": "Initial data", "templateType": "anything", "definition": "random_partition(total,num_destinations)", "description": "", "name": "demand"}}, "ungrouped_variables": [], "name": "Transportation problem - apply minimum cost algorithm - MAS1901", "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": [{"showCorrectAnswer": true, "allowFractions": false, "correctAnswer": "assignment", "variableReplacementStrategy": "originalfirst", "prompt": "
Apply the minimum cost algorithm to find an assignment of units of coal to be transported between pits and power stations.
\nWhen there's more than one choice of cell, choose the cell with the maximum available allocation.
", "correctAnswerFractions": false, "allowResize": false, "numRows": "num_sources", "scripts": {}, "type": "matrix", "numColumns": "num_destinations", "tolerance": 0, "markPerCell": false, "variableReplacements": [], "marks": 1}, {"correctAnswerFraction": false, "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "assignment_cost", "prompt": "What is the total cost of this solution?
", "showPrecisionHint": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "variableReplacements": [{"part": "p0", "must_go_first": false, "variable": "assignment"}], "marks": 1, "maxValue": "assignment_cost"}], "variablesTest": {"condition": "", "maxRuns": "3000"}, "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.
\nThe cost $c_{ij}$ 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)}
", "tags": [], "rulesets": {}, "preamble": {"css": "", "js": ""}, "metadata": {"notes": "", "licence": "None specified", "description": ""}, "advice": "The following tables show each step of the minimum cost algorithm:
\n{minimum_cost_display(supply,demand,costs)}
\nThe total cost of this solution is $\\var{show_cost_calculation(assignment,costs)}$.
"}, {"variable_groups": [{"variables": ["num_sources", "num_destinations", "total", "omit_source", "show_sources", "show_destinations"], "name": "Setup"}, {"variables": ["supply", "demand", "costs", "show_supply", "show_demand", "show_costs", "dummy_resource"], "name": "Initial data"}, {"variables": ["assignment", "assignment_cost", "show_assignment"], "name": "Minimum costs"}], "variables": {"show_assignment": {"group": "Minimum costs", "templateType": "anything", "definition": "matrix(map(\n map(\n assignment[x][y],\n y,\n 0..show_destinations-1\n ),\n x,\n 0..show_sources-1\n))", "description": "", "name": "show_assignment"}, "costs": {"group": "Initial data", "templateType": "anything", "definition": "matrix(map(\n map(\n if(xpower station
"], "showCorrectAnswer": true, "matrix": "if(omit_source,[1,0],[0,1])", "distractors": ["", ""], "variableReplacements": [], "shuffleChoices": false, "scripts": {}, "maxMarks": 0, "type": "1_n_2", "minMarks": 0, "variableReplacementStrategy": "originalfirst", "displayColumns": 0, "marks": 0}, {"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "dummy_resource", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "maxValue": "dummy_resource"}, {"showCorrectAnswer": true, "allowFractions": false, "correctAnswer": "costs", "variableReplacementStrategy": "originalfirst", "allowResize": true, "correctAnswerFractions": false, "numRows": 1, "scripts": {}, "type": "matrix", "numColumns": 1, "tolerance": 0, "markPerCell": false, "variableReplacements": [], "marks": 1}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "prompt": "By adding dummy sources or destinations, balance this problem.
\nThe balanced problem adds another [[0]] with [[1]] units of coal.
\nEnter the cost matrix for the balanced problem below.
\n[[2]]
", "variableReplacements": [], "marks": 0}, {"showCorrectAnswer": true, "allowFractions": false, "correctAnswer": "show_assignment", "variableReplacementStrategy": "originalfirst", "prompt": "Apply the minimum cost algorithm to your balanced problem to find an assignment of units of coal to be transported between pits and power stations.
\nWhen there's more than one choice of cell, choose the cell with the maximum available allocation.
", "correctAnswerFractions": false, "allowResize": false, "numRows": "show_sources", "scripts": {}, "type": "matrix", "numColumns": "show_destinations", "tolerance": 0, "markPerCell": false, "variableReplacements": [{"part": "p0g2", "must_go_first": false, "variable": "costs"}], "marks": 1}, {"showCorrectAnswer": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "assignment_cost", "variableReplacementStrategy": "originalfirst", "variableReplacements": [{"part": "p1", "must_go_first": false, "variable": "assignment"}], "marks": 1, "maxValue": "assignment_cost"}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "prompt": "What is the total cost of this solution?
\n£ [[0]]
", "variableReplacements": [], "marks": 0}], "variablesTest": {"condition": "", "maxRuns": 100}, "statement": "Four power stations labelled $j = 1,2,3,4$ require {show_variable_list(show_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(show_supply,'a')} units of coal, respectively.
\nThe 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(show_supply,show_demand,show_costs)}
", "tags": [], "rulesets": {}, "preamble": {"css": "", "js": ""}, "metadata": {"notes": "", "licence": "None specified", "description": ""}, "advice": "The total supply is {sum(show_supply)}, while the total demand is {sum(show_demand)}, so we need to add a dummy {if(omit_source,'pit supplying','power station demanding')} {dummy_resource} units of coal.
\nThe cost matrix then looks like this:
\n{cost_table(supply,demand,costs)}
\nThe following tables show each step of the minimum cost algorithm:
\n{minimum_cost_display(supply,demand,costs)}
\nThe total cost of this solution is $\\var{show_cost_calculation(assignment,costs)}$.
"}, {"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_assignment": {"group": "Stepping stone", "templateType": "anything", "definition": "stepping_stone(initial_assignment,costs)", "description": "", "name": "final_assignment"}, "initial_assignment": {"group": "Minimum costs", "templateType": "anything", "definition": "minimum_cost(supply,demand,costs)", "description": "", "name": "initial_assignment"}, "num_sources": {"group": "Setup", "templateType": "anything", "definition": "3", "description": "", "name": "num_sources"}, "final_cost": {"group": "Stepping stone", "templateType": "anything", "definition": "assignment_cost(final_assignment,costs)", "description": "", "name": "final_cost"}, "final_is_optimal": {"group": "Stepping stone", "templateType": "anything", "definition": "assignment_is_optimal(final_assignment,costs)", "description": "", "name": "final_is_optimal"}, "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_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"}, "total": {"group": "Setup", "templateType": "anything", "definition": "random(50..500)", "description": "", "name": "total"}, "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 - MAS1901", "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": [{"showCorrectAnswer": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "initial_cost", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "maxValue": "initial_cost"}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "prompt": "What is the cost of this initial assignment?
\n£ [[0]]
", "variableReplacements": [], "marks": 0}, {"showCorrectAnswer": true, "allowFractions": false, "correctAnswer": "final_assignment", "variableReplacementStrategy": "originalfirst", "prompt": "Use the stepping stones method to find an optimal solution, and enter it below.
", "correctAnswerFractions": false, "allowResize": false, "numRows": "num_sources", "scripts": {"mark": {"script": "var validation = this.validation;\nvar optimisation = Numbas.extensions.optimisation;\n\nvar studentMatrix = this.studentAnswerAsMatrix();\n\nif(studentMatrix===null) {\n this.setCredit(0,R('part.matrix.invalid cell'));\n validation.invalidCell = true;\n return;\n} else {\n validation.invalidCell = false;\n}\n\nif(!optimisation.assignment_is_valid(studentMatrix,variables.supply,variables.demand)) {\n this.setCredit(0,\"Your answer does not satisfy one of the constraints of supply or demand.\");\n return;\n}\n\nthis.answered = true;\n\nif(optimisation.assignment_is_optimal(studentMatrix,null,variables.costs)) {\n this.setCredit(1,\"Your answer is optimal.\");\n return;\n} else {\n this.setCredt(0,\"Your answer is not optimal.\");\n return;\n}\n\n", "order": "instead"}}, "type": "matrix", "numColumns": "num_destinations", "tolerance": 0, "markPerCell": false, "variableReplacements": [], "marks": 1}, {"showCorrectAnswer": true, "scripts": {}, "gaps": [{"correctAnswerFraction": false, "showPrecisionHint": false, "allowFractions": false, "scripts": {}, "type": "numberentry", "showCorrectAnswer": true, "minValue": "final_cost", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "maxValue": "final_cost"}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "prompt": "What is the cost of the optimal solution?
\n£ [[0]]
", "variableReplacements": [], "marks": 0}], "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.
\nThe 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)}
\nThe 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": ""}, "metadata": {"notes": "", "licence": "None specified", "description": ""}, "advice": "The cost of the initial solution is $\\var{show_cost_calculation(initial_assignment,costs)}$.
\nThe steps of the method are shown below.
\n{stepping_stone_display(initial_assignment,costs)}
\nAt this point, no cells have shadow costs greater than their real costs, so the solution is optimal.
\nThe cost of the optimal solution is $\\var{show_cost_calculation(final_assignment,costs)}$.
"}], "duration": 0, "name": "Transportation problems", "showQuestionGroupNames": false, "allQuestions": true, "resources": [], "percentPass": 0, "feedback": {"showanswerstate": true, "advicethreshold": 0, "showactualmark": true, "allowrevealanswer": true, "showtotalmark": true}, "shuffleQuestions": false, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"name": "Transportation problem - apply minimum cost algorithm", "extensions": ["optimisation"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [{"variables": ["num_sources", "num_destinations", "total"], "name": "Setup"}, {"variables": ["supply", "demand", "costs"], "name": "Initial data"}, {"variables": ["assignment", "assignment_cost"], "name": "Minimum costs"}], "variables": {"costs": {"templateType": "anything", "group": "Initial data", "definition": "matrix(repeat(\n repeat(\n random(1..9),\n num_destinations\n ),\n num_sources\n))", "description": "", "name": "costs"}, "num_sources": {"templateType": "anything", "group": "Setup", "definition": "random(3..5)", "description": "", "name": "num_sources"}, "num_destinations": {"templateType": "anything", "group": "Setup", "definition": "7-num_sources+random(0,1)", "description": "", "name": "num_destinations"}, "assignment": {"templateType": "anything", "group": "Minimum costs", "definition": "minimum_cost(supply,demand,costs)", "description": "", "name": "assignment"}, "assignment_cost": {"templateType": "anything", "group": "Minimum costs", "definition": "assignment_cost(assignment,costs)", "description": "", "name": "assignment_cost"}, "total": {"templateType": "anything", "group": "Setup", "definition": "random(50..500)", "description": "", "name": "total"}, "supply": {"templateType": "anything", "group": "Initial data", "definition": "random_partition(total,num_sources)", "description": "", "name": "supply"}, "demand": {"templateType": "anything", "group": "Initial data", "definition": "random_partition(total,num_destinations)", "description": "", "name": "demand"}}, "ungrouped_variables": [], "rulesets": {}, "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"]]}}, "showQuestionGroupNames": false, "parts": [{"showCorrectAnswer": true, "markPerCell": false, "allowFractions": false, "correctAnswer": "assignment", "allowResize": false, "prompt": "Apply the minimum cost algorithm to find an assignment of units of coal to be transported between pits and power stations.
\nWhen there's more than one choice of cell, choose the cell with the maximum available allocation.
", "correctAnswerFractions": false, "numRows": "num_sources", "scripts": {}, "type": "matrix", "numColumns": "num_destinations", "tolerance": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1}, {"showCorrectAnswer": true, "allowFractions": false, "variableReplacementStrategy": "originalfirst", "minValue": "assignment_cost", "prompt": "What is the total cost of this solution?
", "showPrecisionHint": false, "scripts": {}, "type": "numberentry", "correctAnswerFraction": false, "variableReplacements": [{"part": "p0", "must_go_first": false, "variable": "assignment"}], "marks": 1, "maxValue": "assignment_cost"}], "variablesTest": {"condition": "", "maxRuns": "3000"}, "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.
\nThe cost $c_{ij}$ 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)}
", "tags": [], "question_groups": [{"pickingStrategy": "all-ordered", "questions": [], "name": "", "pickQuestions": 0}], "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": ""}, "advice": "The following tables show each step of the minimum cost algorithm:
\n{minimum_cost_display(supply,demand,costs)}
\nThe total cost of this solution is $\\var{show_cost_calculation(assignment,costs)}$.
"}, {"name": "Transportation problem - apply minimum cost algorithm to unbalanced problem", "extensions": ["optimisation"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "contributors": [{"name": "Bill Foster", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/6/"}, {"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "variable_groups": [{"variables": ["num_sources", "num_destinations", "total", "omit_source", "show_sources", "show_destinations"], "name": "Setup"}, {"variables": ["supply", "demand", "costs", "show_supply", "show_demand", "show_costs", "dummy_resource"], "name": "Initial data"}, {"variables": ["assignment", "assignment_cost", "show_assignment"], "name": "Minimum costs"}], "variables": {"show_assignment": {"group": "Minimum costs", "templateType": "anything", "definition": "matrix(map(\n map(\n assignment[x][y],\n y,\n 0..show_destinations-1\n ),\n x,\n 0..show_sources-1\n))", "description": "", "name": "show_assignment"}, "costs": {"group": "Initial data", "templateType": "anything", "definition": "matrix(map(\n map(\n if(xThe balanced problem adds another [[0]] with [[1]] units of coal.
\nEnter the cost matrix for the balanced problem below.
\n[[2]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"displayType": "radiogroup", "showCorrectAnswer": true, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "matrix": "if(omit_source,[1,0],[0,1])", "choices": ["pit
", "power station
"], "unitTests": [], "variableReplacements": [], "shuffleChoices": false, "showFeedbackIcon": true, "scripts": {}, "minMarks": 0, "type": "1_n_2", "maxMarks": 0, "variableReplacementStrategy": "originalfirst", "displayColumns": 0, "marks": 0}, {"showCorrectAnswer": true, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "dummy_resource", "maxValue": "dummy_resource", "unitTests": [], "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "variableReplacements": [], "marks": 1, "mustBeReducedPC": 0}, {"showCorrectAnswer": true, "markPerCell": false, "allowFractions": false, "correctAnswer": "costs", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "allowResize": true, "unitTests": [], "correctAnswerFractions": false, "numRows": 1, "scripts": {}, "type": "matrix", "numColumns": 1, "tolerance": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 1, "showFeedbackIcon": true}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}, {"scripts": {}, "showCorrectAnswer": true, "markPerCell": false, "allowFractions": false, "correctAnswer": "show_assignment", "extendBaseMarkingAlgorithm": true, "customMarkingAlgorithm": "", "prompt": "Apply the minimum cost algorithm to your balanced problem to find an assignment of units of coal to be transported between pits and power stations.
\nWhen there's more than one choice of cell, choose the cell with the maximum available allocation.
", "unitTests": [], "correctAnswerFractions": false, "numRows": "show_sources", "allowResize": false, "type": "matrix", "numColumns": "show_destinations", "tolerance": 0, "variableReplacementStrategy": "originalfirst", "variableReplacements": [{"part": "p0g2", "must_go_first": false, "variable": "costs"}], "marks": 1, "showFeedbackIcon": true}, {"showCorrectAnswer": true, "customMarkingAlgorithm": "", "extendBaseMarkingAlgorithm": true, "prompt": "What is the total cost of this solution?
\n£ [[0]]
", "unitTests": [], "showFeedbackIcon": true, "scripts": {}, "gaps": [{"showCorrectAnswer": true, "allowFractions": false, "customMarkingAlgorithm": "", "mustBeReduced": false, "extendBaseMarkingAlgorithm": true, "minValue": "assignment_cost", "maxValue": "assignment_cost", "unitTests": [], "correctAnswerStyle": "plain", "variableReplacementStrategy": "originalfirst", "showFeedbackIcon": true, "scripts": {}, "type": "numberentry", "notationStyles": ["plain", "en", "si-en"], "correctAnswerFraction": false, "variableReplacements": [{"part": "p1", "must_go_first": false, "variable": "assignment"}], "marks": 1, "mustBeReducedPC": 0}], "type": "gapfill", "variableReplacementStrategy": "originalfirst", "variableReplacements": [], "marks": 0, "sortAnswers": false}], "statement": "Four power stations labelled $j = 1,2,3,4$ require {show_variable_list(show_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(show_supply,'a')} units of coal, respectively.
\nThe 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(show_supply,show_demand,show_costs)}
", "tags": [], "rulesets": {}, "preamble": {"css": "", "js": ""}, "type": "question", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": "Although the statement has 4 power stations and 3 pits, when the question is run sometimes 3 power stations are given and sometimes 4 pits.
"}, "variablesTest": {"condition": "", "maxRuns": 100}, "advice": "The total supply is {sum(show_supply)}, while the total demand is {sum(show_demand)}, so we need to add a dummy {if(omit_source,'pit supplying','power station demanding')} {dummy_resource} units of coal.
\nThe cost matrix then looks like this:
\n{cost_table(supply,demand,costs)}
\nThe following tables show each step of the minimum cost algorithm:
\n{minimum_cost_display(supply,demand,costs)}
\nThe total cost of this solution is $\\var{show_cost_calculation(assignment,costs)}$.
"}, {"name": "Transportation problem - stepping stones", "extensions": ["optimisation"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "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/"}], "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": [], "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.
\nThe 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)}
\nThe 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", "metadata": {"licence": "Creative Commons Attribution 4.0 International", "description": ""}, "advice": "The cost of the initial solution is $\\var{show_cost_calculation(initial_assignment,costs)}$.
\nThe steps of the method are shown below.
\n{stepping_stone_display(initial_assignment,costs)}
\nAt this point, no cells have shadow costs greater than their real costs, so the solution is optimal.
\nThe cost of the optimal solution is $\\var{show_cost_calculation(final_assignment,costs)}$.
"}], "name": "", "pickQuestions": 0}], "navigation": {"onleave": {"message": "", "action": "none"}, "browse": true, "reverse": true, "preventleave": true, "showresultspage": "oncompletion", "allowregen": true, "showfrontpage": true}, "type": "exam", "metadata": {"notes": "", "licence": "Creative Commons Attribution 4.0 International", "description": ""}, "extensions": ["optimisation"], "timing": {"timedwarning": {"message": "", "action": "none"}, "timeout": {"message": "", "action": "none"}, "allowPause": true}, "pickQuestions": 0, "contributors": [{"name": "Newcastle University Mathematics and Statistics", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/697/"}], "custom_part_types": []}