当前位置:网站首页>Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
Mathematical modeling column | Part 5: MATLAB optimization model solving method (Part I): Standard Model
2022-04-23 20:20:00 【Install a sound 77】
Optimization problem is one of the most common problems in mathematical modeling competition . As a general rule , Those who seek the greatest 、 Minimum 、 furthest 、 lately 、 Most economical 、 Richest 、 Most efficient 、 The most time-consuming goal , Can be classified into the category of optimization problems .MATLAB Optimization toolbox and global optimization toolbox provide complete solutions to multiple optimization problems , The former covers linear programming 、 Mixed integer linear programming 、 Second planning 、 Nonlinear optimization 、 Solver for nonlinear least squares , The latter includes global search 、 Multiple initial points 、 Pattern search 、 Genetic algorithm and other solving algorithms .
This lecture mainly introduces how to use the optimization toolbox to solve the standard optimization model in mathematical modeling . More content , Welcome to MathWorks Website and MATLAB Software documentation .
1. Talk about optimization
Optimization means that under certain conditions , Seek to minimize your goals ( Big ) Design parameters or decisions . There are two key objects in the optimization problem : Objective functions and constraints ( Optional ). General optimization problems , Its mathematical expression can be described as :
among x For the length n Decision variable vector ,f(x) Is the target function ,G(x) Is a constraint function .
Solve the minimum of the objective function ( Big ) value , An efficient and accurate solution depends not only on constraints and the number of variables , It depends more on the characteristics of objective function and constraint function . Clarifying the optimization type is the premise of confirming the optimization scheme , Let's see how these features are divided :
Common objective functions are :
Linear programming : It is widely used in financial information that can be expressed linearly between variables 、 energy 、 In modern management fields such as operation research .
Mixed integer linear programming : The linear programming problem is extended , The constraint that some or all variables in the optimal solution must be integers is added . for example , If a variable represents the number of shares to be subscribed , Then only the integer value should be rounded . Again , If a variable represents the on of the generator / Off state , Then only binary values should be taken (0 or 1).
Second planning : The objective function or constraint function is a multivariate quadratic function . This optimization is applied to portfolio optimization in finance 、 Power plant generation optimization 、 Design optimization and other fields in engineering .
least square : It is divided into linear and nonlinear , Find the optimal function matching of variables by minimizing the sum of squares of errors . Nonlinear least squares optimization can also be used for curve fitting .
2. There are too many optimization solvers , How to choose ?
Yes MATLAB Provide algorithms for various optimization problems , We call it a solver (Solver). According to it, solve the goal , Divided into four groups :
-
Minimum optimization group : Find the starting point of the objective function x0 Local minima in the vicinity
-
Multi objective optimization group : Find or minimize the maximum value of a set of functions or the specified value
-
Equation solving system : Find the nonlinear equation f(x) = 0 starting point x0 Near solution
-
Least square method ( Curve fitting ) Group : Minimize the sum of squares
The optimization toolbox alone provides nearly 20 A solver , Faced with such a wide range of options , Users are often confused . fortunately ,MATLAB Provides a simple and clear reference tool —— Optimize the decision table . It can be said that a watch is in hand , Optimization does not worry :
The above table * The representation algorithm is provided by the global toolbox . Besides , Multiobjective optimization and equation solvers are not listed in this table , More solver options , You can click to read the original .
3. Write beautiful 、 Efficient code
After confirming the optimization strategy , You can start writing code . Let's take an example , Understand the steps and precautions for writing efficient optimization algorithm code .
[ subject ]
- Objective function
- Constraint function ( All variables are positive )
[ answer ]
a. First , According to the title, it is confirmed that this is a linear programming problem . The general mathematical expression of linear programming and MATLAB The standard form is :
Create a file that conforms to the standard format A、b、Aeq、beq、lb、ub Parameters , Only then can the optimization algorithm run smoothly .
b. For the optimization steps of linear programming ( It is also applicable to other optimization schemes ), Recommendations are as follows :
1 ) Select the optimization solver
2 ) Merge all variables into one vector
3 ) Create boundary constraints (lb,ub)
4 ) Create linear inequality constraints (A,b)
5 ) Create a linear equality constraint (Aeq,beq)
6 ) Create objective functions
7 ) Optimization problem solving
8 ) Results test
c. MATLAB Code and comments :
d. Optimization results :
e. If the result is not satisfactory , You can adjust the optimization options , Iterative calculation .
4. Integer programming artifact
In optimization , We often encounter integer programming problems , In especial 0-1 Programming problem , MATLAB For integer programming problems , There is a special solver intlinprog. This function can not only solve the general integer programming problem , We can also solve mixed integer programming problems , That is, the decision variable can be either an integer or a decimal , Just specify the number of the decision variable that is an integer . Through a concrete example , Let's take a look at the use of this function .
The problem is :
The solution code is :
Run code , The optimal solution can be obtained quickly x = [1 0 1].
5. Popular graphical applications
MATLAB So popular in the field of data analysis , In addition to providing a rich set of built-in algorithms , There are all kinds of friendly application interfaces . In the optimization toolbox , There is also such a powerful tool —— Optimization App, Can be in MATLAB Apps Window or run optmitool Command to open . It is an interactive graphical application tool , No need to write code , Directly set various solvers in the graphical interface 、 Configure the objective function 、 constraint condition , You can run the optimization algorithm and visualize the intermediate and final results .
stay Optimization App in , Just click... In the menu bar File > Generate Code, Can be App The settings in are automatically generated MATLAB Code , The user can realize the reuse and secondary development of the algorithm .
Besides , Facing more and more complex optimization problems , How to speed up the operation of the algorithm is also a problem we often hear . For this demand , Can combine MATLAB Parallel computing toolbox , Use the multi-core hardware resources of the computer , Realize algorithm acceleration , Interested users can click to read the original text, watch the video and learn more .
版权声明
本文为[Install a sound 77]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/04/202204210551491858.html
边栏推荐
- 16MySQL之DCL 中 COMMIT和ROllBACK
- R language ggplot2 visualization: ggplot2 visualizes the scatter diagram and uses geom_ mark_ The ellipse function adds ellipses around data points of data clusters or data groups for annotation
- Common form verification
- Sqoop imports data from Mysql to HDFS using lzop compression format and reports NullPointerException
- 使用 WPAD/PAC 和 JScript在win11中进行远程代码执行1
- How to do product innovation—— Exploration of product innovation methodology I
- [talkative cloud native] load balancing - the passenger flow of small restaurants has increased
- The flinkcdc reports an error: but this is no longer available on the server
- Es error: request contains unrecognized parameter [ignore_throttled]
- Alicloud: could not connect to SMTP host: SMTP 163.com, port: 25
猜你喜欢
. Ren -- the intimate artifact in the field of vertical Recruitment!
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
Leetcode XOR operation
Commit and ROLLBACK in DCL of 16mysql
Es error: request contains unrecognized parameter [ignore_throttled]
Redis cache penetration, cache breakdown, cache avalanche
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
PCL点云处理之计算两平面交线(五十一)
Zdns was invited to attend the annual conference of Tencent cloud basic resources and share the 2020 domain name industry development report
Compact CUDA tutorial - CUDA driver API
随机推荐
R语言ggplot2可视化:ggplot2可视化散点图并使用geom_mark_ellipse函数在数据簇或数据分组的数据点周围添加椭圆进行注释
Numpy Index & slice & iteration
Change the material of unity model as a whole
Paper writing 19: the difference between conference papers and journal papers
如何做产品创新?——产品创新方法论探索一
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
nc基础用法
Redis installation (centos7 command line installation)
Tencent Qiu Dongyang: techniques and ways of accelerating deep model reasoning
PIP installation package reports an error. Could not find a version that satisfies the requirement pymysql (from versions: none)
nc基础用法2
Cadence Orcad Capture 批量更改元件封装功能介绍图文教程及视频演示
Mysql database - single table query (II)
Customize timeline component styles
ArcGIS JS version military landmark drawing (dovetail arrow, pincer arrow, assembly area) fan and other custom graphics
网络通信基础(局域网、广域网、IP地址、端口号、协议、封装、分用)
[talkative cloud native] load balancing - the passenger flow of small restaurants has increased
Building the tide, building the foundation and winning the future -- the successful holding of zdns Partner Conference
NC basic usage
R语言survival包coxph函数构建cox回归模型、ggrisk包ggrisk函数和two_scatter函数可视化Cox回归的风险评分图、解读风险评分图、基于LIRI数据集(基因数据集)