当前位置:网站首页>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
边栏推荐
- Linux64Bit下安装MySQL5.6-不能修改root密码
- Recommend an open source free drawing software draw IO exportable vector graph
- SQL Server connectors by thread pool 𞓜 instructions for dtsqlservertp plug-in
- Tencent Qiu Dongyang: techniques and ways of accelerating deep model reasoning
- The second method of file upload in form form is implemented by fileitem class, servletfileupload class and diskfileitemfactory class.
- NC basic usage 4
- 微信中金财富高端专区安全吗,证券如何开户呢
- redis 分布式锁
- ArcGIS js api 4. X submergence analysis and water submergence analysis
- R language ggplot2 visual facet_wrap, and use the lineheight parameter to customize the height of the facet icon tab (gray label bar)
猜你喜欢
Don't bother tensorflow learning notes (10-12) -- Constructing a simple neural network and its visualization
SIGIR'22「微软」CTR估计:利用上下文信息促进特征表征学习
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
SIGIR'22 "Microsoft" CTR estimation: using context information to promote feature representation learning
[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached
[text classification cases] (4) RNN and LSTM film evaluation Tendency Classification, with tensorflow complete code attached
Click an EL checkbox to select all questions
LeetCode异或运算
SQL Server Connectors By Thread Pool | DTSQLServerTP plugin instructions
WordPress plug-in: WP CHINA Yes solution to slow domestic access to the official website
随机推荐
Es index (document name) fuzzy query method (database name fuzzy query method)
JDBC tool class jdbcfiledateutil uploads files and date format conversion, including the latest, simplest and easiest way to upload single files and multiple files
Es keyword sorting error reason = fielddata is disabled on text fields by default Set fielddata = true on keyword in order
[numerical prediction case] (3) LSTM time series electricity quantity prediction, with tensorflow complete code attached
Unity 模型整体更改材质
Es error: request contains unrecognized parameter [ignore_throttled]
Computing the intersection of two planes in PCL point cloud processing (51)
DNS cloud school | analysis of hidden tunnel attacks in the hidden corner of DNS
. Ren -- the intimate artifact in the field of vertical Recruitment!
Tencent Qiu Dongyang: techniques and ways of accelerating deep model reasoning
nc基础用法
redis 分布式锁
Solution to PowerDesigner's failure to connect to MySQL in x64 system
CVPR 2022 | querydet: use cascaded sparse query to accelerate small target detection under high resolution
The R language uses the timeroc package to calculate the multi time AUC value of survival data without competitive risk, and uses the confint function to calculate the confidence interval value of mul
Why does ES6 need to introduce map when JS already has object type
Fundamentals of programming language (2)
[latex] 5 how to quickly write out the latex formula corresponding to the formula
Local call feign interface message 404
selenium.common.exceptions.WebDriverException: Message: ‘chromedriver‘ executable needs to be in PAT