fitC13Data

PURPOSE ^

v0 is input v. It will automatically be converted to alpha by solving N*alpha = v;

SYNOPSIS ^

function [vout, rout] = fitC13Data(v0,expdata,model, majorIterationLimit)

DESCRIPTION ^

 v0 is input v.  It will automatically be converted to alpha by solving N*alpha = v;
 if v0 is a matrix then it is assumed to be a multiple start situation and
 vout will also have this size.

 expdata is either a data structure or a cell array of structures, in
 which case it is assumed that you wan to fit the sum of the scores.
 model - standard model structure
 majorIterationLimit (optional) - max number of iterations solver is allowed to take.
  Default = 1000;

CROSS-REFERENCE INFORMATION ^

This function calls: This function is called by:

SOURCE CODE ^

0001 function [vout, rout] = fitC13Data(v0,expdata,model, majorIterationLimit)
0002 % v0 is input v.  It will automatically be converted to alpha by solving N*alpha = v;
0003 % if v0 is a matrix then it is assumed to be a multiple start situation and
0004 % vout will also have this size.
0005 %
0006 % expdata is either a data structure or a cell array of structures, in
0007 % which case it is assumed that you wan to fit the sum of the scores.
0008 % model - standard model structure
0009 % majorIterationLimit (optional) - max number of iterations solver is allowed to take.
0010 %  Default = 1000;
0011 
0012 if nargin < 4
0013     majorIterationLimit = 1000;
0014 end
0015 diffInterval = 1e-5;         %gradient step size.
0016 method = 1; % 2 = in terms of v.  % 1 in terms of alpha
0017 printLevel = 3; %3 prints every iteration.  1 does a summary.  0 = silent.
0018 
0019 if method == 1
0020     if ~isfield(model, 'N')
0021        model.N = null(model.S); 
0022        display('model.N should be defined');
0023        pause;
0024     end
0025 
0026     x0 = model.N\v0; % back substitute
0027 
0028     % safety check:
0029     if (max(abs(model.S*v0))> 1e-6)
0030         display('v0 not quite in null space');
0031         pause;
0032     end
0033     if(max(abs(model.N*x0 - v0)) > 1e-6)
0034         max(abs(model.N*x0 - v0))
0035         display('null basis is weird');
0036         pause;
0037     end
0038 
0039     % set up problem
0040     nalpha = size(model.N, 2);
0041     x_L = -1000*ones(nalpha,1);
0042     x_U = 1000*ones(nalpha,1);
0043     [A, b_L, b_U] = defineLinearConstraints(model, method);
0044 elseif method == 2
0045     x0 = v0; % back substitute
0046     [A, x_L, x_U] = defineLinearConstraints(model, method);
0047     b_L = zeros(size(A,1),1);
0048     b_U = zeros(size(A,1),1);
0049 else
0050     display('error'); pause;
0051 end
0052  
0053 numpoints = size(x0,2);
0054 vout = zeros(size(v0));
0055 rout = cell(numpoints, 1);
0056 
0057 for k = 1:numpoints
0058     x_0 = x0(:,k);
0059     NLPproblem.objFunction = 'errorComputation2';
0060     NLPproblem.gradFunction = 'errorComputation2_grad';
0061     NLPproblem.lb = x_L;
0062     NLPproblem.ub = x_U;
0063     NLPproblem.name = 'c13fitting';
0064     NLPproblem.x0 = x_0;
0065     NLPproblem.A = A;
0066     NLPproblem.b_L = b_L;
0067     NLPproblem.b_U = b_U;
0068     NLPproblem.userParams.expdata = expdata;
0069     NLPproblem.userParams.model = model;
0070     NLPproblem.userParams.useparfor = true;
0071     NLPproblem.userParams.diff_interval = diffInterval;
0072     
0073     NLPproblem.PriLevOpt = 1;
0074     cnan = ( method == 2);
0075 
0076     NLPsolution = solveCobraNLP(NLPproblem, 'checkNaN', cnan, 'printLevel', printLevel, 'iterationLimit', majorIterationLimit, 'logFile', 'minimize_SNOPT.txt');
0077     
0078     if exist('ttt.txt', 'file')
0079        fprintf('quitting due to file found\n');
0080        continue;
0081     end
0082     if method == 1
0083         vout(:,k) = model.N*NLPsolution.full;        
0084     else
0085         vout(:,k) = NLPsolution.full;
0086     end
0087     rout{k} = NLPsolution;
0088 end
0089 return
0090

Generated on Thu 21-Jun-2012 15:39:23 by m2html © 2003