@@ -555,7 +555,7 @@ def __call__(self, est_covariance, est):
555
555
if self ._stat_type != "mean" and isinstance (
556
556
est ._stat , MultiOutputMeanAndVariance ):
557
557
return (
558
- est_covariance [est .nqoi + self ._qoi_idx ,
558
+ est_covariance [est ._nqoi + self ._qoi_idx ,
559
559
est ._nqoi + self ._qoi_idx ])
560
560
elif (isinstance (
561
561
est ._stat , (MultiOutputVariance , MultiOutputMean )) or
@@ -570,7 +570,7 @@ def __repr__(self):
570
570
571
571
def compute_variance_reductions (optimized_estimators ,
572
572
criteria = ComparisonCriteria ("det" ),
573
- nhf_samples = None ):
573
+ nhf_samples = None , pilot_cost = None ):
574
574
"""
575
575
Compute the variance reduction (relative to single model MC) for a
576
576
list of optimized estimtors.
@@ -597,6 +597,11 @@ def compute_variance_reductions(optimized_estimators,
597
597
evaluations that produce a estimator cost equal to the optimized
598
598
target cost of the estimator is used. Usually, nhf_samples should be
599
599
set to None.
600
+
601
+ pilot_cost : float
602
+ The cost of running the pilot study. if not None this is used to
603
+ determine the number of high-fidelity samples used by a single
604
+ fidelity MC study that does not need a pilot
600
605
"""
601
606
var_red , est_criterias , sf_criterias = [], [], []
602
607
optimized_estimators = optimized_estimators .copy ()
@@ -606,7 +611,16 @@ def compute_variance_reductions(optimized_estimators,
606
611
est_criteria = criteria (est ._covariance_from_npartition_samples (
607
612
est ._rounded_npartition_samples ), est )
608
613
if nhf_samples is None :
609
- nhf_samples = int (est ._rounded_target_cost / est ._costs [0 ])
614
+ if pilot_cost is None :
615
+ nhf_samples = int (est ._rounded_target_cost / est ._costs [0 ])
616
+ else :
617
+ nhf_samples = int (
618
+ (est ._rounded_target_cost + pilot_cost )/ est ._costs [0 ])
619
+ else :
620
+ if pilot_cost is not None :
621
+ msg = "pilot cost was specified even though nhf_samples was "
622
+ msg += "not None"
623
+ raise ValueError (msg )
610
624
sf_criteria = criteria (
611
625
est ._stat .high_fidelity_estimator_covariance (
612
626
nhf_samples ), est )
0 commit comments