-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Pass x0, bounds and n_parameters into Cost (#101)
* Unpack x0, bounds and n_parameters into Cost * Pass x0, bounds and n_parameters from Cost * Remove n_parameters function check * Allow problem=None in BaseCost * Add StandaloneCost * Add test of StandaloneCosts
- Loading branch information
1 parent
790bb47
commit f67c810
Showing
5 changed files
with
42 additions
and
13 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,18 @@ | ||
import pybop | ||
import numpy as np | ||
|
||
|
||
class StandaloneCost(pybop.BaseCost): | ||
def __init__(self, problem=None): | ||
super().__init__(problem) | ||
|
||
self.x0 = np.array([4.2]) | ||
self.n_parameters = len(self.x0) | ||
|
||
self.bounds = dict( | ||
lower=[-1], | ||
upper=[10], | ||
) | ||
|
||
def __call__(self, x, grad=None): | ||
return x[0] ** 2 + 42 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters