Exemplo n.º 1
0
 def test_lagrangian_bound(self):
     """ Make sure the lagrangian bound is at least a bound
     """
     from mpisppy.extensions.xhatlooper import XhatLooper
     PHoptions = self._copy_of_base_options()
     PHoptions["PHIterLimit"] = 1
     PHoptions["xhat_looper_options"] =  {"xhat_solver_options":\
                                          PHoptions["iterk_solver_options"],
                                          "scen_limit": 3}
     ph = mpisppy.opt.ph.PH(PHoptions,
                            self.all3_scenario_names,
                            scenario_creator,
                            scenario_denouement,
                            cb_data=3,
                            PH_extensions=XhatLooper)
     conv, basic_obj, tbound = ph.ph_main()
     xhatobj = ph.extobject._xhat_looper_obj_final
     dopts = sputils.option_string_to_dict("mipgap=0.0001")
     objbound = ph.post_solve_bound(solver_options=dopts, verbose=False)
     self.assertGreaterEqual(xhatobj, objbound)
Exemplo n.º 2
0
            )
            f.write(", " + str(PHoptions["solvername"]))
            f.write(", " + str(ph.n_proc))
            f.write(", " + nbunstr)
            f.write(", " + str(PHoptions["PHIterLimit"]))
            f.write(", " + str(PHoptions["convthresh"]))
            f.write(", " + str(PHoptions["defaultPHrho"]))
    ###from mpisppy.xhatlooper import XhatLooper
    conv, eobj, tbound = ph.ph_main()

    # PH_extensions=XhatLooper,

    print("\nQUITTING EARLY; this needs to be a hub and have spokes!!!")
    quit()

    dopts = {"mipgap": 0.001}
    ph.PHoptions["asynchronous"] = False
    objbound = ph.post_solve_bound(solver_options=dopts, verbose=False)
    if ph.rank == 0:
        print("**** Lagrangian objective function bound=", objbound)

    end_time = dt.datetime.now()

    if ph.rank == 0:
        with open(appfile, "a") as f:
            f.write(", " + str(objbound) + ", " + str(tbound) + ", " + str(ph._PHIter))
            f.write(", " + str((end_time - start_time).total_seconds()))
            if PHoptions["asynchronous"]:
                f.write(", " + str(PHoptions["async_frac_needed"]))
                f.write(", " + str(PHoptions["async_sleep_secs"]))