Home > plotting > getObjectiveString.m

getObjectiveString

PURPOSE ^

getObjectiveString

SYNOPSIS ^

function objectiveString = getObjectiveString(max, objectiveNames, objectiveValues)

DESCRIPTION ^

 getObjectiveString
   Returns a string representing the objective function (e.g. 'MAX Growth
   - 0.5 HXT4').

   max                 true if the objective function should be maximized
   objectiveNames      cell array of reaction names
   objectiveValues     the corresponding coefficients for each reaction

   objectiveString     the calculated objective function

   Usage: objectiveString = getObjectiveString(max, objectiveNames,
           objectiveValues)

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function objectiveString = getObjectiveString(max, objectiveNames, objectiveValues)
0002 % getObjectiveString
0003 %   Returns a string representing the objective function (e.g. 'MAX Growth
0004 %   - 0.5 HXT4').
0005 %
0006 %   max                 true if the objective function should be maximized
0007 %   objectiveNames      cell array of reaction names
0008 %   objectiveValues     the corresponding coefficients for each reaction
0009 %
0010 %   objectiveString     the calculated objective function
0011 %
0012 %   Usage: objectiveString = getObjectiveString(max, objectiveNames,
0013 %           objectiveValues)
0014 
0015 objectiveString='';
0016 
0017 if max==true
0018     objectiveString=[objectiveString 'MAX: '];
0019 else
0020     objectiveString=[objectiveString 'MIN: '];
0021 end
0022 
0023 %Loops through the reactions
0024 for i=1:length(objectiveNames)
0025     %Add no sign if it's the first reaction
0026     if i>1
0027         if objectiveValues(i)==1
0028             objectiveString=[objectiveString ' + ' objectiveNames{i}];
0029             continue;
0030         end
0031         if objectiveValues(i)==-1
0032             objectiveString=[objectiveString ' - ' objectiveNames{i}];
0033             continue;
0034         end
0035         if objectiveValues(i)>=0
0036             objectiveString=[objectiveString ' + ' num2str(objectiveValues(i)) ' ' objectiveNames{i}];
0037         else
0038             objectiveString=[objectiveString ' - ' num2str(abs(objectiveValues(i))) ' ' objectiveNames{i}];
0039         end
0040     else
0041         if objectiveValues(i)==1
0042             objectiveString=[objectiveString objectiveNames{i}];
0043             continue;
0044         end
0045         if objectiveValues(i)==-1
0046             objectiveString=[objectiveString '- ' objectiveNames{i}];
0047             continue;
0048         end
0049         if objectiveValues(i)>=0
0050             objectiveString=[objectiveString num2str(objectiveValues(i)) ' ' objectiveNames{i}];
0051         else
0052             objectiveString=[objectiveString '- ' num2str(abs(objectiveValues(i))) ' ' objectiveNames{i}];
0053         end
0054     end
0055 end
0056 end

Generated by m2html © 2005