/[ascend]/trunk/base/generic/solver/slv.c
ViewVC logotype

Diff of /trunk/base/generic/solver/slv.c

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

revision 125 by johnpye, Tue Dec 20 08:32:25 2005 UTC revision 126 by johnpye, Tue Dec 20 13:27:11 2005 UTC
# Line 1  Line 1 
1  /*  /*
2   *  SLV: Ascend Nonlinear Solver      SLV: Ascend Nonlinear Solver
3   *  by Karl Michael Westerberg      Copyright (C) 1990 Karl Michael Westerberg
4   *  Created: 2/6/90      Copyright (C) 1993 Joseph Zaher
5   *  Version: $Revision: 1.51 $      Copyright (C) 1994 Joseph Zaher, Benjamin Andrew Allan
6   *  Version control file: $RCSfile: slv.c,v $      Copyright (C) 1996 Benjamin Andrew Allan
7   *  Date last modified: $Date: 1998/04/26 22:47:53 $      Copyright (C) 2005 The ASCEND developers
8   *  Last modified by: $Author: ballan $  
9   *      This program is free software; you can redistribute it and/or modify
10   *  This file is part of the SLV solver.      it under the terms of the GNU General Public License as published by
11   *      the Free Software Foundation; either version 2 of the License, or
12   *  Copyright (C) 1990 Karl Michael Westerberg      (at your option) any later version.
13   *  Copyright (C) 1993 Joseph Zaher  
14   *  Copyright (C) 1994 Joseph Zaher, Benjamin Andrew Allan      This program is distributed in the hope that it will be useful,
15   *      but WITHOUT ANY WARRANTY; without even the implied warranty of
16   *  The SLV solver is free software; you can redistribute      MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
17   *  it and/or modify it under the terms of the GNU General Public License as      GNU General Public License for more details.
18   *  published by the Free Software Foundation; either version 2 of the  
19   *  License, or (at your option) any later version.      You should have received a copy of the GNU General Public License
20   *      along with this program; if not, write to the Free Software
21   *  The SLV solver is distributed in hope that it will be      Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA  02110-1301  USA
22   *  useful, but WITHOUT ANY WARRANTY; without even the implied warranty of      This file is part of the SLV solver.
23   *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU  */
  *  General Public License for more details.  
  *  
  *  You should have received a copy of the GNU General Public License  
  *  along with the program; if not, write to the Free Software Foundation,  
  *  Inc., 675 Mass Ave, Cambridge, MA 02139 USA.  Check the file named  
  *  COPYING.  COPYING is found in ../compiler.  
  *  
  */  
24    
25  #include <math.h>  #include <math.h>
26  #include <stdarg.h>  #include <stdarg.h>
# Line 57  Line 49 
49  #include "solver/slv_client.h"  #include "solver/slv_client.h"
50  #include "solver/analyze.h"  #include "solver/analyze.h"
51    
   
52  #define NEEDSTOBEDONE 0  #define NEEDSTOBEDONE 0
53    
54  /**  /**
# Line 66  Line 57 
57   ***  Defines are to take care of the unlinked ones.   ***  Defines are to take care of the unlinked ones.
58   **/   **/
59  #if 0  #if 0
60  #include "solver/slv0.h"  # include "solver/slv0.h"
61  #include "solver/slv1.h"  # include "solver/slv1.h"
62  #include "solver/slv2.h"  # include "solver/slv2.h"
63  #include "solver/slv3.h"  # include "solver/slv3.h"
64  #include "solver/slv4.h"  # include "solver/slv4.h"
65  #include "solver/slv5.h"  # include "solver/slv5.h"
66  #include "solver/slv6.h"  # include "solver/slv6.h"
67  #include "solver/slv7.h"  # include "solver/slv7.h"
68  #include "solver/slv8.h"  # include "solver/slv8.h"
69  #include "solver/slv9.h"  # include "solver/slv9.h"
   
70  #endif  #endif
71    
72    
73  struct slv_system_structure {  struct slv_system_structure {
74    int solver;    int solver;
75    int serial_id; /* through time, two systems may have the same pointer  
76                    * but never simultaneously. The serial_id provides a    int serial_id;
77                    * unique tag that will never repeat. Clients concerned      /**< Through time, two systems may have the same pointer but never
78                    * with identity but not capable of tracking time must          simultaneously. The serial_id provides a unique tag that will
79                    * use the serial_id for checks.          never repeat. Clients concerned with identity but not capable
80                    */          of tracking time must use the serial_id for checks. */
81    
82    SlvBackendToken instance; /* should be void * in the most generic case */    SlvBackendToken instance; /* should be void * in the most generic case */
83    
84    /* All solver handles.  sysI can't be dereferenced outside slvI.c    /* All solver handles.  sysI can't be dereferenced outside slvI.c
# Line 239  struct slv_system_structure { Line 230  struct slv_system_structure {
230  };  };
231    
232    
233  /*********************************************************************\  /**
234   global variable used to communicate information between solvers and   global variable used to communicate information between solvers and
235   an interface, whether a calculation should be halted or not.   an interface, whether a calculation should be halted or not.
236   0 means go on. any other value may contain additional information   0 means go on. any other value may contain additional information
237   content.   content.
238  \*********************************************************************/  */
239  int Solv_C_CheckHalt_Flag = 0;  int Solv_C_CheckHalt_Flag = 0;
240    
241  int g_SlvNumberOfRegisteredClients; /* see header */  int g_SlvNumberOfRegisteredClients; /* see header */
242    
243    /** making ANSI assumption that RegisteredClients is init to 0/NULLs */
244  static SlvFunctionsT SlvClientsData[SLVMAXCLIENTS];  static SlvFunctionsT SlvClientsData[SLVMAXCLIENTS];
 /* making ANSI assumption that RegisteredClients is init to 0/NULLs */  
245    
246    /*-----------------------------------------------------------------*/
247    /**
248        Note about g_number_of_whens, g_number_of_dvars and g_number_of_bnds:
249        These numbers are as the same as those given in the solver and master
250        lists, however, these lists are destroyed before the buffers are destroyed,
251        so the information is gone before I can use it.
252    */
253    
254  /*  /** Global var used to destroy the cases and the gl_list inside each WHEN */
  * global variables used to destroy:  
  * the cases and the gllist inside each when,  
  * the list of whens in each discrete variable, and  
  * the list of logical relations in each boundary, correspondingly.  
  * This number are as the same as those given in the solver and master  
  * lists, however, these lists are destroyed before the buffers are  
  * destroyed, so the information is gone before I can use it.  
  */  
255  static int g_number_of_whens;  static int g_number_of_whens;
256    
257    /** Global var used to destroy the list of whens in each discrete variable */
258  static int g_number_of_dvars;  static int g_number_of_dvars;
259    
260    /** Global var used to destroy the list of logical relations in each boundary */
261  static int g_number_of_bnds;  static int g_number_of_bnds;
262    
263  /*-------------------------------------------------------------------  /*-------------------------------------------------------------------
# Line 295  static int g_number_of_bnds; Line 289  static int g_number_of_bnds;
289  /** Free a pointer provided it's not NULL */  /** Free a pointer provided it's not NULL */
290  #define SFUN(p) if ((p) != NULL) ascfree(p)  #define SFUN(p) if ((p) != NULL) ascfree(p)
291    
292  /*********************************************************************\  /*-----------------------------------------------------------------
293    server functions.      SERVER FUNCTIONS
294  \*********************************************************************/  */
295    
296    /** Register a new solver.
297        @TODO This needs work still, particularly of the dynamic loading
298        sort. it would be good if here we farmed out the dynamic loading
299        to another file so we don't have to crap this one all up.
300    */
301  int slv_register_client(SlvRegistration registerfunc, char *func, char *file)  int slv_register_client(SlvRegistration registerfunc, char *func, char *file)
302  {  {
   /* this needs work still, particularly of the dynamic loading sort.  
    * it would be good if here we farmed out the dynamic loading  
    * to another file so we don't have to crap this one all up.  
    */  
303    int status;    int status;
304    
305    (void)func;  /*  stop gcc whine about unused parameter */    (void)func;  /*  stop gcc whine about unused parameter */

Legend:
Removed from v.125  
changed lines
  Added in v.126

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