pypharm 1.3.1__tar.gz → 1.3.2__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- {pypharm-1.3.1 → pypharm-1.3.2}/PKG-INFO +1 -1
- {pypharm-1.3.1 → pypharm-1.3.2}/PyPharm/models.py +26 -19
- {pypharm-1.3.1 → pypharm-1.3.2}/pypharm.egg-info/PKG-INFO +1 -1
- {pypharm-1.3.1 → pypharm-1.3.2}/setup.py +1 -1
- {pypharm-1.3.1 → pypharm-1.3.2}/PyPharm/__init__.py +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/PyPharm/country_optimization.py +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/PyPharm/country_optimization_v2.py +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/README.md +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/pypharm.egg-info/SOURCES.txt +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/pypharm.egg-info/dependency_links.txt +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/pypharm.egg-info/requires.txt +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/pypharm.egg-info/top_level.txt +0 -0
- {pypharm-1.3.1 → pypharm-1.3.2}/setup.cfg +0 -0
|
@@ -323,7 +323,7 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
|
|
|
323
323
|
|
|
324
324
|
need_v_release_optimization = False
|
|
325
325
|
release_parameters_target = None
|
|
326
|
-
|
|
326
|
+
accumulation_parameters_target = None
|
|
327
327
|
|
|
328
328
|
class ReleaseRK45(RK45):
|
|
329
329
|
|
|
@@ -496,6 +496,15 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
|
|
|
496
496
|
accumulation_type=self.accumulation_type,
|
|
497
497
|
c0=c0
|
|
498
498
|
)
|
|
499
|
+
self.last_result.model_realized = c0 - self.get_release_function()(self.last_result.t, c0)
|
|
500
|
+
if self.with_accumulate:
|
|
501
|
+
model_accumulation = self.get_accumulation_function()(self.last_result.t, c0)
|
|
502
|
+
if self.accumulation_type == 1:
|
|
503
|
+
self.last_result.model_realized = model_accumulation - self.get_release_function()(self.last_result.t, c0)
|
|
504
|
+
elif self.accumulation_type == 2:
|
|
505
|
+
accumulation_coeffs = model_accumulation / c0
|
|
506
|
+
self.last_result.model_realized= accumulation_coeffs * self.get_release_function()(self.last_result.t, c0)
|
|
507
|
+
self.last_result.model_realized = model_accumulation - self.last_result.model_realized
|
|
499
508
|
return self.last_result
|
|
500
509
|
|
|
501
510
|
def _target_function(self, x, max_step=0.01, metric='R2'):
|
|
@@ -523,29 +532,13 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
|
|
|
523
532
|
if metric == 'R2':
|
|
524
533
|
plus = 0
|
|
525
534
|
if self.teoretic_realized is not None:
|
|
526
|
-
model_realized =
|
|
527
|
-
if self.with_accumulate:
|
|
528
|
-
model_accumulation = self.get_accumulation_function()(self.teoretic_x, c0)
|
|
529
|
-
if self.accumulation_type == 1:
|
|
530
|
-
model_realized = model_accumulation - self.get_release_function()(self.teoretic_x, c0)
|
|
531
|
-
elif self.accumulation_type == 2:
|
|
532
|
-
accumulation_coeffs = model_accumulation / c0
|
|
533
|
-
model_realized = accumulation_coeffs * self.get_release_function()(self.teoretic_x, c0)
|
|
534
|
-
model_realized = model_accumulation - model_realized
|
|
535
|
+
model_realized = self.last_result.model_realized
|
|
535
536
|
plus = np.sum(((model_realized - self.teoretic_realized) ** 2) / ((self.teoretic_realized - self.teoretic_realized_avg) ** 2))
|
|
536
537
|
return plus + np.sum(np.sum(self.w * ((target_results - self.teoretic_y) ** 2), axis=1) / np.sum((self.teoretic_avg - self.teoretic_y) ** 2, axis=1))
|
|
537
538
|
elif metric == 'norm':
|
|
538
539
|
plus = 0
|
|
539
540
|
if self.teoretic_realized is not None:
|
|
540
|
-
model_realized =
|
|
541
|
-
if self.with_accumulate:
|
|
542
|
-
model_accumulation = self.get_accumulation_function()(self.teoretic_x, c0)
|
|
543
|
-
if self.accumulation_type == 1:
|
|
544
|
-
model_realized = model_accumulation - self.get_release_function()(self.teoretic_x, c0)
|
|
545
|
-
elif self.accumulation_type == 2:
|
|
546
|
-
accumulation_coeffs = model_accumulation / c0
|
|
547
|
-
model_realized = accumulation_coeffs * self.get_release_function()(self.teoretic_x, c0)
|
|
548
|
-
model_realized = model_accumulation - model_realized
|
|
541
|
+
model_realized = self.last_result.model_realized
|
|
549
542
|
plus = np.linalg.norm(self.teoretic_realized - model_realized)
|
|
550
543
|
return plus + np.linalg.norm(target_results - self.teoretic_y)
|
|
551
544
|
else:
|
|
@@ -597,3 +590,17 @@ class ReleaseCompartmentModel(BaseCompartmentModel):
|
|
|
597
590
|
s += self.release_parameters_target_count + int(self.need_v_release_optimization)
|
|
598
591
|
self.accumulation_parameters[self.accumulation_parameters_target] = x[s:s + self.accumulation_parameters_target_count]
|
|
599
592
|
return x
|
|
593
|
+
|
|
594
|
+
def plot_model(self, compartment_numbers=None, compartment_names={},
|
|
595
|
+
left=None, right=None, y_lims={}, plot_accumulation=False, **kwargs):
|
|
596
|
+
super().plot_model(compartment_numbers, compartment_names, left, right, y_lims, **kwargs)
|
|
597
|
+
if plot_accumulation:
|
|
598
|
+
if hasattr(self, "teoretic_x") and hasattr(self, "teoretic_realized"):
|
|
599
|
+
plt.plot(self.teoretic_x, self.teoretic_realized, "*r")
|
|
600
|
+
plt.plot(self.last_result.t, self.last_result.model_realized)
|
|
601
|
+
plt.title(compartment_names.get('realized', 'realized'))
|
|
602
|
+
plt.xlim(left=left, right=right)
|
|
603
|
+
if y_lims.get('realized'):
|
|
604
|
+
plt.ylim(y_lims.get('realized'))
|
|
605
|
+
plt.grid()
|
|
606
|
+
plt.show()
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|
|
File without changes
|