/[ascend]/trunk/models/johnpye/solve.py
ViewVC logotype

Contents of /trunk/models/johnpye/solve.py

Parent Directory Parent Directory | Revision Log Revision Log


Revision 1074 - (show annotations) (download) (as text)
Tue Jan 9 02:45:44 2007 UTC (14 years ago) by johnpye
File MIME type: text/x-python
File size: 1124 byte(s)
Added more to catch missing X windows server
1 try:
2 from solverreporter import *
3 have_solverreporter = True
4 except RuntimeError,e:
5 print "NOTE: RuntimeError when importing solverreporter: %s", e
6 have_solverreporter = False
7 except Exception,e:
8 print "NOTE: unrecognised error when importing solverreporter: %s",e
9 have_solverreporter = False
10
11 import extpy
12
13 def solve(self):
14 """ run the active solver on the current model (reporting to the status bar only) """
15
16 assert self.__class__.__name__=="Instance"
17 assert self.isModel()
18 print "SELF IS A MODEL"
19
20 browser = extpy.getbrowser()
21 if browser:
22 print "Using browser.solver"
23 solver = browser.solver
24 else:
25 print "Using hardwired default solver, QRSlv"
26 solver = ascpy.Solver("QRSlv")
27
28 if browser and have_solverreporter:
29 reporter = SimpleSolverReporter(browser)
30 else:
31 print "Using console solver reporter"
32 reporter = ascpy.SolverReporter()
33
34 # the 'sim' object is registered in simulation.cpp each time a method is to be run
35 # (an exception is thrown if not available (eg if C++ not being used)
36 sim = ascpy.Registry().getSimulation("sim")
37
38 sim.solve(solver,reporter)
39
40 extpy.registermethod(solve)

john.pye@anu.edu.au
ViewVC Help
Powered by ViewVC 1.1.22