Beispiel #1
0
 def evaluate(self, thorough=True):
     """
     Evaluate metric over the argument sample space and save values to ``table``.
     
     Parameters
     ----------
     thorough : bool
         If True, simulate the whole system with each sample.
         If False, simulate only the affected parts of the system.
     
     """
     speed_up()
     samples = self._samples
     if samples is None: raise RuntimeError('must load samples before evaluating')
     evaluate_sample = self._evaluate_sample_thorough if thorough else self._evaluate_sample_smart
     self._table[self._metric_indices] = [evaluate_sample(samples[i]) for i in self._index]
Beispiel #2
0
 def evaluate(self, thorough=True):
     """Evaluate metric over the argument sample space and save values to ``table``.
     
     Parameters
     ----------
     thorough : bool
         If True, simulate the whole system with each sample.
         If False, simulate only the affected parts of the system.
     
     """
     speed_up()
     # Setup before simulation
     funcs = [i.getter for i in self._metrics]
     samples = self._samples
     if samples is None:
         raise ValueError(
             'must load samples or distribution before evaluating')
     index = self._index
     values = np.zeros([len(index), len(funcs)])
     zip_ = zip
     if thorough:
         if self._setters:
             setters = self._setters
         else:
             self._setters = setters = [p.setter for p in self._params]
         simulate = self._system.simulate
         for i in index:
             for f, s in zip_(setters, samples[i]):
                 f(s)
             simulate()
             values[i] = [i() for i in funcs]
     else:
         update = self._update
         for i in index:
             update(samples[i])
             values[i] = [i() for i in funcs]
     self.table[var_indices(self._metrics)] = values
Beispiel #3
0
    def evaluate(self, thorough=True, jit=True, notify=False):
        """
        Evaluate metric over the argument sample space and save values to `table`.
        
        Parameters
        ----------
        thorough : bool
            If True, simulate the whole system with each sample.
            If False, simulate only the affected parts of the system.
        jit : bool
            Whether to JIT compile functions with Numba to speed up simulation.
        notify=False : bool, optional
            If True, notify elapsed time after each sample evaluation. 
        
        """
        if jit: speed_up()
        samples = self._samples
        if samples is None:
            raise RuntimeError('must load samples before evaluating')
        evaluate_sample = self._evaluate_sample_thorough if thorough else self._evaluate_sample_smart
        table = self.table
        if notify:
            from biosteam.utils import TicToc
            timer = TicToc()
            timer.tic()

            def evaluate(sample, count=[0]):
                count[0] += 1
                values = evaluate_sample(sample)
                print(f"{count} Elapsed time: {timer.elapsed_time:.0f} sec")
                return values
        else:
            evaluate = evaluate_sample
        table[self._metric_indices] = [
            evaluate(samples[i]) for i in self._index
        ]
def update_productivity(productivity):
    R301.productivity = productivity
    R302.productivity = productivity * R302.ferm_ratio
    for unit in (R301, R302):
        unit._design()
        unit._cost()
    solve_TEA()


# %%

# =============================================================================
# Regular strain
# =============================================================================

bst.speed_up()
R301.set_titer_limit = True
R301.neutralization = True
R401.bypass = False
S402.bypass = False

run_number = 0
MPSPs_regular = [[], [], []]
NPVs_regular = [[], [], []]

print('\n-------- Regular Strain --------')
for i in titer_range:
    for j in yield_range:
        limits[0].append(i)
        limits[1].append(j)
        # Baseline productivity