Current location - Training Enrollment Network - Mathematics courses - How to establish a mathematical model and solve it with matlab? Which expert gives a template?
How to establish a mathematical model and solve it with matlab? Which expert gives a template?
Hello, first of all, I want to say that it is wise for you to choose matlab, a powerful software. Its functions are very comprehensive, and its optimization toolbox is very convenient to solve your problems. The program for solving linear programming is called linprog, and the calling format is [x, fval, exit flag, output, lambda] = linprog (c, a, b, aeq, beq, lb, ub, x0, options). Val: the function value at the optimal solution; Exitflag: status indication at the end of the program (> 0: convergence, 0: maximum number of function calls or iterations (specified in options) < 0: non-convergence); Output: a structural variable containing the following data (the actual number of iterations, the actual number of Pcgiterations of CG iterations (for large-scale calculation), and the algorithm actually used by the algorithm); Lambda: a structural variable containing the following data (lagrange multiplier constrained by inequality, lagrange multiplier constrained by eqlin equality, lagrange multiplier constrained by upper bound, lagrange multiplier constrained by lower bound); C: objective function matrix; A/Aeq: inequality/equality constraint coefficient matrix; B/beq: matrix of constant terms with inequality/equality constraints; Lb: the lower limit of the independent variable definition domain; Ub: the upper limit of the independent variable definition domain; X0: Initial solution (by default, the program automatically takes x0=0) Option: The practical application of the structure containing algorithm control parameters is not so complicated, and many parameters can be defaulted. Use your example to demonstrate: (enter in the command window) f = [-2; -3]; A=[0, 1; 4,2; 1, 1]; b =[ 12; 20; 6]; Lb = zero (3,1); [x, fval] = linprog (f, a, b, [], [], lb) Calculate x = [0; 6], namely x 1=0, x2=6fval=- 18. It shows that linprog function can only find the minimum value, so all the coefficients of the objective function become reciprocal, and the final result should be the reciprocal of fval. I hope the above content will help you learn matlab, and you can read more help files in the future, which have detailed explanations.