ANN for constraint optimization problem
2 vues (au cours des 30 derniers jours)
Afficher commentaires plus anciens
hello,
How do i modify my ANN algorithm, by incorporating some constraints to perfom my obtained result. the matlab code used is generated from Neural Network Toolbox.
function [Y,Xf,Af] = ANN_Function(X)
% ===== NEURAL NETWORK CONSTANTS =====
% Input 1
x1_step1_xoffset = [-0.964339227389144;-0.906927494859787;-0.9643288955237];
x1_step1_gain = [1.03826501814344;1.06861700687107;1.27340625419393];
x1_step1_ymin = -1;
% Layer 1
b1 = [-1.3371193654695128217;-3.7243723447930885406;0.59020209217794505907;-0.26942 281438778381553;-0.084790990077469749475;-0.287833517416886564;-0.6199588700217847359;0.87036361559242081398;1.1136596091577191103;3.5728692098803582766];
IW1_1 = [0.62172489473929637427 -1.1539538428995010921 0.40749280432490736503;0.33504097052172682192 2.2754223181903578954 -2.0670552187061321803;-0.97421719994837163714 0.16930737512492399777 0.95638889040809083042;3.453458645614659428 2.4120651149524281465 3.9342055592145062093;2.9998512477370034013 2.2723487424133810286 3.3571622229587347874;-1.6838243946405258011 -2.3995748128279066336 0.36244936598086713309;-3.1423700210823852785 1.3845185332230820485 2.4609517018642876884;-0.39703700607817143942 2.4912130193995269956 -0.16941481846512243536;1.406655675671569572 0.92534256006865256428 0.64325984129225455277;1.5085377777493140794 1.4551527878904193525 -1.3090133612083598713];
% Layer 2
b2 = [-0.28647967632293369622;-0.77689684809120063136;0.23567045137827014045;-0.50614562961496167848;0.17775471570313430836;0.39409286123122444501;-0.23743319675300361693];
LW2_1 = [-1.2595809845665446591 0.52253536564831837286 1.6575450213582203496 1.4444644615739332671 -0.79927746466752380705 -0.49440949393277561219 -1.0291039534117272236 -0.10205229528755178914 -1.783179386992490123 0.012007511957539542674;-1.8160587258194498261 0.16525212307258660416 -0.35634974797682900105 0.61911944611294977836 -0.55104180525241264199 0.36270218166368617396 0.70227078264624087645 -0.69192422904692441055 0.63741286998972901401 0.078380036138073788665;-0.39987089599785630156 0.0015263660888982231219 -0.32703999255710186622 -1.0870691355791675115 0.68183572942635206626 0.20086063975571505358 0.53707692508704663048 -0.043958739282595582498 0.30170293659756891591 -0.40387165805595148793;-0.42538078713443683299 -0.41243046298959784579 0.09360967585146644232 -0.54902810742656438237 0.27858672713463300541 0.13466521369669071095 -0.31684402239022979586 -0.016110146899087046668 0.18209067234932024837 -0.38144681930811946691;0.78489623544097297803 0.064197561813166229006 -0.14703146723552590336 0.045763727795912277629 -0.044493781097574965078 0.023102496123388799321 0.19498160438730580135 0.42399577006788119471 0.068627392557574939946 0.2774573470874529546;0.28300904777281810087 -0.040045961378933660202 -0.048322484065649526364 0.23633721304470370339 -0.28761021912207535012 0.22386822762508534757 -0.095795332741767574847 0.31901549272383256106 0.17453188621906071121 -0.40095786179528114523;0.2537157491011907684 -0.037837226082635302959 -0.044856312727524147443 0.24018253583883578117 -0.28974054247799801987 0.23561178051146219881 -0.095989508380685484301 0.30576014862164185848 0.18195538033206490325 0.22157365239611195862];
% Output 1
y1_step1_ymin = -1;
y1_step1_gain = [1.21212121212121;1.53846153846154;0.8;3.33333333333333;1.66666666666667;2;2];
y1_step1_xoffset = [-0.785398163397448;-0.523598775598299;-0.261799387799149;-0.174532925199433;-0.349065850398866;-0.523598775598299;-0.523598775598299];
% ===== SIMULATION ========
% Format Input Arguments
isCellX = iscell(X);
if ~isCellX, X = {X}; end;
% Dimensions
TS = size(X,2); % timesteps
if ~isempty(X)
Q = size(X{1},1); % samples/series
else
Q = 0;
end
% Allocate Outputs
Y = cell(1,TS);
% Time loop
for ts=1:TS
% Input 1
X{1,ts} = X{1,ts}';
Xp1 =
mapminmax_apply(X{1,ts},x1_step1_gain,x1_step1_xoffset,x1_step1_ymin);
% Layer 1
a1 = tansig_apply(repmat(b1,1,Q) + IW1_1*Xp1);
% Layer 2
a2 = repmat(b2,1,Q) + LW2_1*a1;
% Output 1
Y{1,ts} =
mapminmax_reverse(a2,y1_step1_gain,y1_step1_xoffset,y1_step1_ymin);
Y{1,ts} = Y{1,ts}';
end
% Final Delay States Xf = cell(1,0); Af = cell(2,0);
% Format Output Arguments if ~isCellX, Y = cell2mat(Y); end end
% ===== MODULE FUNCTIONS ========
% Map Minimum and Maximum Input Processing Function function y = mapminmax_apply(x,settings_gain,settings_xoffset,settings_ymin) y = bsxfun(@minus,x,settings_xoffset); y = bsxfun(@times,y,settings_gain); y = bsxfun(@plus,y,settings_ymin); end
% Sigmoid Symmetric Transfer Function function a = tansig_apply(n) a = 2 ./ (1 + exp(-2*n)) - 1; end
% Map Minimum and Maximum Output Reverse-Processing Function function x = mapminmax_reverse(y,settings_gain,settings_xoffset,settings_ymin) x = bsxfun(@minus,y,settings_ymin); x = bsxfun(@rdivide,x,settings_gain); x = bsxfun(@plus,x,settings_xoffset); end
2 commentaires
Réponses (0)
Voir également
Catégories
En savoir plus sur Genomics and Next Generation Sequencing dans Help Center et File Exchange
Community Treasure Hunt
Find the treasures in MATLAB Central and discover how the community can help you!
Start Hunting!