[Mathematical Modeling] Basic Principles and Case Sharing of Linear Programming Model

1.1, linear programming problem

      In people's production practice, they often encounter the problem of how to use existing resources to arrange production in order to obtain maximum economic benefits. Such problems constitute an important branch of operations research-mathematical programming, and linear programming (Linear Programming abbreviated as LP) is an important branch of mathematical programming. Since GBDantzig proposed the simplex method for solving linear programming in 1947, linear programming has become more mature in theory, and it has become more extensive and deeper in practice. Especially after the computer can handle linear programming with thousands of constraints and decision variables, the application of linear programming has become more extensive and has become one of the basic methods often used in modern management.

1.1.1 Examples and definitions of linear programming

Example 1.1 A machine tool factory produces two types of machine tools, A and B, and the profit after sale of each machine is 4,000 yuan and 3,000 yuan respectively. The production of machine tool A needs to be processed by machines A and B, and the processing time is 2 hours and 1 hour for each machine respectively; the production of machine tool B needs to be processed by machines A, B, and C, and the processing time is one hour for each machine. If the
number of machine hours available for processing per day are 10 hours for machine A, 8 hours for machine B and 7 hours for machine C, how many machine tools should the factory produce in order to maximize the total profit?

The mathematical model of the above problem: suppose that the total profit z is the largest when the factory produces x1 machine A and x2 machine B, then x1 and x2 should meet:

The variables x1, x2 are called decision variables, the formula (1.1) is called the objective function of the problem, and several inequalities in (1.2) are the constraints of the problem, denoted as st (subject to).

The objective function and constraints are linear functions, so it is called a linear programming problem. The linear programming problem is a problem of finding the maximum or minimum linear objective function under the restriction of a set of linear constraints. When solving practical problems, the problem is reduced to a linear programming mathematical model is a very important step, and it is often a very difficult step. Whether the model is established properly or not directly affects the solution. Choosing appropriate decision variables is one of the keys for us to establish an effective model.
 

1.1.2 The concept of solutions to linear programming problems

Where c and x are n-dimensional column vectors, A and Aeq are matrices of appropriate dimensions, and b and beq are column vectors of appropriate dimensions. [ Note: matlab is for min ]

The feasible solution that satisfies the constraint (1.4) is the solution x= [x,L,x,I, which is called the feasible solution of the linear programming problem, and the feasible solution that maximizes the objective function (1.3) is called the optimal solution.
Feasible region feasible region set is called a feasible solution for all problems consisting of, referred to as R.

1.1.3 Matlab standard form of linear programming and software solution

Where c and x are n-dimensional column vectors, A and Aeq are matrices of appropriate dimensions, and b and beq are column vectors of appropriate dimensions.

The command for solving linear programming in Matlab is

[x,fval] = linprog(c,A,b)
[x,fval] = linprog(c,A,b,Aeq,beq)
[x,fval] = linprog(c,A,b,Aeq,beq,lb,ub)

[ Note: These are three different ways of writing. For the standard form, you can write which parameter you have. ]

Where x returns the value of the decision vector, fval returns the optimal value of the objective function, c is the value vector, A, b correspond to linear inequality constraints, Aeq, beq correspond to linear equality constraints, lb and ub respectively corresponds to the lower bound vector and upper bound vector of the decision vector.

Example 1.2 Solve the following linear programming problem

The MATLAB program for solving is as follows.

f=[-2;-3;5];
a=[-2,5,-1;1,3,1]; b=[-10;12]; .
aeq=[1,1,1];
beq=7;
[x,yl=linprog(f,a,b,aeq,beq,zeros(3,1));
x, y=-y

1.1.4 Problems that can be transformed into linear programming


1.2 Benefits and risks of investment

1.2.1 Questions

1.2.2 Symbol requirements and basic assumptions

The symbol stipulates that
si represents the i-th investment project, such as stocks, bonds, etc., i = 0, 1, L, n, where s0 refers to deposit in the bank;
ri, Pi, and qi respectively represent the average return rate of si, the transaction fee rate, Risk loss rate, i = 0, L, n, where p0 = 0, q0 = 0;
ui represents the trading quota of si, i = 1, L, n;
xi represents the funds of the investment project si, i = 0, 1, L ,n;
a represents the degree of investment risk;
Q represents the overall return;

Basic assumptions
(1) The amount of investment M is quite large. For ease of calculation, assume M = 1;
(2) The more diversified the investment, the smaller the total risk;
(3) The overall risk is the investment project s; the largest risk To measure;
(4) n + 1 kinds of assets s; are independent of each other;
(5) in this period of investment, r;,P;,q; is a fixed value, not affected by unexpected factors;
(6 ) Net income and overall risk are only affected by r;,P;,9; and are not affected by other factors.


1.2.3 Analysis and establishment of the model


Model 1: Fix the risk level and optimize the return

That is, the level of risk does not exceed a

Model 2: Fix the profit level and minimize the risk

That is, the minimum benefit is k

c) When investors weigh asset risks and expected returns, they hope to choose a portfolio that satisfies them. Therefore, weights s (0<s≤1) and (1-s) are respectively assigned to risk and return, and s is called the investment preference coefficient.

 

1.2.4 Solution of Model One

clc,clear
a=0;hold on
while a<0.05
    c=[-0.05,-0.27,-0.19,-0.185,-0.185];
    A=[zeros(4,1 ),diag([0.025,0.015,0.055,0.026])];
    b=a*ones(4,1);
    Aeq=[1,1.01,1.02,1 .045,1.065];
    beq=1; LB=zeros(5,1);,
    [x,Ql=linprog(c,A,b,Aeq,beq,LB);
    Q=-Q; plot(a,Q,'*k'); .
    a=a+0.001;
end
xlabel('a'),ylabel('Q')

1.2.5 Result analysis

It can be seen that
(1) the risk is large, and the return is also large.
(2) When the investment is more diversified, the risk taken by investors is smaller, which is consistent with the meaning of the question. Risky investors will have concentrated investment, while conservative investors will diversify their investment as much as possible.
(3) There is a turning point near a = 0.006. On the left of this point, when the risk increase is small, profits increase rapidly. On the right side of this point, when the risk increases greatly, the profit increases very slowly. Therefore, for investors who have no special preference for risk and return, the turning point of the curve should be selected as the optimal portfolio, which is about a=0.6%. Q=20%, the corresponding investment plan is risk degree a= 0.006, return Q= 0.2019, x,=0, x= 0.24, x,=0.4, X3= 0.1091, x4 = 0.2212.
 

Learning source:

https://www.bilibili.com/video/BV1kC4y1a7Ee?p=3

https://www.bilibili.com/video/BV1kC4y1a7Ee?p=4

Guess you like

Origin blog.csdn.net/Zhouzi_heng/article/details/113483537