Main Content

本页的翻译已过时。点击此处可查看最新英文版本。

基于问题的优化设置

使用变量和表达式表示优化问题,以串行或并行方式求解

在基于问题的优化中,您需要创建优化变量,用这些变量来构建表示目标和约束或表示方程的表达式,并使用 solve 求解问题。有关以基于问题的方法求解优化问题的步骤,请参阅Problem-Based Optimization Workflow。有关方程求解,请参阅Problem-Based Workflow for Solving Equations

在开始求解优化问题之前,您必须选择合适的方法:基于问题或基于求解器。有关详细信息,请参阅首先选择基于问题或基于求解器的方法

注意:如果您的非线性函数不是由多项式、有理式和初等函数(如 exp)组成的,可以使用 fcn2optimexpr 将其转换为优化表达式。请参阅Convert Nonlinear Function to Optimization ExpressionSupported Operations for Optimization Variables and Expressions

有关基本非线性优化示例,请参阅基于问题求解有约束非线性问题:。有关基本混合整数线性规划示例,请参阅混合整数线性规划基础:基于问题。有关基本方程求解示例,请参阅基于问题求解非线性方程组

函数

全部展开

eqnproblem创建方程问题
optimproblem创建优化问题
optimvar创建优化变量
show显示有关优化对象的信息
showbounds显示变量边界
write保存优化对象描述
writebounds保存变量边界描述
fcn2optimexpr将函数转换为优化表达式
optimconstr创建空优化约束数组
optimeq创建空优化等式数组
optimineq创建空优化不等式数组
optimexpr创建空优化表达式数组
show显示有关优化对象的信息
write保存优化对象描述
evaluate计算优化表达式
findindex查找命名索引变量的等效数值索引
infeasibility一个点处的约束违反度
prob2struct将优化问题或方程问题转换为求解器形式
show显示有关优化对象的信息
solve求解优化问题或方程问题
varindex将问题变量映射到基于求解器的变量索引
write保存优化对象描述

对象

EquationProblem非线性方程组
OptimizationConstraint优化约束
OptimizationEquality等式和等式约束
OptimizationExpression关于优化变量的算术或函数表达式
OptimizationInequality不等式约束
OptimizationProblem优化问题
OptimizationVariable优化变量

主题

基于问题的步骤

Problem-Based Optimization Workflow

Learn the problem-based steps for solving optimization problems.

Problem-Based Workflow for Solving Equations

Learn the problem-based steps for solving equations.

Optimization Expressions

Define expressions for both the objective and constraints.

Pass Extra Parameters in Problem-Based Approach

Pass extra parameters, data, or fixed variables in the problem-based approach.

Write Objective Function for Problem-Based Least Squares

Syntax rules for problem-based least squares.

Write Constraints for Problem-Based Cone Programming

Requirements for solve to use coneprog for problem solution.

Named Index for Optimization Variables

Create and work with named indices for variables.

Review or Modify Optimization Problems

Review or modify problem elements such as variables and constraints.

Examine Optimization Solution

Evaluate the solution and its quality.

设置选项

设置选项

设置优化选项

Output Function for Problem-Based Optimization

Use an output function in the problem-based approach to record iteration history and to make a custom plot.

基于问题的优化技巧

Create Efficient Optimization Problems

Obtain a faster or more accurate solution when the problem has integer constraints, and avoid loops when creating a problem.

Separate Optimization Model from Data

Create reusable, scalable problems by separating the model from the data.

变量名称不允许重复

两个同名优化变量问题的解决办法。

Create Initial Point for Optimization with Named Index Variables

Create initial points for solve when the problem has named index variables by using the findindex function.

Expression Contains Inf or NaN

Optimization expressions containing Inf or NaN cannot be displayed, and can cause unexpected results.

Objective and Constraints Having a Common Function in Serial or Parallel, Problem-Based

Save time when the objective and nonlinear constraint functions share common computations in the problem-based approach.

Effect of Automatic Differentiation in Problem-Based Optimization

Automatic differentiation lowers the number of function evaluations for solving a problem.

Supply Derivatives in Problem-Based Workflow

How to include derivative information in problem-based optimization when automatic derivatives do not apply.

Obtain Generated Function Details

Find the values of extra parameters in nonlinear functions created by prob2struct.

Output Function for Problem-Based Optimization

Use an output function in the problem-based approach to record iteration history and to make a custom plot.

并行计算

What Is Parallel Computing in Optimization Toolbox?

Use multiple processors for optimization.

Using Parallel Computing in Optimization Toolbox

Perform gradient estimation in parallel.

Minimizing an Expensive Optimization Problem Using Parallel Computing Toolbox™

Example showing the effectiveness of parallel computing in two solvers: fmincon and ga.

Improving Performance with Parallel Computing

Investigate factors for speeding optimizations.

基于问题的算法

基于问题的优化算法

优化函数和对象如何求解优化问题。

Automatic Differentiation Background

Learn how automatic differentiation works.

Supported Operations for Optimization Variables and Expressions

Explore the supported mathematical and indexing operations for optimization variables and expressions.