Location via proxy:   [ UP ]  
[Report a bug]   [Manage cookies]                
0% found this document useful (0 votes)
0 views

Introduction to Linear Programming

Uploaded by

boromis763
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
0 views

Introduction to Linear Programming

Uploaded by

boromis763
Copyright
© © All Rights Reserved
Available Formats
Download as DOCX, PDF, TXT or read online on Scribd
You are on page 1/ 3

Introduction to Linear Programming

Definition: Linear programming involves optimizing a linear objective function


subject to linear equality and inequality constraints.
General Form: Maximize or minimize: cTxc^T xcTx subject to: Ax≤bA x \leq
bAx≤b Aeqx=beqA_{eq} x = b_{eq}Aeqx=beq x≥0x \geq 0x≥0
Where:
 ccc is the coefficient vector for the objective function.
 AAA and AeqA_{eq}Aeq are matrices for inequality and equality
constraints.
 bbb and beqb_{eq}beq are vectors for the constraints.
 xxx is the vector of decision variables.

2. Setting Up Linear Programming in Octave


2.1 Installing the Optimization Package: To solve linear programming
problems in Octave, you need the optim package. If it's not installed, you can
install it using:
octave
Copy code
pkg install -forge optim
pkg load optim
2.2 Defining the Problem:
1. Objective Function Coefficients: Create a vector c for the coefficients
in the objective function.
2. Constraints: Define matrices and vectors for the inequality constraints (A
and b) and equality constraints (A_eq and b_eq).
3. Bounds: Define bounds for the decision variables, if any.
2.3 Solving the Problem: Use the linprog function to solve the problem. The
general syntax is:
octave
Copy code
[x, fval] = linprog(c, A, b, A_eq, b_eq, lb, ub)
 c: Objective function coefficients.
 A and b: Coefficients for inequality constraints.
 A_eq and b_eq: Coefficients for equality constraints.
 lb and ub: Lower and upper bounds for decision variables.
 x: Solution vector.
 fval: Value of the objective function at the solution.

3. Example Problem
Problem: Maximize z=3x1+2x2z = 3x_1 + 2x_2z=3x1+2x2 subject to:
x1+x2≤4x_1 + x_2 \leq 4x1+x2≤4 x1≤2x_1 \leq 2x1≤2 x2≤3x_2 \leq 3x2≤3
x1≥0x_1 \geq 0x1≥0 x2≥0x_2 \geq 0x2≥0
Step-by-Step Solution:
1. Define Objective Function:
octave
Copy code
c = [-3; -2]; % Coefficients for the objective function (negative for maximization)
2. Define Constraints:
octave
Copy code
A = [1, 1; 1, 0; 0, 1]; % Coefficients for inequality constraints
b = [4; 2; 3]; % Right-hand side for inequality constraints
3. Define Bounds:
octave
Copy code
lb = [0; 0]; % Lower bounds for x1 and x2
ub = []; % No upper bounds explicitly defined (will use constraints instead)
4. Solve the Problem:
octave
Copy code
[x, fval] = linprog(c, A, b, [], [], lb, ub)
Output Interpretation:
 x will contain the values of x1x_1x1 and x2x_2x2 that maximize the
objective function.
 fval will contain the maximum value of the objective function zzz.

4. Additional Considerations
4.1 Integer Programming: For problems where decision variables must be
integers, you would typically use integer programming techniques. Octave’s
linprog does not support integer constraints directly, so you may need to use
specialized solvers or packages.
4.2 Sensitivity Analysis: Octave doesn’t provide built-in functions for
sensitivity analysis, but you can manually vary parameters and observe changes
in the solution.
4.3 Advanced Constraints: For more complex constraints, such as nonlinear
constraints or quadratic objectives, you may need to use different optimization
functions or tools.
4.4 Debugging:
 Infeasibility: If Octave returns infeasible solutions, check constraints and
bounds.
 Unbounded Solutions: If the solution is unbounded, verify that the
problem formulation and constraints are correctly specified.

You might also like