Home > RAVEN > 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)

   Rasmus Agren, 2010-12-16

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 %   Rasmus Agren, 2010-12-16
0016 %
0017 
0018 objectiveString='';
0019 
0020 if max==true
0021    objectiveString=[objectiveString 'MAX: ']; 
0022 else
0023    objectiveString=[objectiveString 'MIN: '];    
0024 end
0025 
0026 %Loops through the reactions
0027 for i=1:length(objectiveNames)
0028    %Add no sign if it's the first reaction
0029    if i>1
0030        if objectiveValues(i)==1
0031             objectiveString=[objectiveString ' + ' objectiveNames{i}]; 
0032             continue;
0033        end
0034        if objectiveValues(i)==-1
0035             objectiveString=[objectiveString ' - ' objectiveNames{i}]; 
0036             continue;
0037        end
0038        if objectiveValues(i)>=0
0039            objectiveString=[objectiveString ' + ' num2str(objectiveValues(i)) ' ' objectiveNames{i}];
0040        else
0041            objectiveString=[objectiveString ' - ' num2str(abs(objectiveValues(i))) ' ' objectiveNames{i}];
0042        end
0043    else
0044        if objectiveValues(i)==1
0045             objectiveString=[objectiveString objectiveNames{i}]; 
0046             continue;
0047        end
0048        if objectiveValues(i)==-1
0049             objectiveString=[objectiveString '- ' objectiveNames{i}]; 
0050             continue;
0051        end
0052        if objectiveValues(i)>=0
0053            objectiveString=[objectiveString num2str(objectiveValues(i)) ' ' objectiveNames{i}];
0054        else
0055            objectiveString=[objectiveString '- ' num2str(abs(objectiveValues(i))) ' ' objectiveNames{i}];
0056        end
0057    end
0058 end

Generated on Mon 06-Jan-2014 14:58:12 by m2html © 2005