API Reference
ParameterBank
A collection of parameters with sampling, constraints, and conversions.
The bank stores independent and derived parameters, optional constraint
functions, and a canonical parameter order. It can sample full parameter
instances, validate them against constraints, and convert between rich
ParameterSet and array/dataframe representations.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
dict[str, IndependentScalarParameter | IndependentVectorParameter | DerivedScalarParameter] | None
|
Dictionary mapping parameter names to parameter instances. |
None
|
constraints
|
list[Callable[[ParameterSet], bool]] | None
|
List of constraint functions that take a ParameterSet and return a boolean. |
None
|
array_mode
|
bool
|
If True, sampling and conversions use only sampled parameters and return plain arrays; otherwise use all parameters and return ParameterSet objects. |
False
|
texnames
|
dict[str, str] | None
|
Optional dictionary mapping parameter names to TeX-formatted display names. |
None
|
max_attempts
|
int
|
Maximum number of attempts when sampling with constraints before raising an error. Defaults to 100. |
100
|
Source code in jscip/parameter_bank.py
26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 | |
names: list[str]
property
Get the names of all parameters in the bank. This also defines the canonical order of the parameters.
sampled: list[str]
property
Get a list of all parameters that are set to be sampled.
vector_names: list[str]
property
Get a list of all vector parameter names.
lower_bounds: np.ndarray
property
Get the lower bounds of all sampled parameters.
For scalar parameters, returns the scalar lower bound. For vector parameters, returns the lower bound array or scalar if uniform.
upper_bounds: np.ndarray
property
Get the upper bounds of all sampled parameters.
For scalar parameters, returns the scalar upper bound. For vector parameters, returns the upper bound array or scalar if uniform.
sampled_texnames: list[str]
property
Get the TeX names of all sampled parameters.
__contains__(key: str) -> bool
Check if a parameter exists in the bank.
Source code in jscip/parameter_bank.py
182 183 184 | |
__len__() -> int
Get the number of parameters in the bank.
Source code in jscip/parameter_bank.py
186 187 188 | |
__iter__() -> Iterator[str]
Iterate over the parameter names in the bank.
Source code in jscip/parameter_bank.py
190 191 192 | |
__getitem__(key: str) -> IndependentScalarParameter | IndependentVectorParameter | DerivedScalarParameter
Get a parameter by its name.
Source code in jscip/parameter_bank.py
194 195 196 197 198 199 200 201 | |
copy() -> ParameterBank
Create a copy of the ParameterBank.
Source code in jscip/parameter_bank.py
203 204 205 206 207 208 209 210 211 212 213 | |
merge(other: ParameterBank) -> None
Merge another ParameterBank into this one. If a parameter with the same name exists, it will be overwritten.
Source code in jscip/parameter_bank.py
227 228 229 230 231 232 233 234 235 236 237 | |
add_parameter(name: str, parameter: IndependentScalarParameter | IndependentVectorParameter | DerivedScalarParameter | DerivedVectorParameter) -> None
Add a new parameter to the bank.
Source code in jscip/parameter_bank.py
239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 | |
add_constraint(constraint: Callable[[ParameterSet], bool]) -> None
Add a new constraint to the bank.
Source code in jscip/parameter_bank.py
268 269 270 271 272 273 | |
get_constraints() -> list[Callable[[ParameterSet], bool]]
Get all constraints in the bank.
Source code in jscip/parameter_bank.py
275 276 277 | |
get_default_values(return_array: bool | None = None) -> ParameterSet | np.ndarray
Return default values for all parameters.
Computes a ParameterSet by taking the current value for all
independent parameters and computing all derived parameters from those
values. Optionally, returns the sampled subset as a NumPy array when
return_array=True.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
return_array
|
bool | None
|
If True, return a 1D NumPy array of sampled parameter
values in canonical sampled order. If False, return a full
|
None
|
Returns:
| Type | Description |
|---|---|
ParameterSet | ndarray
|
ParameterSet | numpy.ndarray: The default instance or the sampled |
ParameterSet | ndarray
|
values array. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameter_bank.py
279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 | |
instance_to_array(input: ParameterSet | list[ParameterSet]) -> np.ndarray
Convert a parameter instance (or list) to a sampled parameter array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
ParameterSet | list[ParameterSet]
|
A single |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 1D array for a single instance or 2D array for a |
ndarray
|
list of instances, containing values for sampled parameters only, |
ndarray
|
in canonical sampled order. Vector parameters are flattened into |
ndarray
|
the array. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameter_bank.py
331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 | |
dataframe_to_array(df: pd.DataFrame) -> np.ndarray
Extract sampled parameter columns from a DataFrame as a NumPy array.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
df
|
DataFrame
|
DataFrame containing sampled parameter columns. |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: 2D array of sampled values in canonical sampled |
ndarray
|
order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameter_bank.py
381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 | |
array_to_instance(theta: np.ndarray) -> ParameterSet
Convert a parameter array to a parameter instance.
When array_mode is True, theta must contain only sampled
independent parameters in canonical sampled order. Otherwise, it must
contain values for all independent parameters in canonical order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
theta
|
ndarray
|
1D NumPy array. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A full instance with derived parameters recomputed. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If shapes are inconsistent with |
Source code in jscip/parameter_bank.py
399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 | |
sample(size: int | tuple | None = None) -> ParameterSet | pd.DataFrame | np.ndarray
Sample parameter sets or theta arrays.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int | tuple | None
|
If |
None
|
Returns:
| Type | Description |
|---|---|
ParameterSet | DataFrame | ndarray
|
ParameterSet | pandas.DataFrame | numpy.ndarray: Depending on |
ParameterSet | DataFrame | ndarray
|
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameter_bank.py
513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 | |
instances_to_dataframe(instances: list[ParameterSet]) -> pd.DataFrame
Convert a list of parameter instances to a pandas DataFrame.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instances
|
list[ParameterSet]
|
A non-empty list of |
required |
Returns:
| Type | Description |
|---|---|
DataFrame
|
pandas.DataFrame: Rows correspond to instances; columns to |
DataFrame
|
parameters in canonical order. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the input is not a non-empty list of |
Source code in jscip/parameter_bank.py
586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 | |
log_prob(input: ParameterSet | pd.DataFrame | np.ndarray) -> float | np.ndarray
Compute log-probability for parameter instances.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
input
|
ParameterSet | DataFrame | ndarray
|
A |
required |
Returns:
| Type | Description |
|---|---|
float | ndarray
|
float | numpy.ndarray: A scalar for a single |
float | ndarray
|
NumPy array of log-probabilities for batches. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If the type/shape of |
Source code in jscip/parameter_bank.py
618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 | |
order(instance: ParameterSet) -> ParameterSet
Reindex an instance to the bank's canonical parameter order.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
instance
|
ParameterSet
|
The |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A new instance with parameters ordered canonically. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If reindexing fails (e.g., missing keys). |
Source code in jscip/parameter_bank.py
697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 | |
pretty_print() -> None
Print a human-readable summary of the bank configuration.
Source code in jscip/parameter_bank.py
717 718 719 720 721 722 723 724 725 726 | |
ParameterSet
A single parameter configuration with scalar and/or vector values.
This is a thin wrapper around pandas.Series used to represent a single
instance of parameters, typically produced by sampling a ParameterBank.
It can store both scalar values (from IndependentScalarParameter or
DerivedScalarParameter) and vector values (from IndependentVectorParameter
as numpy arrays). It preserves the canonical parameter ordering maintained
by the bank when reindexed via ParameterBank.order.
Source code in jscip/parameter_set.py
18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
satisfies(constraint: Callable[[ParameterSet], bool]) -> bool
Evaluate a boolean constraint on this instance.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
constraint
|
Callable[[ParameterSet], bool]
|
A callable |
required |
Returns:
| Name | Type | Description |
|---|---|---|
bool |
bool
|
True if the constraint is satisfied, otherwise False. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameter_set.py
35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 | |
copy() -> ParameterSet
Return a copy of this parameter set.
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A new instance with the same values. |
Note
Numpy arrays are deep copied to prevent unintended mutations.
Source code in jscip/parameter_set.py
55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 | |
reindex(new_index: Sequence[str]) -> ParameterSet
Reindex this instance to a new sequence of parameter names.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
new_index
|
Sequence[str]
|
Iterable of parameter names specifying the new order. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
ParameterSet |
ParameterSet
|
A new instance with the requested index. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameter_set.py
75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 | |
DerivedParameter
Base class for derived parameters (scalar or vector).
Derived parameters are computed from other parameters via a function. They are never sampled directly.
Attributes:
| Name | Type | Description |
|---|---|---|
function |
Callable that computes the derived value from a ParameterSet. |
|
is_sampled |
bool
|
Always False for derived parameters. |
Source code in jscip/parameters.py
57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 | |
is_sampled: bool
property
Get whether this parameter is sampled (always False).
compute(parameters)
Compute the derived value for a given parameter set.
Must be implemented by subclasses.
Source code in jscip/parameters.py
79 80 81 82 83 84 | |
copy()
Return a copy of this parameter.
Must be implemented by subclasses.
Source code in jscip/parameters.py
86 87 88 89 90 91 | |
DerivedScalarParameter
A read-only parameter computed from other parameters.
A DerivedScalarParameter wraps a function that maps a ParameterSet to a
scalar value. It is not sampled directly and is recomputed whenever an
instance is formed or updated.
Source code in jscip/parameters.py
227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 | |
compute(parameters: ParameterSet) -> float
Compute the derived scalar value for a given parameter set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
ParameterSet
|
A ParameterSet containing the independent parameters. |
required |
Returns:
| Name | Type | Description |
|---|---|---|
float |
float
|
The computed scalar value. |
Source code in jscip/parameters.py
242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 | |
copy() -> DerivedScalarParameter
Return a shallow copy preserving the underlying function.
Returns:
| Name | Type | Description |
|---|---|---|
DerivedScalarParameter |
DerivedScalarParameter
|
A new wrapper around the same function. |
Source code in jscip/parameters.py
259 260 261 262 263 264 265 266 267 | |
DerivedVectorParameter
A read-only vector parameter computed from other parameters.
A DerivedVectorParameter wraps a function that maps a ParameterSet to a
vector value. It is not sampled directly and is recomputed whenever an
instance is formed or updated.
Attributes:
| Name | Type | Description |
|---|---|---|
function |
Callable that computes the derived vector from a ParameterSet. |
|
output_shape |
tuple[int, ...]
|
Expected shape of the output vector (e.g., (3,) for 3D vector). |
is_sampled |
bool
|
Always False for derived parameters. |
Source code in jscip/parameters.py
270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 | |
output_shape: tuple[int, ...]
property
Get the expected output shape.
shape: tuple[int, ...]
property
Get the shape of the parameter (alias for output_shape).
__init__(function: Callable[[ParameterSet], np.ndarray], output_shape: tuple[int, ...]) -> None
Initialize a DerivedVectorParameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
function
|
Callable[[ParameterSet], ndarray]
|
Callable that takes a ParameterSet and returns a numpy array. |
required |
output_shape
|
tuple[int, ...]
|
Expected shape of the output (e.g., (3,) for 3D vector). |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If function is not callable or output_shape is invalid. |
Source code in jscip/parameters.py
283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 | |
compute(parameters: ParameterSet) -> np.ndarray
Compute the derived vector value for a given parameter set.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
parameters
|
ParameterSet
|
The |
required |
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: The computed vector value. |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in jscip/parameters.py
327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 | |
copy() -> DerivedVectorParameter
Return a shallow copy preserving the underlying function.
Returns:
| Name | Type | Description |
|---|---|---|
DerivedVectorParameter |
DerivedVectorParameter
|
A new wrapper around the same function. |
Source code in jscip/parameters.py
364 365 366 367 368 369 370 371 372 | |
IndependentParameter
Base class for independent parameters (scalar or vector).
Independent parameters can be sampled from distributions or held fixed. They are the primary inputs to a parameter space.
Attributes:
| Name | Type | Description |
|---|---|---|
is_sampled |
bool
|
Whether this parameter will be sampled from a distribution. |
Source code in jscip/parameters.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 | |
is_sampled: bool
property
Get whether this parameter is sampled.
sample(size: int | None = None)
Sample from the parameter's distribution.
Must be implemented by subclasses.
Source code in jscip/parameters.py
42 43 44 45 46 47 | |
copy()
Return a copy of this parameter.
Must be implemented by subclasses.
Source code in jscip/parameters.py
49 50 51 52 53 54 | |
IndependentScalarParameter
A real-valued parameter with optional uniform sampling over a range.
This class represents a scalar numeric parameter. When is_sampled=True, a
uniform distribution over range=(low, high) is constructed to draw
samples; otherwise the parameter is treated as fixed at value.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
float
|
Current scalar value of the parameter. |
is_sampled |
bool
|
Whether this parameter will be sampled from a distribution. |
range |
tuple[float, float] | None
|
Optional inclusive bounds |
Raises:
| Type | Description |
|---|---|
ValueError
|
If types are invalid, if the range is malformed, or if the value falls outside the provided range. |
Source code in jscip/parameters.py
94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 | |
value: float
property
writable
Get the value of the parameter.
range: tuple[float, float] | None
property
writable
Get the range of the parameter.
sample(size: int | None = None) -> float
Sample from the parameter's distribution.
If is_sampled is True, draws from a uniform distribution over
range. Otherwise, returns the fixed value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int | None
|
Optional number of samples. If omitted, returns a scalar. |
None
|
Returns:
| Type | Description |
|---|---|
float
|
float | numpy.ndarray: A single float if |
float
|
a NumPy array of samples. |
Source code in jscip/parameters.py
193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 | |
copy() -> IndependentScalarParameter
Return a shallow copy preserving configuration.
Returns:
| Name | Type | Description |
|---|---|---|
IndependentScalarParameter |
IndependentScalarParameter
|
A new parameter with the same value, range, |
IndependentScalarParameter
|
and sampling flag. |
Source code in jscip/parameters.py
213 214 215 216 217 218 219 220 221 222 223 224 | |
IndependentVectorParameter
A vector-valued parameter with optional multivariate sampling.
This class represents an Nx1 vector parameter that can be sampled from multivariate distributions. The parameter can be initialized with a list or NumPy array and supports element-wise or uniform range specifications.
Attributes:
| Name | Type | Description |
|---|---|---|
value |
ndarray
|
Current vector value as a 1D NumPy array of length N. |
shape |
tuple[int]
|
Tuple (N,) representing the dimensionality. |
is_sampled |
bool
|
Whether this parameter will be sampled from a distribution. |
range |
tuple[ndarray, ndarray] | None
|
Element-wise bounds as (low_array, high_array) or None. |
distribution |
str
|
Distribution type ('uniform' or 'mvnormal'). |
Raises:
| Type | Description |
|---|---|
ValueError
|
If types are invalid, shapes are inconsistent, or values fall outside the provided ranges. |
Source code in jscip/parameters.py
375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |
value: np.ndarray
property
writable
Get the current value of the parameter.
shape: tuple[int]
property
Get the shape of the parameter.
range: tuple[np.ndarray, np.ndarray] | None
property
Get the range of the parameter.
distribution: str
property
Get the distribution type.
__init__(value: list | np.ndarray, is_sampled: bool = False, range: tuple[list | np.ndarray, list | np.ndarray] | tuple[float, float] | None = None, distribution: Literal['uniform', 'mvnormal'] = 'uniform', cov: np.ndarray | None = None)
Initialize a IndependentVectorParameter.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
value
|
list | ndarray
|
Initial vector value as list or 1D array of length N. |
required |
is_sampled
|
bool
|
Whether to sample this parameter. |
False
|
range
|
tuple[list | ndarray, list | ndarray] | tuple[float, float] | None
|
Either: - tuple of (low, high) arrays/lists of length N for element-wise bounds - tuple of (low, high) floats to apply same range to all elements - None for no range constraints |
None
|
distribution
|
Literal['uniform', 'mvnormal']
|
Distribution type - 'uniform' or 'mvnormal'. |
'uniform'
|
cov
|
ndarray | None
|
Covariance matrix for 'mvnormal' distribution (NxN array). If None and distribution='mvnormal', uses identity matrix. |
None
|
Raises:
| Type | Description |
|---|---|
ValueError
|
If value is not 1D, range shapes don't match, or distribution parameters are invalid. |
Source code in jscip/parameters.py
394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 | |
sample(size: int | None = None) -> np.ndarray
Sample from the parameter's distribution.
If is_sampled is True, draws from the configured distribution.
Otherwise, returns the fixed value.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
size
|
int | None
|
Optional number of samples. If omitted, returns a single sample with shape matching the parameter shape. |
None
|
Returns:
| Type | Description |
|---|---|
ndarray
|
numpy.ndarray: If size is None, returns array of shape (N,). If size is provided, returns array of shape (size, N). |
Source code in jscip/parameters.py
603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 | |
copy() -> IndependentVectorParameter
Return a copy preserving configuration.
Returns:
| Name | Type | Description |
|---|---|---|
IndependentVectorParameter |
IndependentVectorParameter
|
A new parameter with the same configuration. |
Source code in jscip/parameters.py
653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 | |