function [J,X] = CostFunction_RBS_RMS_2n(X,Dat) % Load data from spMODEparam (execute first) OD = Dat.DataOD; XFP = Dat.DataXFP_per_cell; % Number of copies per experiment Copies = size(OD,2)/(Dat.NOBJ/2); % Initialize variables J = zeros(size(X,1),Dat.NOBJ); Vculture = 200; % volume of microplate well (microliters) Ccells_OD600_1=8e5; % cells/microliter for OD=1. % Source: Agilent, E. coli Cell Culture Concentration % from OD600 Calculator OD_0 = min(min(OD,[],1)); % Initial OD_600 (%0.2 fosbe) Ncells_0 = Vculture*OD_0*Ccells_OD600_1; % initial number of cells cn = 500; % Number of plasmids in cell Cr = cn*600/720; % 600(bp/min)/720(bp)*500(plasmids/cell) dm = 0.247; % min-1 %dp = 0.0063; % min-1 Kmax_exp = max(max(OD,[],1)); % Max OD_600 (1.128 fosbe) Kmax = Vculture*Kmax_exp*Ccells_OD600_1; % Maximum capacity, in number % of cells, for a 200 % microliters batch of E. coli % in LB medium. % Fitted from experimental data for xpop=1:size(X,1) % Decision variables & parameters p = X(xpop,1); dp = X(xpop,2); mu = X(xpop,3); param = [Cr p dm dp mu Kmax]; % Simulation and experimental parameters time = Dat.DataTime; % Each 5 minutes aprox options = odeset('RelTol',1e-6,'AbsTol',1e-6); % Initial Conditions of variables (except n3 = input) n1_0 = Cr/(dm+mu); % mRNA n2_0 = Cr*p/((dm+mu)*(dp+mu)); % PoI n3_0 = Ncells_0; % Number of cells InitC = [n1_0; n2_0; n3_0]; % Model simulation [t,n]=ode45(@mc_simple,time,InitC,options,param); %Output -> Simulated XFP and cells growth XFP_sim = n(:,2).*ones(length(time),Copies); Ncells_sim = n(:,3).*ones(length(time),Copies); OD_sim = Ncells_sim/(Vculture*Ccells_OD600_1); k = 1; error_XFP = zeros(length(time),Copies*Dat.NOBJ); % There are N copies of experiments error_OD = zeros(length(time),Copies*Dat.NOBJ); for j = 1:(Dat.NOBJ/2) % Square error error_XFP(:,k:(k+Copies-1)) = (( XFP(:,k:(k+Copies-1)) - XFP_sim )).^2; error_OD(:,k:(k+Copies-1)) = (( OD(:,k:(k+Copies-1)) - OD_sim )).^2; k = k + Copies; %N-fold to the next value end %% Optimization % Objectives: minimize error J1,...,6 = mean of XFP and OD for each input step % value. RMS Error j1 = sqrt(mean(error_XFP(:,1:Copies),1)); j2 = sqrt(mean(error_XFP(:,Copies+1:2*Copies),1)); j3 = sqrt(mean(error_XFP(:,2*Copies+1:3*Copies),1)); j4 = sqrt(mean(error_OD(:,1:Copies),1)); j5 = sqrt(mean(error_OD(:,Copies+1:2*Copies),1)); j6 = sqrt(mean(error_OD(:,2*Copies+1:3*Copies),1)); % Total error XFP and OD J1 = mean(j1,2); J2 = mean(j2,2); J3 = mean(j3,2); J4 = mean(j4,2); J5 = mean(j5,2); J6 = mean(j6,2); J(xpop,:)=[J1, J2, J3, J4, J5, J6]; end %% Mechanism to improve basic pertinency (Objective space bounded). % For an example, please, refer to: % G. Reynoso-Meza, J. Sanchis, X. Blasco, J.M. Herrero. Multiobjective % evolutionary algorithms for multivariable PI controller design. Expert % Systems with Applications Volume 39, Issue 9, July 2012, Pages 7895�7907. if isempty(Dat.Pertinency) %Nothing happens else for xpop=1:size(J,1) PenUpper=0; PenLower=0; for nobj=1:size(J,2) PenUpper=PenUpper+... max((J(xpop,nobj)-Dat.Pertinency(nobj,2)),0)/... Dat.Pertinency(nobj,2); PenLower=PenLower+... max((Dat.Pertinency(nobj,1)-J(xpop,nobj)),0)/... Dat.Pertinency(nobj,2); end if PenUpper+PenLower>0 Penalty=max(Dat.Pertinency(:,2))+PenUpper+PenLower; J(xpop,:)=Penalty*ones(1,size(J,2)); end end end