def test_xhat_eval_creator(self):
        options = self._get_xhatEval_options()

        MMW_options = self._get_base_options()
        scenario_creator_kwargs = MMW_options['kwargs']
        scenario_creator_kwargs['num_scens'] = MMW_options['batch_size']
        ev = Xhat_Eval(options,
                       farmer.scenario_names_creator(100),
                       farmer.scenario_creator,
                       scenario_denouement=None,
                       scenario_creator_kwargs=scenario_creator_kwargs)
 def test_gap_estimators(self):
     scenario_names = farmer.scenario_names_creator(50, start=1000)
     estim = ciutils.gap_estimators(
         self.xhat,
         self.refmodelname,
         solvername=solvername,
         scenario_names=scenario_names,
     )
     G = estim['G']
     s = estim['s']
     G, s = round_pos_sig(G, 3), round_pos_sig(s, 3)
     self.assertEqual((G, s), (110.0, 426.0))
    def test_xhat_eval_evaluate(self):
        options = self._get_xhatEval_options()
        MMW_options = self._get_base_options()
        scenario_creator_kwargs = MMW_options['kwargs']
        scenario_creator_kwargs['num_scens'] = MMW_options['batch_size']
        ev = Xhat_Eval(options,
                       farmer.scenario_names_creator(100),
                       farmer.scenario_creator,
                       scenario_denouement=None,
                       scenario_creator_kwargs=scenario_creator_kwargs)

        xhat = ciutils.read_xhat(self.xhat_path)
        obj = round_pos_sig(ev.evaluate(xhat), 2)
        self.assertEqual(obj, -1300000.0)
 def test_xhat_eval_evaluate_one(self):
     options = self._get_xhatEval_options()
     MMW_options = self._get_base_options()
     xhat = ciutils.read_xhat(self.xhat_path)
     scenario_creator_kwargs = MMW_options['kwargs']
     scenario_creator_kwargs['num_scens'] = MMW_options['batch_size']
     scenario_names = farmer.scenario_names_creator(100)
     ev = Xhat_Eval(options,
                    scenario_names,
                    farmer.scenario_creator,
                    scenario_denouement=None,
                    scenario_creator_kwargs=scenario_creator_kwargs)
     k = scenario_names[0]
     obj = ev.evaluate_one(xhat, k, ev.local_scenarios[k])
     obj = round_pos_sig(obj, 2)
     self.assertEqual(obj, -48000.0)