matlab 多目标规划模型
如何在Matlab中进行多目标优化问题求解

如何在Matlab中进行多目标优化问题求解如何在Matlab中进行多目标优化问题求解?多目标优化问题是指存在多个目标函数,且这些目标函数之间相互矛盾或者无法完全同时满足的问题。
在实际应用中,多目标优化问题非常常见,例如在工程设计中寻求最佳平衡点、在金融投资中追求高收益低风险等。
而Matlab作为一种强大的数值计算工具,提供了丰富的优化算法和工具箱,可以帮助我们解决多目标优化问题。
一、多目标优化问题数学建模在解决多目标优化问题之前,首先需要将实际问题转化为数学模型。
假设我们需要优化一个n维的向量x,使得目标函数f(x)同时最小化或最大化。
其中,n为自变量的个数,f(x)可以表示为多个目标函数f1(x)、f2(x)、...、fm(x)的向量形式:f(x) = [f1(x), f2(x), ..., fm(x)]其中,fi(x)(i=1,2,...,m)即为待优化的目标函数。
在多目标优化问题中,一般没有单一的最优解,而是存在一个解集,称为"帕累托前沿(Pareto Frontier)"。
该解集中的每个解被称为"非支配解(Non-Dominated Solution)",即不能被其他解所优化。
因此,多目标优化问题的目标就是找到帕累托前沿中的最佳解。
二、Matlab中的多目标优化算法Matlab提供了多种多目标优化算法和工具箱,包括paretosearch、gamultiobj、NSGA-II等等。
这些算法基于不同的思想和原理,可以根据问题的特点选择合适的算法进行求解。
1. paretosearch算法paretosearch算法采用遗传算法的思想,通过迭代更新种群来寻找非支配解。
该算法适用于求解中小规模的多目标优化问题。
使用paretosearch算法求解多目标优化问题可以按照以下步骤进行:(1)定义目标函数编写目标函数fi(x)(i=1,2,...,m)的代码。
matlab多目标优化模型教程

fgoalattainSolve multiobjective goal attainment problemsEquationFinds the minimum of a problem specified byx, weight, goal, b, beq, lb, and ub are vectors, A and Aeq are matrices, and c(x), ceq(x), and F(x) are functions that return vectors. F(x), c(x), and ceq(x) can be nonlinear functions.Syntaxx = fgoalattain(fun,x0,goal,weight)x = fgoalattain(fun,x0,goal,weight,A,b)x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq)x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub)x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon)x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,... options)x = fgoalattain(problem)[x,fval] = fgoalattain(...)[x,fval,attainfactor] = fgoalattain(...)[x,fval,attainfactor,exitflag] = fgoalattain(...)[x,fval,attainfactor,exitflag,output] = fgoalattain(...)[x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(...)Descriptionfgoalattain solves the goal attainment problem, which is one formulation for minimizing a multiobjective optimization problem.x = fgoalattain(fun,x0,goal,weight) tries to make the objective functions supplied by fun attain the goals specified by goal by varying x, starting at x0, with weight specified by weight.x = fgoalattain(fun,x0,goal,weight,A,b) solves the goal attainment problem subject to the linear inequalities A*x ≤ b.x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq) solves the goal attainment problem subject to the linear equalities Aeq*x = beq as well. Set A = [] and b = [] if no inequalities exist.x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub) defines a set of lower and upper bounds on the design variables in x, so that the solution is always in the range lb ≤ x ≤ ub.x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon) subjects the goal attainment problem to the nonlinear inequalities c(x) or nonlinear equality constraints ceq(x) defined in nonlcon. fgoalattain optimizes such that c(x) ≤ 0 and ceq(x) = 0. Set lb = [] and/or ub = [] if no bounds exist.x = fgoalattain(fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon,... options) minimizes with the optimization options specified in the structure options. Use optimset to set these options.x = fgoalattain(problem) finds the minimum for problem, where problem is a structure described in Input Arguments.Create the structure problem by exporting a problem from Optimization Tool, as described in Exporting to the MATLAB Workspace.[x,fval] = fgoalattain(...) returns the values of the objective functions computed in fun at the solution x.[x,fval,attainfactor] = fgoalattain(...) returns the attainment factor at the solution x.[x,fval,attainfactor,exitflag] = fgoalattain(...) returns a value exitflag that describes the exit condition of fgoalattain.[x,fval,attainfactor,exitflag,output] = fgoalattain(...) returns a structure output that contains information about the optimization.[x,fval,attainfactor,exitflag,output,lambda] = fgoalattain(...) returns a structure lambda whose fields contain the Lagrange multipliers at the solution x.Input ArgumentsFunction Arguments contains general descriptions of arguments passed into fgoalattain. This section provides function-specific details for fun, goal, nonlcon, options, weight, and problem:fun The function to be minimized. fun is a function that acceptsa vector x and returns a vector F, the objective functionsevaluated at x. The function fun can be specified as a functionhandle for a function file:x = fgoalattain(@myfun,x0,goal,weight)where myfun is a MATLAB function such asfunction F = myfun(x)F = ... % Compute function values at x.fun can also be a function handle for an anonymous function.x = fgoalattain(@(x)sin(x.*x),x0,goal,weight);If the user-defined values for x and F are matrices, they areconverted to a vector using linear indexing.To make an objective function as near as possible to a goalvalue, (i.e., neither greater than nor less than) use optimsetto set the GoalsExactAchieve option to the number of objectivesrequired to be in the neighborhood of the goal values. Suchobjectives must be partitioned into the first elements of thevector F returned by fun.If the gradient of the objective function can also be computedand the GradObj option is 'on', as set byoptions = optimset('GradObj','on')then the function fun must return, in the second outputargument, the gradient value G, a matrix, at x. The gradientconsists of the partial derivative dF/dx of each F at the pointx. If F is a vector of length m and x has length n, where n isthe length of x0, then the gradient G of F(x) is an n-by-m matrixwhere G(i,j) is the partial derivative of F(j) with respect tox(i) (i.e., the jth column of G is the gradient of the jthobjective function F(j)).goal Vector of values that the objectives attempt to attain. The vector is the same length as the number of objectives F returnedby fun. fgoalattain attempts to minimize the values in thevector F to attain the goal values given by goal.nonlcon The function that computes the nonlinear inequality constraints c(x) ≤ 0 and the nonlinear equality constraintsceq(x) = 0. The function nonlcon accepts a vector x and returnstwo vectors c and ceq. The vector c contains the nonlinearinequalities evaluated at x, and ceq contains the nonlinearequalities evaluated at x. The function nonlcon can bespecified as a function handle.x = fgoalattain(@myfun,x0,goal,weight,A,b,Aeq,beq,...lb,ub,@mycon)where mycon is a MATLAB function such asfunction [c,ceq] = mycon(x)c = ... % compute nonlinear inequalities at x.ceq = ... % compute nonlinear equalities at x.If the gradients of the constraints can also be computed andthe GradConstr option is 'on', as set byoptions = optimset('GradConstr','on')then the function nonlcon must also return, in the third andfourth output arguments, GC, the gradient of c(x), and GCeq,the gradient of ceq(x). Nonlinear Constraints explains how to"conditionalize" the gradients for use in solvers that do notaccept supplied gradients.If nonlcon returns a vector c of m components and x has lengthn, where n is the length of x0, then the gradient GC of c(x)is an n-by-m matrix, where GC(i,j) is the partial derivativeof c(j) with respect to x(i) (i.e., the jth column of GC is thegradient of the jth inequality constraint c(j)). Likewise, ifceq has p components, the gradient GCeq of ceq(x) is an n-by-pmatrix, where GCeq(i,j) is the partial derivative of ceq(j)with respect to x(i) (i.e., the jth column of GCeq is thegradient of the jth equality constraint ceq(j)).Passing Extra Parameters explains how to parameterize thenonlinear constraint function nonlcon, if necessary.options Options provides the function-specific details for the options values.weight A weighting vector to control the relative underattainment or overattainment of the objectives in fgoalattain. When thevalues of goal are all nonzero, to ensure the same percentageof under- or overattainment of the active objectives, set theweighting function to abs(goal). (The active objectives are theset of objectives that are barriers to further improvement ofthe goals at the solution.)When the weighting function weight is positive, fgoalattainattempts to make the objectives less than the goal values. Tomake the objective functions greater than the goal values, setweight to be negative rather than positive. To make an objectivefunction as near as possible to a goal value, use theGoalsExactAchieve option and put that objective as the firstelement of the vector returned by fun (see the precedingdescription of fun and options).problem objective Vector of objective functionsx0 Initial point for xgoal Goals to attainweight Relative importance factors of goalsAineq Matrix for linear inequality constraintsbineq Vector for linear inequality constraintsAeq Matrix for linear equality constraintsbeq Vector for linear equality constraintslb Vector of lower boundsub Vector of upper boundsnonlcon Nonlinear constraint functionsolver 'fgoalattain'options Options structure created with optimset Output ArgumentsFunction Arguments contains general descriptions of arguments returned by fgoalattain. This section provides function-specific details for attainfactor, exitflag, lambda, and output:attainfactor The amount of over- or underachievement of the goals. If attainfactor is negative, the goals have been overachieved;if attainfactor is positive, the goals have beenunderachieved.attainfactor contains the value of γ at the solution. Anegative value of γindicates overattainment in the goals.exitflag Integer identifying the reason the algorithm terminated.The following lists the values of exitflag and thecorresponding reasons the algorithm terminated.1 Function converged to a solutions x.4 Magnitude of the search direction lessthan the specified tolerance andconstraint violation less thanoptions.TolCon5 Magnitude of directional derivative lessthan the specified tolerance andconstraint violation less thanoptions.TolCon0 Number of iterations exceededoptions.MaxIter or number of functionevaluations exceeded options.FunEvals-1 Algorithm was terminated by the outputfunction.-2 No feasible point was found.lambda Structure containing the Lagrange multipliers at the solution x (separated by constraint type). The fields of thestructure arelower Lower bounds lbupper Upper bounds ubineqlin Linear inequalitieseqlin Linear equalitiesineqnonlin Nonlinear inequalitieseqnonlin Nonlinear equalitiesoutput Structure containing information about the optimization.The fields of the structure areiterations Number of iterations takenfuncCount Number of function evaluationslssteplength Size of line search step relative tosearch directionstepsize Final displacement in xalgorithm Optimization algorithm usedfirstorderopt Measure of first-order optimalityconstrviolation Maximum of constraint functionsmessage Exit messageOptionsOptimization options used by fgoalattain. You can use optimset to set or change the values of these fields in the options structure options. See Optimization Options for detailed information.DerivativeCheck Compare user-supplied derivatives (gradients ofobjective or constraints) to finite-differencingderivatives. The choices are 'on' or the default,'off'.Diagnostics Display diagnostic information about the functionto be minimized or solved. The choices are 'on' orthe default, 'off'.DiffMaxChange Maximum change in variables for finite-differencegradients (a positive scalar). The default is 0.1.DiffMinChange Minimum change in variables for finite-differencegradients (a positive scalar). The default is 1e-8. Display Level of display.∙'off' displays no output.∙'iter' displays output at each iteration, andgives the default exit message.∙'iter-detailed' displays output at eachiteration, and gives the technical exitmessage.∙'notify' displays output only if the functiondoes not converge, and gives the default exitmessage.∙'notify-detailed' displays output only if thefunction does not converge, and gives thetechnical exit message.∙'final' (default) displays just the finaloutput, and gives the default exit message.∙'final-detailed' displays just the finaloutput, and gives the technical exit message.FinDiffType Finite differences, used to estimate gradients, areeither 'forward' (default), or 'central'(centered). 'central' takes twice as many functionevaluations, but should be more accurate.The algorithm is careful to obey bounds whenestimating both types of finite differences. So, forexample, it could take a backward, rather than aforward, difference to avoid evaluating at a pointoutside bounds.FunValCheck Check whether objective function and constraintsvalues are valid. 'on' displays an error when theobjective function or constraints return a valuethat is complex, Inf, or NaN. The default, 'off',displays no error.GoalsExactAchieve Specifies the number of objectives for which it isrequired for the objective fun to equal the goal goal(a nonnegative integer). Such objectives should bepartitioned into the first few elements of F. Thedefault is 0.GradConstr Gradient for nonlinear constraint functions definedby the user. When set to 'on', fgoalattain expectsthe constraint function to have four outputs, asdescribed in nonlcon in the Input Arguments section.When set to the default, 'off', gradients of thenonlinear constraints are estimated by finitedifferences.GradObj Gradient for the objective function defined by theuser. See the preceding description of fun to seehow to define the gradient in fun. Set to 'on' tohave fgoalattain use a user-defined gradient of theobjective function. The default, 'off',causesfgoalattain to estimate gradients usingfinite differences.MaxFunEvals Maximum number of function evaluations allowed (apositive integer). The default is100*numberOfVariables.MaxIter Maximum number of iterations allowed (a positiveinteger). The default is 400.MaxSQPIter Maximum number of SQP iterations allowed (a positiveinteger). The default is 10*max(numberOfVariables,numberOfInequalities + numberOfBounds)MeritFunction Use goal attainment/minimax merit function if setto 'multiobj', the default. Use fmincon meritfunction if set to 'singleobj'.OutputFcn Specify one or more user-defined functions that anoptimization function calls at each iteration,either as a function handle or as a cell array offunction handles. The default is none ([]). SeeOutput Function.PlotFcns Plots various measures of progress while thealgorithm executes, select from predefined plots orwrite your own. Pass a function handle or a cellarray of function handles. The default is none ([]).∙@optimplotx plots the current point∙@optimplotfunccount plots the function count∙@optimplotfval plots the function value∙@optimplotconstrviolation plots the maximumconstraint violation∙@optimplotstepsize plots the step sizeFor information on writing a custom plot function,see Plot Functions.RelLineSrchBnd Relative bound (a real nonnegative scalar value) onthe line search step length such that the totaldisplacement in x satisfies|Δx(i)| ≤relLineSrchBnd· max(|x(i)|,|typicalx(i)|). This option provides control over themagnitude of the displacements in x for cases inwhich the solver takes steps that are considered toolarge. The default is none ([]).RelLineSrchBndDurat ion Number of iterations for which the bound specified in RelLineSrchBnd should be active (default is 1).TolCon Termination tolerance on the constraint violation,a positive scalar. The default is 1e-6.TolConSQP Termination tolerance on inner iteration SQPconstraint violation, a positive scalar. Thedefault is 1e-6.TolFun Termination tolerance on the function value, apositive scalar. The default is 1e-6.TolX Termination tolerance on x, a positive scalar. Thedefault is 1e-6.TypicalX Typical x values. The number of elements in TypicalXis equal to the number of elements in x0, thestarting point. The default value isones(numberofvariables,1). fgoalattain usesTypicalX for scaling finite differences forgradient estimation.UseParallel When 'always', estimate gradients in parallel.Disable by setting to the default, 'never'. ExamplesConsider a linear system of differential equations.An output feedback controller, K, is designed producing a closed loop systemThe eigenvalues of the closed loop system are determined from the matrices A, B, C, and K using the command eig(A+B*K*C). Closed loop eigenvalues must lie on the real axis in the complex plane to the left of the points [-5,-3,-1]. In order not to saturate the inputs, no element in K can be greater than 4 or be less than -4.The system is a two-input, two-output, open loop, unstable system, with state-space matrices.The set of goal values for the closed loop eigenvalues is initialized as goal = [-5,-3,-1];To ensure the same percentage of under- or overattainment in the active objectives at the solution, the weighting matrix, weight, is set to abs(goal).Starting with a controller, K = [-1,-1; -1,-1], first write a function file, eigfun.m.function F = eigfun(K,A,B,C)F = sort(eig(A+B*K*C)); % Evaluate objectivesNext, enter system matrices and invoke an optimization routine.A = [-0.5 0 0; 0 -2 10; 0 1 -2];B = [1 0; -2 2; 0 1];C = [1 0 0; 0 0 1];K0 = [-1 -1; -1 -1]; % Initialize controller matrixgoal = [-5 -3 -1]; % Set goal values for the eigenvalues weight = abs(goal); % Set weight for same percentagelb = -4*ones(size(K0)); % Set lower bounds on the controllerub = 4*ones(size(K0)); % Set upper bounds on the controller options = optimset('Display','iter'); % Set display parameter[K,fval,attainfactor] = fgoalattain(@(K)eigfun(K,A,B,C),...K0,goal,weight,[],[],[],[],lb,ub,[],options)You can run this example by using the demonstration script goaldemo. (From the MATLAB Help browser or the MathWorks™ Web site documentation, you can click the demo name to display the demo.) After about 11 iterations, a solution isActive inequalities (to within options.TolCon = 1e-006):lower upper ineqlinineqnonlin1 12 24K =-4.0000 -0.2564-4.0000 -4.0000fval =-6.9313-4.1588-1.4099attainfactor =-0.3863DiscussionThe attainment factor indicates that each of the objectives has been overachieved by at least 38.63% over the original design goals. The active constraints, in this case constraints 1 and 2, are the objectives that are barriers to further improvement and for which the percentage of overattainment is met exactly. Three of the lower bound constraints are also active.In the preceding design, the optimizer tries to make the objectives less than the goals. For a worst-case problem where the objectives must be as near to the goals as possible, use optimset to set the GoalsExactAchieve option to the number of objectives for which this is required.Consider the preceding problem when you want all the eigenvalues to be equal to the goal values. A solution to this problem is found by invoking fgoalattain with the GoalsExactAchieve option set to 3.options = optimset('GoalsExactAchieve',3);[K,fval,attainfactor] = fgoalattain(...@(K)eigfun(K,A,B,C),K0,goal,weight,[],[],[],[],lb,ub,[],... options)After about seven iterations, a solution isK =-1.5954 1.2040-0.4201 -2.9046fval =-5.0000-3.0000-1.0000attainfactor =1.0859e-20In this case the optimizer has tried to match the objectives to the goals. The attainment factor (of 1.0859e-20) indicates that the goals have been matched almost exactly.NotesThis problem has discontinuities when the eigenvalues become complex; this explains why the convergence is slow. Although the underlying methods assume the functions are continuous, the method is able to make stepstoward the solution because the discontinuities do not occur at the solution point. When the objectives and goals are complex, fgoalattain tries to achieve the goals in a least-squares sense.AlgorithmMultiobjective optimization concerns the minimization of a set of objectives simultaneously. One formulation for this problem, and implemented in fgoalattain, is the goal attainment problem of Gembicki[3]. This entails the construction of a set of goal values for the objective functions. Multiobjective optimization is discussed in Multiobjective Optimization.In this implementation, the slack variable γis used as a dummy argument to minimize the vector of objectives F(x) simultaneously; goal is a set of values that the objectives attain. Generally, prior to the optimization, it is not known whether the objectives will reach the goals (under attainment) or be minimized less than the goals (overattainment). A weighting vector, weight, controls the relative underattainment or overattainment of the objectives.fgoalattain uses a sequential quadratic programming (SQP) method, which is described in Sequential Quadratic Programming (SQP). Modifications are made to the line search and Hessian. In the line search an exact merit function (see [1] and [4]) is used together with the merit function proposed by [5]and [6]. The line search is terminated when either merit function shows improvement. A modified Hessian, which takes advantage of the special structure of the problem, is also used (see [1] and [4]). A full description of the modifications used is found in Goal Attainment Method in "Introduction to Algorithms." Setting the MeritFunction option to 'singleobj' withoptions = optimset(options,'MeritFunction','singleobj')uses the merit function and Hessian used in fmincon.See also SQP Implementation for more details on the algorithm used and the types of procedures displayed under the Procedures heading when the Display option is set to 'iter'.LimitationsThe objectives must be continuous. fgoalattain might give only local solutions.。
gurobi多目标问题matlab

Gurobi多目标问题在Matlab中的解决一、Gurobi简介Gurobi是一款强大的商业数学建模工具,广泛应用于优化领域。
它提供了多种优化算法,能够高效地解决线性规划、整数规划、二次规划等各种优化问题。
在实际工程和科学研究中,经常遇到多目标优化问题,即需要同时优化多个目标函数。
本文将介绍如何使用Gurobi在Matlab中解决多目标优化问题。
二、多目标优化问题的定义在多目标优化问题中,我们需要最小化或最大化多个目标函数,而且这些目标函数之间往往存在相互矛盾的关系。
在生产计划中,一个目标函数可能是最大化产量,另一个目标函数可能是最小化成本。
在实际应用中,我们需要找到一组可行的解,使得所有目标函数都达到一个较好的平衡。
三、Gurobi在Matlab中的调用在Matlab中调用Gurobi需要先安装Gurobi的Matlab接口。
安装完成后,我们可以在Matlab命令窗口中输入命令"gurobi"来验证是否成功安装。
接下来,我们需要在Matlab中编写代码,定义优化问题的目标函数、约束条件和变量类型。
在定义目标函数时,我们需要考虑多个目标函数之间的相关性,以及它们之间的权重关系。
在定义约束条件和变量类型时,我们需要考虑多目标函数之间可能存在的约束条件和变量之间的相互制约关系。
四、多目标优化问题的解决方法Gurobi提供了多种解决多目标优化问题的方法,包括加权法、约束法和Pareto最优解法等。
在加权法中,我们将多个目标函数进行线性组合,并引入权重因子来平衡各个目标函数之间的重要性。
在约束法中,我们将多个目标函数作为多个约束条件,通过逐步添加约束条件来找到最优解。
在Pareto最优解法中,我们寻找一组可行解,使得没有其他可行解能比它在所有目标函数上都更好。
五、案例分析以生产计划为例,假设我们需要同时考虑最大化产量和最小化成本两个目标。
我们可以先使用加权法,通过调整权重因子来平衡这两个目标的重要性,找到一个较好的解。
如何在MATLAB中进行多目标优化

如何在MATLAB中进行多目标优化多目标优化问题是指在存在多个冲突目标的情况下,求解一个能够同时最小化或最大化多个目标函数的问题。
在实际应用中,多目标优化问题被广泛应用于工程优化、金融投资、交通规划等领域。
在MATLAB中,有多种方法可以用来解决多目标优化问题,本文将介绍其中的几种常用方法。
一、多目标优化问题的定义在开始使用MATLAB进行多目标优化之前,首先需要明确多目标优化问题的数学定义。
一般而言,多目标优化问题可以表示为:```minimize f(x) = [f1(x), f2(x), ..., fm(x)]subject to g(x) ≤ 0, h(x) = 0lb ≤ x ≤ ub```其中,f(x)为多个目标函数,g(x)和h(x)为约束条件,lb和ub分别为决策变量的下界和上界。
问题的目标是找到一组决策变量x,使得目标函数f(x)取得最小值。
二、多目标优化问题的解法在MATLAB中,有多种方法可以用来解决多目标优化问题。
下面将介绍其中的几种常见方法。
1. 非支配排序遗传算法(Non-dominated Sorting Genetic Algorithm,NSGA)NSGA是一种经典的多目标优化算法,它将候选解集划分为多个等级或层次,从而使得每个解在候选解集内具备非劣势性。
在MATLAB中,可以使用多目标遗传算法工具箱(Multi-Objective Optimization Toolbox)中的`gamultiobj`函数来实现NSGA算法。
该函数可以通过指定目标函数、约束条件和决策变量范围等参数来求解多目标优化问题。
2. 多目标粒子群优化算法(Multi-objective Particle Swarm Optimization,MOPSO)MOPSO是一种基于群体智能的多目标优化算法,它模拟了粒子的行为,通过不断迭代寻找最优解。
在MATLAB中,可以使用多目标粒子群优化工具箱(Multi-Objective Particle Swarm Optimization Toolbox)中的`mopso`函数来实现MOPSO算法。
数学建模多目标规划函数fgoalattain

MATLAB 中文论坛讲义多目标规划优化问题Matlab 中常用于求解多目标达到问题的函数为fgoalattain.假设多目标函数问题的数学模型为:ubx lb beqx Aeq bx A x ceq x c goalweight x F t s yx ≤≤=≤=≤≤-**0)(0)(*)(..min ,γγ weight 为权值系数向量,用于控制对应的目标函数与用户定义的目标函数值的接近程度; goal 为用户设计的与目标函数相应的目标函数值向量;γ为一个松弛因子标量;F(x)为多目标规划中的目标函数向量。
综上,fgoalattain 的优化过程就是使得F 逼近goal;工程应用中fgoalattain 函数调用格式如下:[x,fval]=fgoalattain (fun,x0,goal,weight,A,b,Aeq,beq,lb,ub,nonlcon)x0表示初值;fun 表示要优化的目标函数;goal 表示函数fun 要逼近的目标值,是一个向量,它的维数大小等于目标函数fun 返回向量F 的维数大小;weight 表示给定的权值向量,用于控制目标逼近过程的步长;例1. 程序(利用fgoalattain 函数求解)23222123222132min )3()2()1(min x x x x x x ++-+-+-0,,6..321321≥=++x x x x x x t s①建立M 文件.function f=myfun(x)f(1)= x(1)-1)^2+(x(2)-2)^2+(x(3)-3)^2;f(2)= x(1)^2+2*x(2)^2+3*x(3)^2;②在命令窗口中输入.goal=[1,1];weight=[1,1];Aeq=[1,1,1];beq=[6];x0=[1;1;1];lb=[0,0,0]; %也可以写lb=zero(3,1);[x,fval]=fgoalattain(‘myfun’,x0,goal,weight,[ ],[ ],Aeq,beq,lb,[ ])③得到结果.x =3.27271.63641.0909fval =8.9422 19.6364例2.某钢铁公司因生产需要欲采购一批钢材,市面上的钢材有两种规格,第1种规格的单价为3500元/t ,第2种规格的单价为4000元/t.要求购买钢材的总费用不超过1000万元,够得钢材总量不少于2000t.问如何确定最好的采购方案,使购买钢材的总费用最小且购买的总量最多.解:设采购第1、2种规格的钢材数量分别为1x 和2x .根据题意建立如下多目标优化问题的数学模型.0,200010000040003500max 40003500)(min212121211≥≥+≤++=x x x x x x x x x f ①建立M 文件. 在Matlab 编辑窗口中输入:function f=myfun(x)f(1)= 3500*x(1)+4000*x(2);f(2)=-x(1)-x(2);②在命令窗口中输入.goal=[10000000,-2000];weight=[10000000,-2000];x0=[1000,1000];A=[3500,4000;-1,-1];b=[10000000;-2000];lb=[0,0]; %也可以写lb=zero(3,1);[x,fval]=fgoalattain(‘myfun ’,x0,goal,weight,A,b,[ ],[ ],lb,[ ])③得到结果.x =1000 1000fval =7500000 -2000。
多目标规划matlab程序实现——【2019数学建模+思路】

优化与决策——多目标线性规划的若干解法及MATLAB 实现摘要:求解多目标线性规划的基本思想大都是将多目标问题转化为单目标规划,本文介绍了理想点法、线性加权和法、最大最小法、目标规划法,然后给出多目标线性规划的模糊数学解法,最后举例进行说明,并用Matlab 软件加以实现。
关键词:多目标线性规划 Matlab 模糊数学。
注:本文仅供参考,如有疑问,还望指正。
一.引言多目标线性规划是多目标最优化理论的重要组成部分,由于多个目标之间的矛盾性和不可公度性,要求使所有目标均达到最优解是不可能的,因此多目标规划问题往往只是求其有效解(非劣解)。
目前求解多目标线性规划问题有效解的方法,有理想点法、线性加权和法、最大最小法、目标规划法。
本文也给出多目标线性规划的模糊数学解法。
二.多目标线性规划模型多目标线性规划有着两个和两个以上的目标函数,且目标函数和约束条件全是线性函数,其数学模型表示为:11111221221122221122max n n n nr r r rn nz c x c x c x z c x c x c x z c x c x c x =+++⎧⎪=+++⎪⎨ ⎪⎪=+++⎩ (1)约束条件为:1111221121122222112212,,,0n n n n m m mn n mn a x a x a x b a x a x a x b a x a x a x bx x x +++≤⎧⎪+++≤⎪⎪ ⎨⎪+++≤⎪≥⎪⎩ (2) 若(1)式中只有一个1122i i i in n z c x c x c x =+++ ,则该问题为典型的单目标线性规划。
我们记:()ij m n A a ⨯=,()ij r n C c ⨯=,12(,,,)T m b b b b = ,12(,,,)T n x x x x = ,12(,,,)T r Z Z Z Z = .则上述多目标线性规划可用矩阵形式表示为:max Z Cx =约束条件:0Ax bx ≤⎧⎨≥⎩(3)三.MATLAB 优化工具箱常用函数[3]在MA TLAB 软件中,有几个专门求解最优化问题的函数,如求线性规划问题的linprog 、求有约束非线性函数的fmincon 、求最大最小化问题的fminimax 、求多目标达到问题的fgoalattain 等,它们的调用形式分别为:①.[x,fval]=linprog(f,A,b,Aeq,beq,lb,ub)f 为目标函数系数,A,b 为不等式约束的系数, Aeq,beq 为等式约束系数, lb,ub 为x 的下限和上限, fval 求解的x 所对应的值。
matlab-多目标规划模型

§10.2 多目旳规划问题旳求解
1、主要目旳法
在有些多目旳决策问题中,多种目旳旳主要性程度
往往不同。其中一种主要性程度最高和最为关键旳目
旳,称之为主要目旳法。其他旳目旳则称为非主要目
旳。
optF ( X ) ( f1 ( X ), f2 ( X ),...., f p ( X ))T
2. 过程:无妨设其顺序为 f1, f2,, f p
先求解
min ( P1 )s.t.
f1 ( x) xS
再解
min (P2 )s.t.
f2 ( x) x S1
依次进行,直到
得最优值 f1*
得最优值
f
* 2
,记 S1 x f1(x) f1* S
,S2
x
f2(x)
f
* 2
S1
(Pp )ms.ti.n
f p (x) x
则
Sp
x
f p (x)
f
* p
S p1
是在分层序列意义下旳最优解集合。
3.
性质:
Sp
S
* pa
,即在分层序列意义下旳最优解是有
效解。
证明:反证。设
~
xSp
,但
~
x
S
* pa
,则必存在
~
yS
使
~
~
F(y) F(x)
即至少有一种j0 ,使
~
~
f j ( y) f j (x), j 1,, j0 1,
成本型指标
可靠性和敏捷性都属于效益型指标,其打分如下
可靠性 一般 低
高
很高
5
敏捷 高 性
3
多目标线性规划MATLAB软件求解

( )=^∑[ z ], z / Z 一
然 后 极 小 化 [ )], 求 解 z( 即
r —_ — —— —— — —— — —— —— — —— —— —— 一
m …
i ̄ ) √ ) Z] n[ ] E _i2 qZ Z i *,
并 将 它 的最 优 解
1 多 目标 线性 规划模 型
多 目标 线 性 规 划 有 着 两 个 和 两 个 以 上 的 目标 函 数 , 目标 函 数 和 约 束 条 件 全 是 线 且
性 函数 , 数 学模 型表 示 为 : 其
Z1 = C l l + 1 C1 2X 2 + … + C1 n
m
aX
21 0 0年 1 O月 第2 7卷 第 5期
枣 庄 学 院 学 报
J OUR AL 0F Z 0Z AN I R 兀Y N A HU G UN VE S
Oc . Ol t2 O
V0 . 7 N0. 12 5
多 目标 线 性 规 划 MA L B软 件 求 解 TA
2 = C1 I+ c2 2 X 2 2+ …
+ Cn n 2  ̄
( 1)
Zr =
C, l + 1
CrX 2 + 2
…
+
C m n
约 束 条 件 为 :
( 2)
若 (1 )式 中 只 有 一 个 = C +c :+ … +c , 该 问 题 为 典 型 的 单 目 标 线 性 规 划 . i l 则
值 为 z,, Z = ( *, 称 ZI
想 点 法 , 造 评 价 函数 构
r— =—— —— ——— ——— ——— —— —一
, Zr)为 值 域 中 的 一 个 理 想 点 , 为 一 般 很 难 达 到 .于 是 , 期 … * 因 在
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
X(x1,x2,...x.n), 为决策变量
如对于求极大(max)型,其各种解定义如下: 绝对最优解:若对于任意的X,都有F(X*)≥F(X) 有效解:若不存在X,使得F(X*)≤ F(X)
弱有效解:若不存在X,使得F(X*)<F(X)
2、多目标优选问题的模型结构
可用效用函数来表示。设方案的效用是目标属 性的函数: U (x)U (f1,f2,..f.p),
并设
aij fi(xj )
且各个方案的效用函数分别为
U (xj)U (a1j,a2j,.a .p .)j,
则多目标优选模型的结构可表示如下:
ord(U X)(U(X1)U , (X2),..U ..(,Xp))T s.t. gi(X)0
hj(X)0
§10.2 多目标规划问题的求解
1、主要目标法
在有些多目标决策问题中,各种目标的重要性程
甲
资源A单位消耗
9
资源B单位消耗
4
资源C单位消耗
3
单位产品的价格
400
单位产品的利润
70
单位产品的污染
3
乙
资源限量
4
240
5
200
10
300
600
120
2
解:问题的多目标模型如下
max f 1 ( X ) 70 x 1 120 x 2 max f 2 ( X ) 400 x 1 600 x 2
f2 1
56
3
7
24
8
f
二、模型结构
多目标决策问题包含有三大要素:目标、方案和决 策者。
在多目标决策问题中,目标有多层次的含义。从最高层次 来看,目标代表了问题要达到的总目标。如确定最满意的 投资项目、选择最满意的食品。从较低层次来看,目标可 看成是体现总目标得以实现的各个具体的目标,如投资项 目的盈利要大、成本要低、风险要小;目标也可看成衡量 总目标得以实现的各个准则,如食品的味道要好,质量要 好,花费要少。
对于上述模型的三个目标,工厂 确定利润最大为主要目标。另两 个目标则通过预测预先给定的希
max( f 3 ( X )) 3 x 1 2 x 2
9 x1 4 x 2 240
4 3
x1 x1
5x2 10 x
200 2 300
x 1 , x 2 0源自望达到的目标值转化为约束条件。 经研究,工厂认为总产值至少应 达到20000个单位,而污染控制 在90个单位以下,即
其余的目标满足一定的条件,即 maxf1(X)
s.t.hgji
( (
X X
) )
0, 0,
i 1,2,...,n j 1,2,...,m
fk
(X)
k
,k
1,2,..., p
1
例题1 某工厂在一个计划期内生产甲、乙两种产品,各产品 都要消耗A,B,C三种不同的资源。每件产品对资源的单位消 耗、各种资源的限量以及各产品的单位价格、单位利润和所 造成的单位污染如下表。假定产品能全部销售出去,问每期 怎样安排生产,才能使利润和产值都最大,且造成的污染最 小?
化多目标问题为单目标问题的方法大致可分为 两类,一类是转化为一个单目标问题,另一类是转化 为多个单目标问题,关键是如何转化.
下面,我们介绍几种主要的转化方法:主要目标 法、线性加权和法、字典序法、步骤法。
§10.1多目标决策问题的特征
一、解的特点
在解决单目标问题时,我们的任务是选择一个或一组
变量X,使目标函数f(X)取得最大(或最小)。对于任意两方
精品课件
1
多目标规划模型
在现实生活中,决策的目标往往有多个,例如,对企业产品的 生产管理,既希望达到高利润,又希望优质和低消耗,还希望减少对 环境的污染等.这就是一个多目标决策的问题.又如选购一个好的计 算机系统,似乎只有一个目标,但由于要从多方面去反映,要用多个 不同的准则来衡量,比如,性能要好,维护要容易,费用要省.这些准 则自然构成了多个目标,故也是一个多目标决策问题.
案所对应的解,只要比较它们相应的目标值,就可以判断谁 优谁劣。但在多目标情况下,问题却不那么单纯了。例如,
有两个目标f1(X),f2(X),希望它们都越大越好。下图列出在
这两个目标下共有8个解的方案。其中方案1,2,3,4称为劣 解,因为它们在两个目标值上都比方案5差,是可以淘汰的解 。而方案5,6,7,8是非劣解(或称为有效解,满意解), 因为这些解都不能轻易被淘汰掉,它们中间的一个与其余任 何一个相比,总有一个指标更优越,而另一个指标却更差。
f2(X)40x0160x02 20000 f3(X)3x12x2 90
由主要目标法化为单目标问题
max f 1 ( X ) 70 x 1 120 x 2
用单纯形法求得其最优解为
x1 12.5,x2 26.25, f1(x) 4025, f2(x) 2075,0f3(x) 90
400 x 1 600 x 2 20000
度往往不一样。其中一个重要性程度最高和最为关键
的目标,称之为主要目标法。其余的目标则称为非主
要目标。 opt(FX)(f1(X),f2(X),...f.p,(X))T
s.t. gi(X)0
hj(X)0
例如,在上述多目标问题中,假定f1(X)为主要目标,其余p-1
个为非主要目标。这时,希望主要目标达到极大值,并要求
多目标决策问题中的方案即为决策变量,也称为 多目标问题的解。备选方案即决策问题的可行解。在多目 标决策中,有些问题的方案是有限的,有些问题 的方案是 无限的。方案有其特征或特性,称之为属性。
1、多目标规划问题的模型结构
opt(FX)(f1(X),f2(X),...f.p,(X))T s.t. gi(X)0
矛盾性、不可公度性。
一般来说,多目标决策问题有两类.一类是多目标规划问题,其 对象是在管理决策过程中求解使多个目标都达到满意结果的最优方 案.另一类是多目标优选问题,其对象是在管理决策过程中根据多个 目标或多个准则衡量和得出各种备选方案的优先等级与排序.
多目标决策由于考虑的目标多,有些目标之 间又彼此有矛盾,这就使多目标问题成为一个复杂而 困难的问题.但由于客观实际的需要,多目标决策问 题越来越受到重视,因而出现了许多解决此决策问题 的方法.一般来说,其基本途径是,把求解多目标问题 转化为求解单目标问题.其主要步骤是,先转化为单 目标问题,然后利用单目标模型的方法,求出单目标 模型的最优解,以此作为多目标问题的解.