Genetic algorithm for non linear model optimisation
Mostra commenti meno recenti
Hello everyone
Dealing with clinical data; I try to optimize a non-linear model with a genetic algorithm. Indeed, after identifying a satisfactory non-linear model (IDNLARX with 2 inputs and 4 outputs), I try to identify the most favorable conditions in terms of input (Synchro_input) for drug consumption (Synchro_output (:, 2) named 'NAD') to ensure a high blood pressure values (Synchro_output (1), named 'PAM'). My fitness function is to minimise the ratio of NAD/PAM.
The algorithm did not function well and here is the warning: ----------------------------------------
Warning: You have more channels than data.
Check if data matrix should be transposed.
> In @iddata\private\datachk at 26
In iddata.pvset at 141
In iddata.set at 142
In iddata.subsasgn at 72
In idnlarx.sim at 327
In IDNLARX_fitness at 14
In gads\private\validate>@(x)fitness(x,FitnessFcnArgs{:}) at 119
In gads\private\fcnvectorizer at 12
In gads\private\stepGA at 45
In gads\private\galincon at 63
In ga at 306
In gads\private\gaguirun at 38
In gadsswitchyard at 13
---------------------------- here is the fitness function:
function y = IDNLARX_fitness(x)
Synchro_input=[0.710280000000000,0.526234000000000;0.710280000000000,0.526234000000000;0.710280000000000,0.526234000000000;0.710280000000000,0.526234000000000;0.710280000000000,0.360519000000000;0.728972000000000,0.360519000000000;0.710280000000000,0.360519000000000;0.598131000000000,0.360519000000000;0.448598000000000,0.360519000000000;0.366355000000000,0.360519000000000;0.411215000000000,0.360519000000000;0.443258000000000,0.360519000000000;0.448598000000000,0.360519000000000;0.444444000000000,0.360519000000000;0.456075000000000,0.315065000000000;0.455395000000000,0.315065000000000;0.464174000000000,0.315065000000000;0.477354000000000,0.315065000000000;0.474479000000000,0.315065000000000;0.471603000000000,0.315065000000000;0.489097000000000,0.315065000000000;0.501558000000000,0.315065000000000;0.507788000000000,0.315065000000000;0.467290000000000,0.315065000000000;0.439252000000000,0.315065000000000;0.411215000000000,0.719394000000000;0.386293000000000,0.719394000000000;0.370433000000000,0.719394000000000;0.356839000000000,0.719394000000000;0.336449000000000,0.719394000000000;0.303219000000000,0.719394000000000;0.252336000000000,0.719394000000000;0.197597000000000,0.719394000000000;0.197597000000000,0.719394000000000;0.186916000000000,0.719394000000000;0.192256000000000,0.719394000000000;0.213618000000000,0.719394000000000;0.229640000000000,1;0.277704000000000,1;0.336449000000000,1;0.373832000000000,1;0.406542000000000,1;0.431983000000000,1;0.452336000000000,1;0.492778000000000,1;0.526480000000000,1;0.554996000000000,1;0.603882000000000,1;0.652768000000000,1;0.687275000000000,0.963636000000000;0.707405000000000,0.963636000000000;0.718907000000000,0.963636000000000;0.733285000000000,0.963636000000000;0.750539000000000,0.963636000000000;0.741912000000000,0.963636000000000;0.724659000000000,0.963636000000000;0.710280000000000,0.963636000000000;0.687275000000000,0.963636000000000;0.658519000000000,0.963636000000000;0.626887000000000,0.963636000000000;0.598131000000000,0.963636000000000;0.578001000000000,0.948918000000000;0.563863000000000,0.948918000000000;0.582555000000000,0.948918000000000;0.598131000000000,0.948918000000000;0.601246000000000,0.948918000000000;0.613707000000000,0.948918000000000;0.641745000000000,0.948918000000000;0.676012000000000,0.948918000000000;0.707165000000000,0.948918000000000;0.725857000000000,0.948918000000000;0.747664000000000,0.948918000000000;0.769470000000000,0.948918000000000;0.791277000000000,0.960173000000000;0.803738000000000,0.960173000000000;0.796549000000000,0.960173000000000;0.787922000000000,0.960173000000000;0.785047000000000,0.960173000000000;0.759166000000000,0.960173000000000;0.747664000000000,0.960173000000000;0.759166000000000,0.960173000000000;0.756290000000000,0.960173000000000;0.756290000000000,0.960173000000000;0.744788000000000,0.960173000000000;0.739037000000000,0.960173000000000;0.733285000000000,0.960173000000000;0.730410000000000,0.960173000000000;0.721783000000000,0.960173000000000;0.710280000000000,0.960173000000000;0.698778000000000,0.960173000000000;0.704529000000000,0.960173000000000;0.716032000000000,0.960173000000000;0.687275000000000,0.960173000000000;0.655643000000000,0.960173000000000;0.644141000000000,0.960173000000000;0.626887000000000,0.960173000000000;0.621136000000000,0.479654000000000;0.612509000000000,0.479654000000000;0.647017000000000,0.479654000000000;0.644860000000000,0.479654000000000;0.644860000000000,0.479654000000000;0.652506000000000,0.479654000000000;0.618522000000000,0.479654000000000;0.594393000000000,0.479654000000000;0.598131000000000,0.479654000000000;0.589823000000000,0.479654000000000;0.610592000000000,0.479654000000000;0.623053000000000,0.479654000000000;0.618899000000000,0.352900000000000;0.618899000000000,0.352900000000000;0.621495000000000,0.352900000000000;0.551402000000000,0.352900000000000;0.560748000000000,0.352900000000000;0.564901000000000,0.352900000000000;0.557009000000000,0.352900000000000;0.575701000000000,0.352900000000000;0.557349000000000,0.352900000000000;0.542056000000000,0.352900000000000;0.542056000000000,0.352900000000000;0.529595000000000,0.352900000000000;0.510903000000000,0.352900000000000;0.507788000000000,0.352900000000000;0.510903000000000,0.352900000000000;0.520489000000000,0.352900000000000;0.529116000000000,0.352900000000000;0.534867000000000,0.352900000000000;0.531991000000000,0.352900000000000;0.537743000000000,0.352900000000000;0.554996000000000,0.352900000000000;0.569375000000000,0.352900000000000;0.598131000000000,0.352900000000000;0.612509000000000,0.352900000000000;0.632638000000000,0.352900000000000;0.652768000000000,0.352900000000000;0.655643000000000,0.352900000000000;0.655643000000000,0.352900000000000;0.649892000000000,0.352900000000000;0.644141000000000,0.352900000000000;0.644141000000000,0.352900000000000;0.661395000000000,0.352900000000000;0.672897000000000,0.352900000000000;0.675773000000000,0.352900000000000;0.684400000000000,0.352900000000000;0.675773000000000,0.352900000000000;0.678648000000000,0.352900000000000;0.655643000000000,0.352900000000000;0.644141000000000,0.352900000000000;0.655643000000000,0.352900000000000;0.667146000000000,0.352900000000000;0.681524000000000,0.352900000000000;0.687275000000000,0.352900000000000;0.690151000000000,0.352900000000000;0.681524000000000,0.352900000000000;0.678648000000000,0.352900000000000;0.675773000000000,0.352900000000000;0.675773000000000,0.352900000000000;0.672897000000000,0.352900000000000;0.672897000000000,0.352900000000000;];
Synchro_output=[0.931001000000000,0.146341000000000,0.191587000000000,0.362782000000000;0.968681000000000,0.146341000000000,0.193229000000000,0.367078000000000;0.986543000000000,0.146341000000000,0.206679000000000,0.371375000000000;1,0.146341000000000,0.220130000000000,0.380773000000000;0.992510000000000,0.150094000000000,0.233580000000000,0.390172000000000;0.979679000000000,0.153846000000000,0.247030000000000,0.399570000000000;0.966883000000000,0.157598000000000,0.260480000000000,0.408969000000000;0.960455000000000,0.161351000000000,0.264495000000000,0.418367000000000;0.955368000000000,0.171357000000000,0.268510000000000,0.427766000000000;0.947107000000000,0.181363000000000,0.272525000000000,0.437164000000000;0.933988000000000,0.247029000000000,0.276540000000000,0.446563000000000;0.926743000000000,0.312695000000000,0.288347000000000,0.478518000000000;0.921752000000000,0.378361000000000,0.300155000000000,0.510473000000000;0.898625000000000,0.444028000000000,0.334501000000000,0.538937000000000;0.885814000000000,0.509694000000000,0.368848000000000,0.567401000000000;0.876496000000000,0.575360000000000,0.403194000000000,0.595865000000000;0.864517000000000,0.641026000000000,0.437540000000000,0.624329000000000;0.863851000000000,0.702939000000000,0.460078000000000,0.652793000000000;0.845882000000000,0.764853000000000,0.482617000000000,0.681257000000000;0.830242000000000,0.826767000000000,0.505156000000000,0.709721000000000;0.823088000000000,0.888680000000000,0.527694000000000,0.738185000000000;0.828745000000000,0.944340000000000,0.550233000000000,0.766649000000000;0.814769000000000,1,0.572771000000000,0.795113000000000;0.801458000000000,1,0.595310000000000,0.816058000000000;0.796633000000000,1,0.617848000000000,0.831096000000000;0.779163000000000,1,0.662524000000000,0.846133000000000;0.764355000000000,0.988118000000000,0.707200000000000,0.861171000000000;0.748383000000000,0.976235000000000,0.751875000000000,0.876208000000000;0.739731000000000,0.964353000000000,0.774012000000000,0.891246000000000;0.735072000000000,0.952470000000000,0.796149000000000,0.906284000000000;0.735405000000000,0.940588000000000,0.818286000000000,0.921321000000000;0.736570000000000,0.928705000000000,0.840423000000000,0.936359000000000;0.730580000000000,0.916823000000000,0.862560000000000,0.951396000000000;0.720597000000000,0.879300000000000,0.884698000000000,0.966434000000000;0.715772000000000,0.841776000000000,0.906835000000000,0.981472000000000;0.713942000000000,0.804253000000000,0.928972000000000,1;0.707619000000000,0.777361000000000,0.951109000000000,0.995972000000000;0.699799000000000,0.750469000000000,0.967406000000000,0.991944000000000;0.693643000000000,0.723577000000000,0.983703000000000,0.987916000000000;0.678835000000000,0.708568000000000,1,0.983888000000000;0.658870000000000,0.693558000000000,0.994160000000000,0.979860000000000;0.653046000000000,0.678549000000000,0.988320000000000,0.975832000000000;0.651216000000000,0.663540000000000,0.982480000000000,0.971805000000000;0.652214000000000,0.648530000000000,0.976640000000000,0.967777000000000;0.649053000000000,0.633521000000000,0.970800000000000,0.963749000000000;0.649219000000000,0.611007000000000,0.964960000000000,0.959721000000000;0.655542000000000,0.604753000000000,0.959120000000000,0.955693000000000;0.664859000000000,0.598499000000000,0.953280000000000,0.945220000000000;0.672014000000000,0.592245000000000,0.947440000000000,0.942266000000000;0.674010000000000,0.575360000000000,0.936655000000000,0.939313000000000;0.681997000000000,0.558474000000000,0.925869000000000,0.936359000000000;0.684326000000000,0.536585000000000,0.915083000000000,0.933405000000000;0.688153000000000,0.514697000000000,0.910138000000000,0.930451000000000;0.700465000000000,0.492808000000000,0.905192000000000,0.927497000000000;0.708784000000000,0.470919000000000,0.900246000000000,0.924544000000000;0.717103000000000,0.449031000000000,0.895301000000000,0.921590000000000;0.722926000000000,0.427142000000000,0.890355000000000,0.918636000000000;0.736237000000000,0.395247000000000,0.885409000000000,0.915682000000000;0.749547000000000,0.370857000000000,0.880464000000000,0.912728000000000;0.762192000000000,0.355847000000000,0.875518000000000,0.901719000000000;0.780328000000000,0.340838000000000,0.870572000000000,0.887218000000000;0.796633000000000,0.318324000000000,0.864951000000000,0.872718000000000;0.802124000000000,0.295810000000000,0.859330000000000,0.858217000000000;0.813604000000000,0.273296000000000,0.853709000000000,0.843716000000000;0.822921000000000,0.255785000000000,0.853034000000000,0.829216000000000;0.835400000000000,0.233896000000000,0.852359000000000,0.814715000000000;0.846548000000000,0.212008000000000,0.851684000000000,0.800215000000000;0.856198000000000,0.190119000000000,0.851008000000000,0.785714000000000;0.868510000000000,0.168230000000000,0.850333000000000,0.771214000000000;0.880157000000000,0.146341000000000,0.849658000000000,0.756713000000000;0.886313000000000,0.153221000000000,0.848983000000000,0.747046000000000;0.875498000000000,0.160100000000000,0.848307000000000,0.737379000000000;0.880989000000000,0.166979000000000,0.847632000000000,0.734157000000000;0.889640000000000,0.173859000000000,0.835624000000000,0.730934000000000;0.894465000000000,0.172608000000000,0.823615000000000,0.727712000000000;0.906944000000000,0.171357000000000,0.811607000000000,0.724490000000000;0.917759000000000,0.170106000000000,0.800274000000000,0.721267000000000;0.930237000000000,0.168856000000000,0.788941000000000,0.718045000000000;0.929572000000000,0.171982000000000,0.777607000000000,0.714823000000000;0.931735000000000,0.175109000000000,0.766274000000000,0.711600000000000;0.932899000000000,0.188868000000000,0.754941000000000,0.708378000000000;0.939056000000000,0.202627000000000,0.743608000000000,0.705156000000000;0.935894000000000,0.210757000000000,0.732275000000000,0.703276000000000;0.932255000000000,0.205754000000000,0.720942000000000,0.701396000000000;0.924109000000000,0.190744000000000,0.703568000000000,0.707573000000000;0.917350000000000,0.175735000000000,0.686194000000000,0.713749000000000;0.907991000000000,0.160725000000000,0.668820000000000,0.719925000000000;0.909377000000000,0.156348000000000,0.651446000000000,0.726101000000000;0.905044000000000,0.151970000000000,0.645406000000000,0.732277000000000;0.904525000000000,0.147592000000000,0.639365000000000,0.738453000000000;0.903658000000000,0.143215000000000,0.633324000000000,0.744629000000000;0.900192000000000,0.138837000000000,0.627284000000000,0.750806000000000;0.899152000000000,0.135084000000000,0.621243000000000,0.756982000000000;0.893259000000000,0.120700000000000,0.615202000000000,0.763158000000000;0.889273000000000,0.106316000000000,0.609161000000000,0.770408000000000;0.885807000000000,0.0975610000000000,0.603121000000000,0.772825000000000;0.894299000000000,0.0888055000000000,0.589634000000000,0.775242000000000;0.896899000000000,0.0900563000000000,0.576147000000000,0.777658000000000;0.901578000000000,0.0856785000000000,0.562661000000000,0.780075000000000;0.896725000000000,0.0813008000000000,0.555215000000000,0.782492000000000;0.890139000000000,0.0819262000000000,0.547769000000000,0.784909000000000;0.880954000000000,0.0825516000000000,0.540323000000000,0.787325000000000;0.874021000000000,0.0831770000000000,0.532877000000000,0.789742000000000;0.870728000000000,0.0838024000000000,0.525431000000000,0.792159000000000;0.861889000000000,0.0844278000000000,0.517985000000000,0.794576000000000;0.857037000000000,0.0838024000000000,0.510539000000000,0.796992000000000;0.843171000000000,0.0819262000000000,0.503093000000000,0.787057000000000;0.847712000000000,0.0787992000000000,0.495647000000000,0.775779000000000;0.848877000000000,0.0756723000000000,0.500557000000000,0.764501000000000;0.850541000000000,0.0669168000000000,0.505466000000000,0.753222000000000;0.847213000000000,0.0581614000000000,0.510375000000000,0.741944000000000;0.847546000000000,0.0550344000000000,0.522730000000000,0.730666000000000;0.850707000000000,0.0519074000000000,0.535085000000000,0.719388000000000;0.854368000000000,0.0487805000000000,0.547440000000000,0.708110000000000;0.856697000000000,0.0456535000000000,0.559796000000000,0.696831000000000;0.854201000000000,0.0425266000000000,0.572151000000000,0.685553000000000;0.861688000000000,0.0393996000000000,0.584506000000000,0.674275000000000;0.860191000000000,0.0362727000000000,0.596861000000000,0.662997000000000;0.861356000000000,0.0337711000000000,0.609216000000000,0.654135000000000;0.860191000000000,0.0325203000000000,0.621571000000000,0.644200000000000;0.867844000000000,0.0325203000000000,0.634839000000000,0.634264000000000;0.868676000000000,0.0325203000000000,0.648107000000000,0.624329000000000;0.870839000000000,0.0325203000000000,0.661374000000000,0.614393000000000;0.865848000000000,0.0325203000000000,0.662287000000000,0.604458000000000;0.872503000000000,0.0325203000000000,0.663199000000000,0.594522000000000;0.872503000000000,0.0325203000000000,0.664112000000000,0.584586000000000;0.865016000000000,0.0325203000000000,0.665024000000000,0.574651000000000;0.865182000000000,0.0325203000000000,0.665937000000000,0.564715000000000;0.864018000000000,0.0325203000000000,0.666849000000000,0.554780000000000;0.868344000000000,0.0325203000000000,0.667762000000000,0.544844000000000;0.870174000000000,0.0325203000000000,0.668674000000000,0.545918000000000;0.879325000000000,0.0325203000000000,0.669587000000000,0.559345000000000;0.879990000000000,0.0325203000000000,0.660480000000000,0.572771000000000;0.881488000000000,0.0325203000000000,0.651373000000000,0.586198000000000;0.887977000000000,0.0325203000000000,0.642267000000000,0.599624000000000;0.896129000000000,0.0325203000000000,0.632247000000000,0.613050000000000;0.900122000000000,0.0325203000000000,0.622228000000000,0.626477000000000;0.901786000000000,0.0325203000000000,0.612209000000000,0.639903000000000;0.900122000000000,0.0325203000000000,0.602190000000000,0.653330000000000;0.901121000000000,0.0325203000000000,0.592171000000000,0.666756000000000;0.909273000000000,0.0325203000000000,0.582152000000000,0.680183000000000;0.908608000000000,0.0325203000000000,0.572132000000000,0.693609000000000;0.913433000000000,0.0325203000000000,0.562113000000000,0.697637000000000;0.914598000000000,0.0325203000000000,0.552094000000000,0.699248000000000;0.919922000000000,0.0325203000000000,0.543060000000000,0.700859000000000;0.915929000000000,0.0325203000000000,0.534027000000000,0.702470000000000;0.911103000000000,0.0325203000000000,0.524993000000000,0.708244000000000;0.907110000000000,0.0325203000000000,0.525979000000000,0.714519000000000;0.906278000000000,0.0325203000000000,0.526964000000000,0.721365000000000;0.903783000000000,0.0325203000000000,0.527950000000000,0.728863000000000;0.903284000000000,0.0325203000000000,0.528935000000000,0.737111000000000;0.913433000000000,0.0325203000000000,0.529921000000000,0.746226000000000;0.909273000000000,0.0325203000000000,0.530906000000000,0.756355000000000;0.903783000000000,0.0325203000000000,0.531892000000000,0.767675000000000;0.899457000000000,0.0325203000000000,0.532877000000000,0.780411000000000;0.895131000000000,0.0325203000000000,0.533863000000000,0.776495000000000;0.894965000000000,0.0325203000000000,0.539849000000000,0.772019000000000;0.892469000000000,0.0325203000000000,0.545834000000000,0.766855000000000;];
S_ECLS = iddata(Synchro_output(1:80,:), Synchro_input(1:80,:), 300,'Name','S_ECLS');
S_ECLS.InputName={'PAPd','PCT'};
S_ECLS.OutputName={'PAM','NAD','CRP','Xray'};
S_ECMO = iddata(Synchro_output(81:158,:), Synchro_input(81:158,:), 300, 'Name', 'S_ECMO');
S_ECMO.InputName={'PAPd','PCT'};
S_ECMO.OutputName={'PAM','NAD','CRP','Xray'};
nk=[1 1;1 1;1 1;1 1];
nb=[2 2;2 2;2 2;2 2];
na=[2 0 0 0;0 2 0 0;0 0 2 0;0 0 0 2];
SynchroNLARX = nlarx(S_ECLS,[na nb nk], wavenet);
t=sim(SynchroNLARX,[x(1) x(2)]);
y=min((t(:,2)+0.1)./(t(:,1)+0.1));
------------- Thanks for any help.
4 Commenti
Matt J
il 30 Giu 2013
Seems doubtful that you've shown your actual code. This line
SynchroNLARX = nlarx(S_ECLS,[na nb nk], wavenet);
should have given an error, since 'wavenet' is not enclosed in quotes.
Matt J
il 3 Lug 2013
Abdelmoumen Commented
Hello Really, there's nothing doubtful, but the only trouble is to find help by allowing anyone to manipulate data whose usefulness remains confidential.The only warnings were those declared above. The wavenet doesn't generate a special error.
I have run your code, and I get
Undefined function or variable 'wavenet'.
Error in test>IDNLARX_fitness (line 19)
SynchroNLARX = nlarx(S_ECLS,[na nb nk], wavenet);
So, I still don't think you have provided code that let's one reproduce your issue.
In any case, the warning you see is coming from sim(), not from ga() itself. You could use "dbstop if warning" to trap the occurence of the warning and to examine what exactly is being fed to sim at that point in the code.
Matt J
il 6 Lug 2013
Abdelmoumen Commented
Thanks Matt for reply, I have changed my code as follow:
SynchroNLARX = nlarx(S_ECLS,[na nb nk],'wavenet');
t=sim(SynchroNLARX,[x(1) x(2) x(3) x(4) x(5) x(6) x(7) x(8) x(9) x(10);x(11) x(12) x(13) x(14) x(15) x(16) x(17) x(18) x(19) x(20)]');
t(1:2,:)=[] remove the two first lines;
y=min((t(:,2)+0.1)./(t(:,1)+0.1));
The only remaining error is: Error using ==> makeState at 55 Your fitness function must return a scalar value.
any suggestions will be helpfull.
Risposta accettata
Più risposte (3)
Abdelmoumen
il 3 Lug 2013
Modificato: Matt J
il 3 Lug 2013
0 voti
Abdelmoumen
il 6 Lug 2013
Modificato: Matt J
il 6 Lug 2013
0 voti
Abdelmoumen
il 9 Lug 2013
0 voti
Categorie
Scopri di più su Genetic Algorithm in Centro assistenza e File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!