Changeset 2393


Ignore:
Timestamp:
Feb 22, 2010 7:18:12 PM (10 years ago)
Author:
jwatson
Message:

Single-threading the ph solver server (for obvious reasons - don't want to spawn a zillion solves) and fixing issues in the solver server test client. Solves occur and results can be shipped back to a client, w/o passing of the instance.

Location:
coopr.pysp/trunk
Files:
2 edited

Legend:

Unmodified
Added
Removed
  • coopr.pysp/trunk/coopr/pysp/phserver.py

    r2325 r2393  
    3535import pstats
    3636
     37import pickle
     38
     39# disable multi-threading. for a solver server, this
     40# would truly be a bad idea, as you (1) likely have limited
     41# solver licenses and (2) likely want to dedicate all compute
     42# resources on this node to a single solve.
     43Pyro.config.PYRO_MULTITHREADED=0
    3744
    3845#
     
    5562      scenario_instance = self._scenario_instances[scenario_name]
    5663      print "SCENARIO INSTANCE=",scenario_instance
    57       print "SUPPORTS MULTITHREADING=",Pyro.util.supports_multithreading()
    5864      print "SOLVING"
    59       self._solver.solve(scenario_instance)
     65      results = self._solver.solve(scenario_instance)
     66      print "TYPE OF RESULTS=",type(results)
     67      print "RESULTS:"
     68      results.write(num=1)
    6069      print "DONE WITH SOLVE"
    61       return scenario_instance
    62 #      return result
     70      encoded_results = pickle.dumps(results)
     71     
     72      return encoded_results
    6373
    6474#
     
    256266   for scenario_name, scenario_instance in scenario_instances.items():
    257267      solver_daemon.connect(delegator_object, scenario_name)
     268
     269   print "WAITING FOR REQUESTS"
    258270
    259271   while True:
     
    318330      solver._report_timing = True
    319331
    320    print "SOLVING!"
    321    results = solver.solve(scenario_instance)
    322    print "TYPE OF RESULTS=",type(results)
    323    results.write(num=1)
     332#   print "SOLVING!"
     333#   results = solver.solve(scenario_instance)
     334#   print "TYPE OF RESULTS=",type(results)
     335#   results.write(num=1)
    324336#   print "RESULTS=",results
    325    print "DONE SOLVING!"
     337#   print "DONE SOLVING!"
    326338
    327339   # spawn the daemon.
  • coopr.pysp/trunk/scripts/ph_test_client

    r2320 r2393  
    44import Pyro.naming
    55
    6 from coopr.opt.base import SolverFactory
    7 from coopr.opt import *
     6import pickle
     7
     8import pyutilib.misc
     9import pyutilib.component.core
     10from coopr.opt.results import SolverResults
    811
    912import sys
     
    3841
    3942print "CALLING SOLVE METHOD"
    40 result = obj.solve(scenario_name)
     43encoded_result = obj.solve(scenario_name)
     44result = pickle.loads(encoded_result)
     45print "SUCCESSFULLY OBTAINED RESULT!"
    4146
    42 print "RESULT=",result
     47print "RESULTS:"
     48result.write(num=1)
    4349
    4450print "DONE"
Note: See TracChangeset for help on using the changeset viewer.