Vous êtes sur la page 1sur 6

Linearno programiranje primena programskih paketa

1/6

1. Linearno programiranje http://algos.inesc-id.pt/lp/


Linear Programming:
A linear program is a problem a problem that can be expressed as follows: min cx (Standard Form) subject to Ax = b x >= 0 Where "x" is the vector of variables to be solved, "A" is the matrix of known coefficients and "c" and "b" are vectors of known coefficients. The Expression "cx" is called the objective function and the equations "Ax = b" are called the constraints.

Syntax of Linear Program:


[max:|min:] c1 x1 + ... + cN xN; (Objective function) [c1:] a11x1 + ... + a1NxN "= | > | < | => | <=" b1; (Constraints) [cM:] aM1x1 + ... + aMNxN "= | > | < | => | <=" bM; Where "x" is the vector of variables to be solved for, "A" is a matrix of known coefficients, and "c" and "b" are vectors of known coefficients. M is the number of constraints and N is the number of variables.

Primer min: x1 + 1.5 x2; c1: 0.5 x1 + x2 >= 7.5; 2 x1 + x2 >= 15; x1 >= 0; x2 >= 0;

Linearno programiranje primena programskih paketa

2/6

Primer

Linearno programiranje primena programskih paketa

3/6

2. Mathcad program

Using the Maximize and Minimize Functions


The example below shows nonlinear optimization using the Maximize function:

Linearno programiranje primena programskih paketa

4/6

The example below shows nonlinear optimization using the Minimize function:

Primer

x1 := 0

x2 := 0

x :=

x1 x2

z( x) := 4 x1 + 7 x2 A := Given Ax b

7 13 5 3

b :=

182 60

Maximizez ( , x) =

5.318 11.136

Linearno programiranje primena programskih paketa

5/6

3. Matlab program

>> help linprog LINPROG Linear programming. X=LINPROG(f,A,b) solves the linear programming problem: min f'*x x subject to: A*x <= b

X=LINPROG(f,A,b,Aeq,beq) solves the problem above while additionally satisfying the equality constraints Aeq*x = beq. X=LINPROG(f,A,b,Aeq,beq,LB,UB) defines a set of lower and upper bounds on the design variables, X, so that the solution is in the range LB <= X <= UB. Use empty matrices for LB and UB if no bounds exist. Set LB(i) = -Inf if X(i) is unbounded below; set UB(i) = Inf if X(i) is unbounded above. X=LINPROG(f,A,b,Aeq,beq,LB,UB,X0) sets the starting point to X0. This option is only available with the active-set algorithm. The default interior point algorithm will ignore any non-empty starting point. X=LINPROG(f,A,b,Aeq,Beq,LB,UB,X0,OPTIONS) minimizes with the default optimization parameters replaced by values in the structure OPTIONS, an argument created with the OPTIMSET function. See OPTIMSET for details. Use options are Display, Diagnostics, TolFun, LargeScale, MaxIter. Currently, only 'final' and 'off' are valid values for the parameter Display when LargeScale is 'off' ('iter' is valid when LargeScale is 'on'). [X,FVAL]=LINPROG(f,A,b) returns the value of the objective function at X: FVAL = f'*X. [X,FVAL,EXITFLAG] = LINPROG(f,A,b) returns EXITFLAG that describes the exit condition of LINPROG. If EXITFLAG is: > 0 then LINPROG converged with a solution X. 0 then LINPROG reached the maximum number of iterations without converging. < 0 then the problem was infeasible or LINPROG failed. [X,FVAL,EXITFLAG,OUTPUT] = LINPROG(f,A,b) returns a structure OUTPUT with the number of iterations taken in OUTPUT.iterations, the type of algorithm used in OUTPUT.algorithm, the number of conjugate gradient iterations (if used) in OUTPUT.cgiterations.

Linearno programiranje primena programskih paketa

6/6

[X,FVAL,EXITFLAG,OUTPUT,LAMBDA]=LINPROG(f,A,b) returns the set of Lagrangian multipliers LAMBDA, at the solution: LAMBDA.ineqlin for the linear inequalities A, LAMBDA.eqlin for the linear equalities Aeq, LAMBDA.lower for LB, and LAMBDA.upper for UB. NOTE: the LargeScale (the default) version of LINPROG uses a primal-dual method. Both the primal problem and the dual problem must be feasible for convergence. Infeasibility messages of either the primal or dual, or both, are given as appropriate. The primal problem in standard form is min f'*x such that A*x = b, x >= 0. The dual problem is max b'*y such that A'*y + s = f, s >= 0.

Primer

Vous aimerez peut-être aussi