// Numbas version: exam_results_page_options {"name": "Julien's copy of Duality of linear programming problems (2 variables)", "extensions": ["optimisation"], "custom_part_types": [], "resources": [], "navigation": {"allowregen": true, "showfrontpage": false, "preventleave": false, "typeendtoleave": false}, "question_groups": [{"pickingStrategy": "all-ordered", "questions": [{"statement": "
You are given the following primal linear programming problem:
\n{if(maximise,'Maximise','Minimise')} $z = \\var{latex(describe_objective(objective_coefficients))}$ subject to
\n\\[ \\var{latex(describe_constraints(constraint_coefficients,constraint_rhs,inequality,'x'))} \\]
", "parts": [{"useCustomName": false, "customName": "", "sortAnswers": false, "adaptiveMarkingPenalty": 0, "scripts": {}, "unitTests": [], "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "prompt": "Write the dual of the given LP problem below. Name your variables y1
, y2
, ...
(Use the \"rows\" and \"columns\" boxes to change the number of constraints or variables)
\n[[0]]
\n$w = $ [[1]]
\nsubject to
\n$y_i \\geq 0$ for all $i$.
", "variableReplacements": [], "type": "gapfill", "marks": 0, "showCorrectAnswer": true, "gaps": [{"useCustomName": false, "shuffleChoices": false, "matrix": "if(maximise,[0,1],[1,0])", "customName": "", "displayColumns": 0, "showCellAnswerState": true, "minMarks": 0, "adaptiveMarkingPenalty": 0, "scripts": {}, "unitTests": [], "choices": ["Maximise
", "Minimise
"], "extendBaseMarkingAlgorithm": true, "showFeedbackIcon": true, "variableReplacementStrategy": "originalfirst", "maxMarks": 0, "variableReplacements": [], "type": "1_n_2", "marks": 0, "displayType": "radiogroup", "showCorrectAnswer": true, "customMarkingAlgorithm": ""}, {"checkVariableNames": true, "adaptiveMarkingPenalty": 0, "checkingType": "absdiff", "unitTests": [], "showFeedbackIcon": true, "variableReplacements": [], "variableReplacementStrategy": "originalfirst", "marks": 1, "extendBaseMarkingAlgorithm": true, "vsetRange": [0, 1], "useCustomName": false, "customName": "", "vsetRangePoints": 5, "checkingAccuracy": 0.001, "scripts": {}, "customMarkingAlgorithm": "", "showCorrectAnswer": true, "failureRate": 1, "showPreview": true, "type": "jme", "answer": "{dual_objective_coefficients[0]}*y1+{dual_objective_coefficients[1]}*y2+{dual_objective_coefficients[2]}*y3", "valuegenerators": [{"name": "y1", "value": ""}, {"name": "y2", "value": ""}, {"name": "y3", "value": ""}]}, {"useCustomName": false, "tolerance": 0, "correctAnswerFractions": false, "customName": "", "allowResize": true, "adaptiveMarkingPenalty": 0, "scripts": {"constructor": {"order": "after", "script": "/*this.display.correctAnswerLaTeX = ko.computed(function() {\n with(question.unwrappedVariables) {\n var rows = [];\n for(var i=0;iLaTeX symbol for the inequality used in the dual problem's constraints.
", "definition": "latex(if(maximise,'\\\\geq','\\\\leq'))", "templateType": "anything"}, "maximise": {"group": "Primal problem", "name": "maximise", "description": "Is the primal problem a maximisation problem?
", "definition": "random(true,false)", "templateType": "anything"}, "dual_objective_coefficients": {"group": "Dual problem", "name": "dual_objective_coefficients", "description": "Coefficients of each variable in the dual problem's objective function.
", "definition": "constraint_rhs", "templateType": "anything"}, "num_constraints": {"group": "Primal problem", "name": "num_constraints", "description": "Number of constraints in the primal LP
", "definition": "3", "templateType": "anything"}, "dual_constraints_matrix": {"group": "Dual problem", "name": "dual_constraints_matrix", "description": "Matrix of coefficients for the constraints in the dual problem, with another column added giving the right-hand sides of the constraints.
\nUsed to mark the student's answer for the constraints.
", "definition": "matrix(\n map(\n list(dual_constraint_coefficients[j])+[dual_constraint_rhs[j]],\n j,\n 0..dual_constraints-1\n )\n)", "templateType": "anything"}, "constraint_rhs": {"group": "Primal problem", "name": "constraint_rhs", "description": "Right-hand side of each constraint
", "definition": "repeat(random(1..20),num_constraints)", "templateType": "anything"}, "inequality": {"group": "Primal problem", "name": "inequality", "description": "LaTeX symbol for the inequalities in the primal problem's constraints
", "definition": "latex(if(maximise,'\\\\leq','\\\\geq'))", "templateType": "anything"}, "dual_constraint_rhs": {"group": "Dual problem", "name": "dual_constraint_rhs", "description": "Right-hand sides of the constraints in the dual problem.
", "definition": "objective_coefficients", "templateType": "anything"}, "dual_variables": {"group": "Dual problem", "name": "dual_variables", "description": "Number of variables in the dual problem (equal to the number of constraints in the primal)
", "definition": "num_constraints", "templateType": "anything"}, "dual_constraints": {"group": "Dual problem", "name": "dual_constraints", "description": "Number of constraints in the dual problem (equal to the number of variables in the primal)
", "definition": "num_variables", "templateType": "anything"}, "objective_coefficients": {"group": "Primal problem", "name": "objective_coefficients", "description": "Coefficients of each variable in the objective function.
", "definition": "repeat(random(1..6),num_variables)", "templateType": "anything"}, "dual_constraint_coefficients": {"group": "Dual problem", "name": "dual_constraint_coefficients", "description": "Coefficients of the constraints in the dual problem. Same format as in the primal.
", "definition": "matrix(map(\n map(\n constraint_coefficients[y][x],\n y,\n 0..dual_variables-1\n ),\n x,\n 0..dual_constraints-1\n))", "templateType": "anything"}, "constraint_coefficients": {"group": "Primal problem", "name": "constraint_coefficients", "description": "Element $(i,j)$ is the coefficient of $x_j$ in the $i$th constraint.
", "definition": "matrix(repeat(\n random_partition(random(num_variables+1..2*num_variables+1),num_variables,0),\n num_constraints\n))", "templateType": "anything"}, "num_variables": {"group": "Primal problem", "name": "num_variables", "description": "Number of variables in the primal LP
", "definition": "2", "templateType": "anything"}}, "extensions": ["optimisation"], "rulesets": {}, "functions": {"describe_constraints": {"type": "number", "definition": "var num_variables=coefficients[0].length;\nvar o = '\\\\begin{align}';\nvar lines = [];\nfor(var i=0;iThe primal problem is a {if(maximise,'maximisation','minimisation')} problem, so the dual problem is a {if(maximise,'minimisation','maximisation')} problem.
\nSo, the dual problem is as follows:
\n{if(maximise,'Minimise','Maximise')} $w = \\simplify{{dual_objective_coefficients[0]}y1+{dual_objective_coefficients[1]}y2+{dual_objective_coefficients[2]}y3}$ subject to
\n\\[ \\var{latex(describe_constraints(dual_constraint_coefficients,dual_constraint_rhs,dual_inequality,'y'))} \\]
", "variable_groups": [{"name": "Primal problem", "variables": ["maximise", "num_variables", "num_constraints", "objective_coefficients", "constraint_coefficients", "constraint_rhs", "inequality"]}, {"name": "Dual problem", "variables": ["dual_variables", "dual_constraints", "dual_objective_coefficients", "dual_constraint_coefficients", "dual_constraint_rhs", "dual_constraints_matrix", "dual_inequality"]}], "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/"}, {"name": "Julien Ugon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3575/"}]}]}], "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/"}, {"name": "Julien Ugon", "profile_url": "https://numbas.mathcentre.ac.uk/accounts/profile/3575/"}]}