Main Content

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

基于问题的优化设置

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

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

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

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

有关基本非线性优化示例,请参阅基于问题求解有约束非线性问题:。有关基本混合整数线性规划示例,请参阅混合整数线性规划基础:基于问题。有关基本方程求解示例,请参阅Solve Nonlinear System of Equations, Problem-Based

函数

全部展开

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

Problem-based steps for solving optimization problems.

Problem-Based Workflow for Solving Equations

Problem-based steps for solving equations.

Optimization Expressions

Expressions define both 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.

Named Index for Optimization Variables

How to create and work with named indices for variables.

Review or Modify Optimization Problems

Shows how to review or modify problem elements such as variables and constraints.

Examine Optimization Solution

How to evaluate the solution and its quality.

设置选项

设置选项

设置优化选项

Output Function for Problem-Based Optimization

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

基于问题的优化技巧

Create Efficient Optimization Problems

Tips for obtaining a faster or more accurate solution when there are integer constraints, and for avoiding loops in problem creation.

Separate Optimization Model from Data

To create reusable, scalable problems, separate the model from the data.

Variables with Duplicate Names Disallowed

Solution to the problem of two optimization variables with the same name.

Create Initial Point for Optimization with Named Index Variables

This example shows how to create initial points for solve when you have 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 your 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.

并行计算

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.

基于问题的算法

Problem-Based Optimization Algorithms

How the optimization functions and objects solve optimization problems.

Automatic Differentiation Background

Learn how automatic differentiation works.

Supported Operations on Optimization Variables and Expressions

Lists all available mathematical and indexing operations on optimization variables and expressions.