Team:Groningen/Modelling/Characterization

From 2009.igem.org

(Difference between revisions)
(Some tweaks to simulated annealing.)
(Some more tweaks to simulated annealing.)
Line 60: Line 60:
!best
!best
!cur
!cur
 +
!gradient
!solved
!solved
 +
|-
 +
|v5K5
 +
|id="v5K5"|
 +
|id="v5K5cur"|
 +
|id="v5K5curgradient"|
 +
|id="v5K5sol"|
|-
|-
|v5
|v5
|id="v5"|
|id="v5"|
|id="v5cur"|
|id="v5cur"|
 +
|id="v5curgradient"|
|id="v5sol"|
|id="v5sol"|
|-
|-
Line 70: Line 78:
|id="K5"|
|id="K5"|
|id="K5cur"|
|id="K5cur"|
 +
|id="K5curgradient"|
|id="K5sol"|
|id="K5sol"|
|-
|-
Line 87: Line 96:
                     time:[60,600,1200,2400,3600]}];
                     time:[60,600,1200,2400,3600]}];
-
function computeCost(c,e) {
+
var varsToMutate = ['v5K5','K5'];
 +
var mutateFuncs = {v5: function(v){return v.v5K5*v.K5;},
 +
                  K5: function(v){return v.K5;}};
 +
 
 +
function computeCost(v,e) {
 +
  // Compute constants
 +
  var c = arsenicModelConstants();
 +
  for(var a in mutateFuncs) c[a] = mutateFuncs[a](v);
 +
 
 +
  // Go through all experiments
   var cost = 0, n = 0, x0, xt, times;
   var cost = 0, n = 0, x0, xt, times;
   for(var i in e) {
   for(var i in e) {
 +
    // Set up constants for this experiment
     var nc = {};
     var nc = {};
     for(var a in c) nc[a] = c[a];
     for(var a in c) nc[a] = c[a];
     for(var a in e[i].constants) nc[a] = e[i].constants[a];
     for(var a in e[i].constants) nc[a] = e[i].constants[a];
 +
 +
    // Simulate
     x0 = arsenicModelInitialization(nc,e[i].AsT);
     x0 = arsenicModelInitialization(nc,e[i].AsT);
     xt = simulate(x0,e[i].time,function(t,d){return arsenicModelGradient(nc,d);});
     xt = simulate(x0,e[i].time,function(t,d){return arsenicModelGradient(nc,d);});
 +
 +
    // Sum (squares of) errors
     for(var j in xt.timeKey) {
     for(var j in xt.timeKey) {
       cost += Math.pow(e[i].AsinT[j]-xt.AsinT[xt.timeKey[j]],2);
       cost += Math.pow(e[i].AsinT[j]-xt.AsinT[xt.timeKey[j]],2);
Line 100: Line 123:
     }
     }
   }
   }
-
   return Math.sqrt(cost/n);
+
   return Math.sqrt(cost/n); // Compute the square root of the average of the squares (RMS)
}
}
-
var varsToMutate = ['v5','K5'];
+
function mutate(c,dc) {
-
var mutateDeps = {v5: ['K5']};
+
-
function mutate(c) {
+
   var vn = varsToMutate[Math.floor(Math.random()*varsToMutate.length)];
   var vn = varsToMutate[Math.floor(Math.random()*varsToMutate.length)];
   var nc = {};
   var nc = {};
Line 112: Line 133:
   // Mutate
   // Mutate
   var factor = 2-Math.exp(-Math.random());
   var factor = 2-Math.exp(-Math.random());
-
   if (Math.random()<0.5) {
+
   if (Math.random()<0.5+Math.atan(dc[vn])/Math.PI) {
-
     factor = 1 /(2-Math.exp(-Math.random()));
+
     factor = 1 / factor;
   }
   }
   nc[vn] *= factor;
   nc[vn] *= factor;
-
  for(var i in mutateDeps[vn]) nc[mutateDeps[vn][i]] *= factor;
 
   return nc;
   return nc;
 +
}
 +
 +
function showOutputs(mode,E,c,dc) {
 +
  setOutput('v5K5'+mode,mutateFuncs.v5(c)/mutateFuncs.K5(c));
 +
  setOutput('v5'+mode,mutateFuncs.v5(c));
 +
  setOutput('K5'+mode,mutateFuncs.K5(c));
 +
  setOutput('E'+mode,computeCost(c,experiments));
 +
  if (dc!=undefined) {
 +
    setOutput('v5K5'+mode+'gradient',dc.v5K5);
 +
    setOutput('v5'+mode+'gradient',dc.v5K5*c.K5-dc.K5*c.v5K5);
 +
    setOutput('K5'+mode+'gradient',dc.K5);
 +
  }
}
}
function fitConstants() {
function fitConstants() {
-
   var c = arsenicModelConstants();
+
  // Show mathematica solution
-
   setOutput('v5sol',c.v5);
+
   var orgC = arsenicModelConstants();
-
  setOutput('K5sol',c.K5);
+
   var cSol = {v5K5: orgC.v5/orgC.K5, K5: orgC.K5};
-
   setOutput('Esol',computeCost(c,experiments));
+
   showOutputs('sol',computeCost(,experiments),c);
-
   c.v5 = 1e-3;
+
 
-
   c.K5 = 1e-3;
+
   // Initialize
 +
  var c = {v5K5: 1, K5: 1};
 +
   var dc = {};
 +
  for(var a in c) dc[a] = 0;
   var E = computeCost(c,experiments);
   var E = computeCost(c,experiments);
   var cBest = c, EBest = E;
   var cBest = c, EBest = E;
 +
 +
  // Set up iteration
   var numiter = 10000;
   var numiter = 10000;
   var iter = 0;
   var iter = 0;
Line 138: Line 175:
     }
     }
     setOutput('iter',iter);
     setOutput('iter',iter);
-
     var cNew = mutate(c);
+
 
 +
    // Mutate and compute new energy and gradient
 +
     var cNew = mutate(c,dc);
     var ENew = computeCost(cNew,experiments);
     var ENew = computeCost(cNew,experiments);
 +
    for(var a in cNew) {
 +
      var dca = (ENew-E)/(cNew[a]-c[a]);
 +
      if (!(isNaN(dca) || !isFinite(dca))) dc[a] = (dc[a]+2*dca)/3;
 +
    }
 +
 +
    // If better than best, accept
     if (ENew < EBest) {
     if (ENew < EBest) {
       cBest = cNew;
       cBest = cNew;
       EBest = ENew;
       EBest = ENew;
-
       setOutput('v5',cBest.v5);
+
       showOutputs('',EBest,cBest);
-
      setOutput('K5',cBest.K5);
+
-
      setOutput('E',EBest);
+
     }
     }
 +
 +
    // Compute (decaying) "temperature" and accept new solution as current if it's not "too" bad
     var T = 1 - (iter/numiter);
     var T = 1 - (iter/numiter);
-
     if (ENew<E || Math.exp((E-ENew)/T)>=Math.random()) {
+
     if (ENew<E || Math.exp((E-ENew)/(1e-3*T))>=Math.random()) {
       c = cNew;
       c = cNew;
       E = ENew;
       E = ENew;
-
       setOutput('v5cur',c.v5);
+
       showOutputs('cur',E,c,dc);
-
      setOutput('K5cur',c.K5);
+
-
      setOutput('Ecur',E);
+
     }
     }
   },1);
   },1);

Revision as of 09:12, 30 September 2009

[http://2009.igem.org/Team:Groningen http://2009.igem.org/wiki/images/f/f1/Igemhomelogo.png]


TODO: Talk about the devices we have and in what way we want to characterize them.

Uptake measurements

Sampling scheme
Time (min)
0 10 20 40 60
As(III)exT(0)
(µM)
0 x
10 x x x x x
20 x
50 x
100 x

To efficiently look at both time and concentration dependent processes we took samples as in the table on the right. Below we list all results, which have been used for fitting all necessary parameters.

TODO: List results. Take conversion from nmol/mg and mg/ml to µM and Vc/Vs into account.

best cur gradient solved
v5K5
v5
K5
E