/[ascend]/trunk/pygtk/simulation.cpp
ViewVC logotype

Diff of /trunk/pygtk/simulation.cpp

Parent Directory Parent Directory | Revision Log Revision Log | View Patch Patch

revision 1379 by jpye, Thu Mar 29 16:21:39 2007 UTC revision 1380 by jpye, Fri Apr 6 04:07:32 2007 UTC
# Line 88  Simulation::~Simulation(){ Line 88  Simulation::~Simulation(){
88      CONSOLE_DEBUG("Destroying Simulation...");      CONSOLE_DEBUG("Destroying Simulation...");
89      /*      /*
90      // FIXME removing this here, because Python overzealously seems to delete simulations      // FIXME removing this here, because Python overzealously seems to delete simulations
91        
92      CONSOLE_DEBUG("Deleting simulation %s", getName().toString());      CONSOLE_DEBUG("Deleting simulation %s", getName().toString());
93      system_free_reused_mem();      system_free_reused_mem();
94      if(sys){      if(sys){
# Line 145  Simulation::write(FILE *fp, const char * Line 145  Simulation::write(FILE *fp, const char *
145      };      };
146    
147      const rel_filter_t rfilter = {      const rel_filter_t rfilter = {
148            REL_INCLUDED | REL_EQUALITY | REL_ACTIVE            REL_INCLUDED | REL_EQUALITY | REL_ACTIVE
149          , REL_INCLUDED | REL_EQUALITY | REL_ACTIVE          , REL_INCLUDED | REL_EQUALITY | REL_ACTIVE
150      };      };
151    
152      if(type==NULL){      if(type==NULL){
# Line 156  Simulation::write(FILE *fp, const char * Line 156  Simulation::write(FILE *fp, const char *
156      }else if(string(type) == "dot"){      }else if(string(type) == "dot"){
157          if(!sys)throw runtime_error("Can't write DOT file: simulation not built");          if(!sys)throw runtime_error("Can't write DOT file: simulation not built");
158          CONSOLE_DEBUG("Writing graph...");          CONSOLE_DEBUG("Writing graph...");
159          if(!fp)fp=stdout;          if(!fp){
160                CONSOLE_DEBUG("... to stdout");
161                fp=stdout;
162            }
163          res = system_write_graph(sys, fp, &rfilter, &vfilter);          res = system_write_graph(sys, fp, &rfilter, &vfilter);
164          if(res){          if(res){
165              stringstream ss;              stringstream ss;
# Line 190  Simulation::runDefaultMethod(){ Line 193  Simulation::runDefaultMethod(){
193          ERROR_REPORTER_NOLINE(ASC_USER_WARNING,"There is no 'on_load' method defined for type '%s'",type.getName().toString());          ERROR_REPORTER_NOLINE(ASC_USER_WARNING,"There is no 'on_load' method defined for type '%s'",type.getName().toString());
194          return;          return;
195      }      }
196      run(m);          run(m);
197  }    }
198    
199  void  void
200  Simulation::run(const Method &method, Instanc &model){  Simulation::run(const Method &method, Instanc &model){
# Line 366  Simulation::checkDoF() const{ Line 369  Simulation::checkDoF() const{
369      Check consistency      Check consistency
370    
371      @TODO what is the difference between this and checkStructuralSingularity?      @TODO what is the difference between this and checkStructuralSingularity?
372        
373      @return list of freeable variables. List will be empty if sys is consistent.      @return list of freeable variables. List will be empty if sys is consistent.
374  */  */
375  vector<Variable>  vector<Variable>
# Line 540  Simulation::build(){ Line 543  Simulation::build(){
543      if(NumberPendingInstances(simroot.getInternalType())){      if(NumberPendingInstances(simroot.getInternalType())){
544          throw runtime_error("System has pending instances; can't yet send to solver.");          throw runtime_error("System has pending instances; can't yet send to solver.");
545      }      }
546        
547      CONSOLE_DEBUG("============== REALLY building system...");      CONSOLE_DEBUG("============== REALLY building system...");
548      sys = system_build(simroot.getInternalType());      sys = system_build(simroot.getInternalType());
549      if(!sys){      if(!sys){
550          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Failed to build system");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Failed to build system");
551          throw runtime_error("Unable to build system");          throw runtime_error("Unable to build system");
552      }      }
553        
554      CONSOLE_DEBUG("System built OK");      CONSOLE_DEBUG("System built OK");
555  }  }
556    
# Line 581  Simulation::setParameters(SolverParamete Line 584  Simulation::setParameters(SolverParamete
584  //------------------------------------------------------------------------------  //------------------------------------------------------------------------------
585  // PRE-SOLVE DIAGNOSTICS  // PRE-SOLVE DIAGNOSTICS
586    
587  /**  /**
588      Get a list of variables to fix to make an underspecified system      Get a list of variables to fix to make an underspecified system
589      become square. Also seems to return stuff when you have a structurally      become square. Also seems to return stuff when you have a structurally
590      singuler system.      singuler system.
# Line 733  SingularityInfo::isSingular() const{ Line 736  SingularityInfo::isSingular() const{
736  // SOLVING  // SOLVING
737    
738  /**  /**
739      Solve the system through to convergence. This function is hardwired with      Solve the system through to convergence. This function is hardwired with
740      a maximum of 1000 iterations, but will interrupt itself when the 'stop'      a maximum of 1000 iterations, but will interrupt itself when the 'stop'
741      condition comes back from the SolverReporter.      condition comes back from the SolverReporter.
742  */  */
# Line 792  Simulation::solve(Solver solver, SolverR Line 795  Simulation::solve(Solver solver, SolverR
795    
796      double elapsed = tm_cpu_time() - starttime;      double elapsed = tm_cpu_time() - starttime;
797      CONSOLE_DEBUG("Elapsed time: %0.3f", elapsed);      CONSOLE_DEBUG("Elapsed time: %0.3f", elapsed);
798        
799      activeblock = status.getCurrentBlockNum();      activeblock = status.getCurrentBlockNum();
800    
801      try{      try{
# Line 870  Simulation::processVarStatus(){ Line 873  Simulation::processVarStatus(){
873          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Unable to update var status (get_status returns error)");          ERROR_REPORTER_HERE(ASC_PROG_ERR,"Unable to update var status (get_status returns error)");
874          return;          return;
875      }      }
876        
877      if(status.block.number_of == 0){      if(status.block.number_of == 0){
878          cerr << "Variable statuses can't be set: block structure not yet determined." << endl;          cerr << "Variable statuses can't be set: block structure not yet determined." << endl;
879          return;          return;
# Line 880  Simulation::processVarStatus(){ Line 883  Simulation::processVarStatus(){
883          ERROR_REPORTER_HERE(ASC_USER_WARNING,"No blocks identified in system");          ERROR_REPORTER_HERE(ASC_USER_WARNING,"No blocks identified in system");
884          return;          return;
885      }      }
886        
887      int activeblock = status.block.current_block;      int activeblock = status.block.current_block;
888      asc_assert(activeblock <= status.block.number_of);      asc_assert(activeblock <= status.block.number_of);
889    

Legend:
Removed from v.1379  
changed lines
  Added in v.1380

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