Hot-keys on this page
r m x p toggle line displays
j k next/prev highlighted chunk
0 (zero) top of page
1 (one) first highlighted chunk
""" Tests creation and solution of MarginModel""" m = sp_test_model() mm = MarginModel(m, gamma = 0.5) margin_solution = mm.localsolve(verbosity=0) uncertain_varkeys = [k for k in m.varkeys if RobustGPTools.is_directly_uncertain(k)] # Checking margin allocation for key in list(uncertain_varkeys): assert(mm.substitutions.get(key) == m.substitutions.get(key) * (1.+mm.setting.get("gamma")*key.pr/100.)) self.assertGreater(margin_solution['cost'], mm.nominal_cost)
""" Tests creation and solution of MarginModel""" # Checking margin allocation (1.+mm.setting.get("gamma")*key.pr/100.))
""" Testing conservativeness of solution methods"""
# def test_robustify_monomial(): # """ Testing whether monomials are robustified correctly""" # m = gp_test_model() # chopped_posys = [] # for c in m.flat(constraintsets=False): # chopped_posys.append(c.as_posyslt1()[0].chop()) # rm = RobustModel(m, 'elliptical')
{'name': 'Linearized Perturbations', 'twoTerm': False, 'boyd': False, 'simpleModel': False}, {'name': 'Simple Conservative', 'twoTerm': False, 'boyd': False, 'simpleModel': True} ] boyd=method['boyd'], simpleModel=method['simpleModel'], nominalsolve=nominal_solution)
run_tests(TESTS)
test() |