Multiobjective functions mixed with integer variables
Mostrar comentarios más antiguos
Hello,
I write this code in matlab, and I try to run ot it gave me the error:"Nonlinear equality constraints not supported."
The code here is to maximize two functions with having 3*N varailbes which are integers [0,1]. In addition there is a constraint that limit the functions.
Can anyone help me?
Thank you in advance
% Identifying some parameters
N = 5; % number of parts
u = [4, 4, 4, 4, 4]; % usage year
L = [10, 10, 10, 10, 10]; % End-of-Life year
Ctre = [-37.29, -35.31, -46.06, 5.49, 24.17]; % Cost of treatment and disposal
Crs = ones(1,N); % Cost of reuse
Cdis = ones(1,N); % Disassembly cost
Cp = 500; % total cost of the product
EpsilonQ = 0.7; % Constraint about the quality of the recovery option
% Second we identy the 0-1 variables
Rec = optimvar('REC',3*N,'Type','integer','LowerBound',0,'UpperBound',1); % Binary value: 1 if part j is recycled, otherwise 0
% Define the inequation and the equation of the variable
Aineq = [];
Bineq = [];
Aeq = [];
Beq = [];
nlcon = @nonlcon;
fun = @objval;
% Problem solving
% Pareto search
npts = 160;
opts_ps.ParetoSetSize = npts;
[x_ps2, fval_ps2, ~, psoutput2] = paretosearch(fun, 3*N , Aineq,Bineq,Aeq,Beq,[],[],nlcon, opts_ps);
disp("Total function Count: "+psoutput2.funcount);
% Genetic algorithm
opts_ga = optimoptions("gamultiobj", "Display","off", "PopulationSize",2*npts);
[x_ga1, fval_ga1, ~, gaoutput1] = gamultiobj(fun, 3*N, [],[],[],[],[],[],nlcon,opts_ga);
disp("Total function Count: "+gaoutput1.funcount);
% Define the objective function
function F = objval(Rec)
N = 5; % number of parts
%C = Ctre * x + (Crs .* ((L-u)/L)) * y + Cdis * (x + y); % Total recovery cost of product / must be minimized
rc = [0, 3.57, 0, 24.31, 8.1]./100; % recycling rate
rs = [0.81, 0, 4.89, 24.31, 0]./100; % reuse rate
e = [10, 9.4, 10, 14, 29]./100; % CO2 saving rate
R = sum (rc .* Rec(1:N)) + sum (rs .* Rec(N+1:2*N)); % Total recovery rate of product / must be maximize
E = sum (e .* (Rec(1:N) + Rec(N + 1: 2 * N))); % Total CO2 saving rate of product / must be maximize
F = [R,E];
end
% define objective variable constraints
function [Cineq, Ceq] = nonlcon(Rec)
N = 5; % number of parts
rc = [0, 3.57, 0, 24.31, 8.1]./100; % recycling rate
rs = [0.81, 0, 4.89, 24.31, 0]./100; % reuse rate
e = [10, 9.4, 10, 14, 29]./100; % CO2 saving rate
EpsilonR = 0.5; % Constraint of total recovery rate for selected parts
EpsilonCO2 = 0.9; % Constraint of total CO2 saving rate of selected parts
u = [4, 4, 4, 4, 4]; % usage year
L = [10, 10, 10, 10, 10]; % End-of-Life year
Ceq = [];
for i=1:N
Ceq = [Ceq, Rec(i) + Rec(N + i) + Rec(2*N + i) - 1];
end
Cineq1 = (sum(rc .* Rec(1:N)) + sum(rs .* Rec(N+1:2*N)))/N;
Cineq2 = (sum(e .* Rec(1:N)) + sum(e .* Rec(N+1:2*N)))/N;
Cineq = [EpsilonR - Cineq1, EpsilonCO2 - Cineq2] ;
for i = 1:N
Cineq = [Cineq, u(i) * Rec(N+i) - L(i)];
end
end
Respuesta aceptada
Más respuestas (0)
Categorías
Más información sobre Global or Multiple Starting Point Search en Centro de ayuda y File Exchange.
Productos
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!