0
0
SciPydata~5 mins

Linear programming (linprog) in SciPy - Cheat Sheet & Quick Revision

Choose your learning style9 modes available
Recall & Review
beginner
What is the main goal of linear programming?
Linear programming aims to find the best value (maximum or minimum) of a linear function, called the objective, while following certain linear constraints.
Click to reveal answer
beginner
In scipy's linprog, what does the 'c' parameter represent?
The 'c' parameter is a list or array of coefficients for the objective function that we want to minimize.
Click to reveal answer
intermediate
What types of constraints can you specify in linprog?
You can specify inequality constraints (A_ub x ≤ b_ub) and equality constraints (A_eq x = b_eq) in linprog.
Click to reveal answer
beginner
What does the result of linprog contain?
The result includes the optimal values for variables, the minimum value of the objective function, and a success flag indicating if the solution was found.
Click to reveal answer
intermediate
Why do we often minimize the objective function in linprog instead of maximizing?
linprog is designed to minimize by default. To maximize, we multiply the objective coefficients by -1 and then minimize.
Click to reveal answer
What does the 'linprog' function in scipy.optimize do?
AGenerates random linear equations
BSolves linear programming problems to minimize a linear objective function
CCalculates eigenvalues of a matrix
DPerforms linear regression on data
In linprog, which parameter represents the inequality constraint matrix?
AA_ub
Bb
CA
Dc
How do you represent the constraint x1 + 2x2 ≤ 4 in linprog?
Ac = [1, 2], b = [4]
BA_eq = [[1, 2]], b_eq = [4]
CA_ub = [[1, 2]], b_ub = [4]
DA_ub = [[4]], b_ub = [1, 2]
If you want to maximize 3x + 4y using linprog, what should you do?
AUse c = [-3, -4] to minimize the negative
BSet maximize=True in linprog
CUse c = [3, 4] directly
DUse equality constraints instead
What does the 'success' attribute in linprog's result indicate?
AIf constraints are all equalities
BIf the input data was valid
CIf the objective function is linear
DIf the optimization found a solution
Explain how to set up a linear programming problem using scipy's linprog.
Think about what you want to minimize and the rules your variables must follow.
You got /5 concepts.
    Describe how to convert a maximization problem into a minimization problem for linprog.
    Remember linprog only minimizes by default.
    You got /3 concepts.