Fronte di Pareto per l'ottimizzazione multiobiettivo, basata sui problemi
Questo esempio mostra come risolvere un problema di ottimizzazione multiobiettivo utilizzando variabili di ottimizzazione e come tracciare il grafico della soluzione.
Formulazione del problema
Il problema ha una variabile di ottimizzazione bidimensionale e due funzioni obiettivo. Creare la variabile di ottimizzazione x
come vettore riga, con l'orientamento previsto dai risolutori multiobiettivo. Imposta limiti che specificano che i componenti di x
vanno da –50 a 50.
x = optimvar("x",1,2,LowerBound=-50,UpperBound=50);
Creare la funzione obiettivo a due componenti. Includere la funzione obiettivo in un problema di ottimizzazione.
fun(1) = x(1)^4 + x(2)^4 + x(1)*x(2) - x(1)^2*x(2)^2 - 9*x(1)^2;
fun(2) = x(1)^4 + x(2)^4 + x(1)*x(2) - x(1)^2*x(2)^2 + 3*x(2)^3;
prob = optimproblem("Objective",fun);
Rivedi il problema.
show(prob)
OptimizationProblem : Solve for: x minimize : ((((x(1).^4 + x(2).^4) + (x(1) .* x(2))) - (x(1).^2 .* x(2).^2)) - (9 .* x(1).^2)) ((((x(1).^4 + x(2).^4) + (x(1) .* x(2))) - (x(1).^2 .* x(2).^2)) + (3 .* x(2).^3)) variable bounds: -50 <= x(1) <= 50 -50 <= x(2) <= 50
Risolvi e traccia la soluzione
Chiama solve
per risolvere il problema.
rng default % For reproducibility sol = solve(prob)
Solving problem using gamultiobj. gamultiobj stopped because the average change in the spread of Pareto solutions is less than options.FunctionTolerance.
sol = 1x18 OptimizationValues vector with properties: Variables properties: x: [2x18 double] Objective properties: Objective: [2x18 double]
Rappresenta graficamente il fronte di Pareto risultante.
paretoplot(sol)
Risolvi nuovamente il problema utilizzando il risolutore paretosearch
.
sol2 = solve(prob,Solver="paretosearch");
Solving problem using paretosearch. Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
paretoplot(sol2)
Utilizzando le opzioni predefinite, il risolutore paretosearch
ottiene un insieme più denso di punti di soluzione rispetto a gamultiobj
. Tuttavia, gamultiobj
ottiene un intervallo di valori più ampio.
Partire da soluzioni mono-obiettivo
Per cercare di ottenere una migliore distribuzione delle soluzioni, trova le soluzioni mono-obiettivo a partire da x = [1 1]
.
x0.x = [1 1];
prob1 = optimproblem("Objective",fun(1));
solp1 = solve(prob1,x0);
Solving problem using fmincon. Local minimum possible. Constraints satisfied. fmincon stopped because the size of the current step is less than the value of the step size tolerance and constraints are satisfied to within the value of the constraint tolerance.
prob2 = optimproblem("Objective",fun(2));
solp2 = solve(prob2,x0);
Solving problem using fmincon. Local minimum found that satisfies the constraints. Optimization completed because the objective function is non-decreasing in feasible directions, to within the value of the optimality tolerance, and constraints are satisfied to within the value of the constraint tolerance.
Preparare le soluzioni mono-obiettivo come punto iniziale per solve
. Ogni punto deve essere passato come vettore colonna alla funzione optimvalues
.
start = optimvalues(prob,"x",[solp1.x' solp2.x']);
Risolvere il problema multiobiettivo con paretosearch
partendo dai punti start
.
sol3 = solve(prob,start,Solver="paretosearch");
Solving problem using paretosearch. Pareto set found that satisfies the constraints. Optimization completed because the relative change in the volume of the Pareto set is less than 'options.ParetoSetChangeTolerance' and constraints are satisfied to within 'options.ConstraintTolerance'.
paretoplot(sol3)
Questa volta, paretosearch
trova un intervallo più ampio di funzioni obiettivo, arrivando quasi a 10 nell'Obiettivo 2 e quasi a 20 nell'Obiettivo 1. Questo intervallo è simile all'intervallo gamultiobj
, ad eccezione del punto di soluzione anomala vicino all'Obiettivo 1 = –31, Obiettivo 2 = 48.
Vedi anche
gamultiobj
| paretosearch
| solve
| paretoplot