[Tutor] C++ Extension Problems (Part1)

Keule m_konermann@gmx.de
Sun, 03 Feb 2002 17:30:53 +0100


This is a multi-part message in MIME format.
--------------030800020909010209070602
Content-Type: multipart/alternative;
 boundary="------------020406090507060503020205"


--------------020406090507060503020205
Content-Type: text/plain; charset=ISO-8859-1; format=flowed
Content-Transfer-Encoding: 8bit

Hi @ ALL !

I´ve created a .dll file with SWIG under windows. Now i want to use it 
and try to import it into the simannealfile.py modul, but pythonwin 
always gives the following error:

File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py" , line 394, 
in ImportFile
    exec codeObj in __main__.__dict__
  File "<auto import>", line 1, in ?
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.
Traceback (most recent call last):
  File "C:\Python21\Pythonwin\pywin\framework\scriptutils.py" , line 
301, in RunScript
    exec codeObject in __main__.__dict__
  File 
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\simannealfile.py" 
, line 2, in ?
    import simannealfile
ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.

I checked out the examples ,delivered with SWIG, and compared them with 
my Settings under Visual C++. The Examples are all functioned and now i 
absolutly did´nt know whats going wrong and why i always get the 
Errormessage above. I ´ve put my files with these mail.
Perhaps anyone of you could check my settings an can give me an advice 
what´s going wrong.

Thanks a lot
Greetings
Marcus


--------------020406090507060503020205
Content-Type: text/html; charset=us-ascii
Content-Transfer-Encoding: 7bit

<html>
<head>
</head>
<body>
Hi @ ALL !<br>
<br>
 I&acute;ve created a .dll file with SWIG under windows. Now i want to use it and 
try to import it into the simannealfile.py modul, but pythonwin always gives 
the following error:<br>
<br>
<i>File <a class="moz-txt-link-rfc2396E" href="C:%5CPython21%5CPythonwin%5Cpywin%5Cframework%5Cscriptutils.py">
"C:\Python21\Pythonwin\pywin\framework\scriptutils.py"</a>
, line 394, in ImportFile<br>
  &nbsp;&nbsp;&nbsp; exec codeObj in __main__.__dict__<br>
  &nbsp; File "&lt;auto import&gt;", line 1, in ?<br>
  ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.<br>
  Traceback (most recent call last):<br>
  &nbsp; File <a class="moz-txt-link-rfc2396E" href="C:%5CPython21%5CPythonwin%5Cpywin%5Cframework%5Cscriptutils.py">
"C:\Python21\Pythonwin\pywin\framework\scriptutils.py"</a>
, line 301, in RunScript<br>
  &nbsp;&nbsp;&nbsp; exec codeObject in __main__.__dict__<br>
  &nbsp; File <a class="moz-txt-link-rfc2396E" href="C:%5CArbeit_Diplomarbeit%5C__Optimierer%5CTEM%5Csimannealfile%5Csimannealfile.py">
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\simannealfile.py"</a>
, line 2, in ?<br>
  &nbsp;&nbsp;&nbsp; import simannealfile<br>
  ImportError: DLL load failed: Das angegebene Modul wurde nicht gefunden.</i><br>
<br>
 I checked out the examples ,delivered with SWIG, and compared them with
my Settings under Visual C++. The Examples are all functioned and now i absolutly 
did&acute;nt know whats going wrong and why i always get the Errormessage above. 
I &acute;ve put my files with these mail. <br>
 Perhaps anyone of you could check my settings an can give me an advice what&acute;s 
going wrong.<br>
<br>
 Thanks a lot<br>
 Greetings<br>
 Marcus<br>
<br>
</body>
</html>

--------------020406090507060503020205--

--------------030800020909010209070602
Content-Type: text/plain;
 name="basisfile.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="basisfile.h"

#ifndef BASISFILE_H
#define BASISFILE_H

#include "safe_string.h"
#include "variable.h"

struct filetext {
  filetext ();
  ~filetext ();

  void clean (struct filetext *ft);
  void clean ();

  struct string text;
  struct string parameter_text;
  /* text first line number */ 
  int tfln;
  /* text last line number */
  int tlln;
  /* pointer to the variable-struct, which points to this
     text-struct. */
  struct variablelist *variable_pointer;
  struct filetext *next;
};

struct basisfile {
  basisfile ();
  basisfile (struct string &fn);
  basisfile (char *fn);
  ~basisfile ();

  void init (char *fn);
  void clean ();
  
  struct filetext *text;
  struct string *filename;

  int readfile ();
  /* write this.text and this.parameter_text to file 'filename'.
     writefile walks through from this to last element of next-pointer
     and writes first text and then parameter_text to the file.  The
     file is opened once in mode 'mode'.  Values of mode are meant to
     be "w"- or "a"-modes according to the fopen()-function. */
  int writefile (struct string &filename, char *mode = "w");
  int writefile (char *mode = "w");
  int build (struct variablelist *variable);
  /* searches parameter_text specified in 'variable' in text of
     'text'.  If found, the text of 'text' is split into 'text' and
     'parameter_text' and in case some text of the line is left, a new
     node is inserted into 'text'.  In case of **text contains a
     splitted line, split will call itself recursively in order to
     search the whole line.  The text-pointer of *variable is set to
     the node of **text containing the parametertext belonging to
     variable.

     How is parameter_text searched for?  It is searched for the line
     variable->linenumber.  variable->preseparator and
     variable->pastseparator gives the text left and right from the
     searched parameter_text.  variable->position gives the number of
     preseparator sets which must be found before parameter_text.  If
     variable->position is 0, variable->preseparator is ignored and it
     is assumed, that the parameter_text starts at the beginning of
     the line.  If enough preseparators are found, the pastseparator
     will be searched for.  An empty pastseparator will lead to an
     error, if the file is continuing after the parameter_text.  A
     pastseparator not found, too.

     Return value is 0, if everything is fine, > 0 if an error occured.
  */
  int split (struct filetext **text, struct variablelist *variable, 
	     int separators = 0);
};

/* Copys x_now of variables to their parameter_texts */
int vl2pt (struct variablelist *vl);
void print (struct filetext *ft);
#endif

--------------030800020909010209070602
Content-Type: text/plain;
 name="calculate.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="calculate.cpp"

#include "calculate.h"
#include "basisfile.h"


int calculate (struct variable &result, struct variablelist *vl, 
	       struct basisfile *bf, struct string *call) {
  /* create basisfile with given values of variables */
  /* 1. copy actual variables to parameter text parts */
  if (vl2pt (vl)) {
    printf ("calculate ():\n ");
    printf ("Error while copying variables (x_now) to parameter texts.\n");
    return 1;
  }

  /* 2. write basisfile */
  if (bf)
    bf->writefile ();
  else {
    printf ("calculate ():\n No basisfile structure specified.\n");
    return 1;
  }
  
  /* execute calculation */
  call->system_call ();

  /* build result out of calculated data */
  /* under construction !! */
  FILE *ergebnis = fopen ("output.asc", "r");
  if (ergebnis)
    fscanf(ergebnis, "%lf", &(result.dv));
  else {
    printf ("calculate:  Ausgabedatei `output.asc' nicht gefunden.\n");
    return 1;
  }
  fclose (ergebnis);
  
  return 0;
}

int calculate (struct variable &result, struct basisfile *bf, 
	       struct string *call) {
  /* write basisfile */
  if (bf)
    bf->writefile ();
  else {
    printf ("calculate ():\n No basisfile structure specified.\n");
    return 1;
  }
  
  /* execute calculation */
  call->system_call ();

  /* build result out of calculated data */
  /* under construction !! */
  FILE *ergebnis = fopen ("output.asc", "r");
  if (ergebnis)
    fscanf(ergebnis, "%lf", &(result.dv));
  else {
    printf ("calculate:  Ausgabedatei `ergebnis.asc' nicht gefunden.\n");
    return 1;
  }
  fclose (ergebnis);
  
  return 0;
}


--------------030800020909010209070602
Content-Type: text/plain;
 name="calculate.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="calculate.h"

#ifndef CALCULATE_H
#define CALCULATE_H

#include "variable.h"

/* calculates results for basisfile.  If vl is parameter, the x_now's
   from vl will be incorporated into the basisfile.  Otherwise not
   (this version is needed for first calculations, when x_now is still
   empty.) */
int calculate (struct variable &result, struct variablelist *vl, 
	       struct basisfile *bf, struct string *call);
int calculate (struct variable &result, struct basisfile *bf, 
	       struct string *call);

#endif

--------------030800020909010209070602
Content-Type: text/plain;
 name="evaluate.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="evaluate.cpp"

#include "evaluate.h"

evaluate::evaluate () {
  goal = NULL;
  epsilon = NULL;
  minchange = NULL;
  criteria = '0';
}

evaluate::~evaluate () {
}

int evaluate::abort (struct variable &result) {
  int comp;
  switch (criteria) {
  case 'e': /* epsilon-environment of goal must be reached */
    printf ("evaluate::abort(): case 'e' not implemented yet.\n");
    return -1;
    break;
  case 's': /* result must be smaller than goal */
    comp = smaller (&result, goal);
    if (comp < 0) {
      printf ("evaluate::abort():\n");
      printf (" Error while comparing result with goal.\n");
      return -1;
    }
    return comp;
    break;
  case 'g': /* result must be greater than goal */
    comp = greater (&result, goal);
    if (comp < 0) {
      printf ("evaluate::abort():\n");
      printf (" Error while comparing result with goal.\n");
      return -1;
    }
    return comp;
    break;
  case 'n': /* `minchange' has to be exceeded after `n' calculations of
	       result */
    printf ("evaluate::abort(): case 'n' not implemented yet.\n");
    return -1;
    break;
  default:
    printf ("evaluate::abort():\n");
    printf (" Unknown criteria `%c'.\n");
    return -1;
  }
  return 0;
}

--------------030800020909010209070602
Content-Type: text/plain;
 name="evaluate.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="evaluate.h"

#ifndef EVALUATE_H
#define EVALUATE_H

#include "variable.h"

struct evaluate {
  evaluate ();
  ~evaluate ();
  /* criteria is used to choose method to determine end or success of
     optimization.  

     'e': epsilon-environment of goal must be reached 
     's': result must be smaller than goal 
     'g': result must be greater than goal 
     'n': `minchange' has to be exceeded after `n' calculations of
     result 
  */
  char criteria;
  /* goal of optimization. */
  struct variable *goal;
  /* error with which goal may be achieved */
  struct variable *epsilon;
  /* `minchange' has to be exceeded after `n' calculations of result */
  struct variable *minchange;
  int n;

  int abort (struct variable &result);
};

#endif

--------------030800020909010209070602
Content-Type: text/plain;
 name="safe_string.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="safe_string.h"

#ifndef SAFE_STRING_H
#define SAFE_STRING_H

#include <stdio.h>
#include <stdlib.h>
#include <string.h>

//#include "variable.h"

/* This straight-forward string class is intended to make use of
   string operations safe.  Every function is meant to allocate just
   the memory the resulting string needs.  No space is wasted and no
   bytes are written in not-allocated memory.  To garantuee this, the
   'size' of a string is the number of characters stored in the
   string, including the ending '\0'. */
struct string {
  int size;
  char *label;

  string ();
  string ( int s, char *l = NULL );
  string ( char *s, char *l = NULL );
  string ( string &s, char *l = NULL );
  ~string ();

  void clean ();

  char &operator () ( int i )
    {
      check_index ( i );
      return str [i];
    }

  string &operator= ( string &s );

  /* Add a 's' to *this.  (strcat) */
  string &cat ( string &s );
  string &cat ( char *s );
  
  /* copies 's' to *this. (strcpy) */
  string &copy ( string &s );
  string &copy ( char *s );
  /* makes a string (*this) out of d.  Builds format-string for sprintf 
     "%a.decimalf" by calculating a from d. */
  int copy (double d, long int decimal);
  int copy (int i);
  /* copies the content of v to string. */
  int copy (struct variable *v);
  /* builds 'cs' with str of string */
  void out (char **cs);

  /* copies first 'n' bytes of 's' to *this.  (strncpy) */
  string &ncopy ( string &s, int n );
  /* copies 'n' bytes starting at 'offset' of 's' to *this.  (strncpy) */
  string &ncopy ( string &s, int n, int offset );

  /* composes string of 'first' and 'second' with 'inbetween'
     inbetween.  E.g. 'first' containing "first", 'second' containing
     "second" and 'inbetween' containing "." result is
     "first.second". */
  string &compose ( string &first, string &second, char *inbetween );
  string &compose ( string &first, char *second, char *inbetween );
  string &compose ( string &first, double second, char *inbetween );
  string &compose ( string &first, int second, char *inbetween );

  /* returns element i */
  int element ( int i );

  /* compares *this to 's'.  Returnvalues just like strcmp. */
  int compare ( struct string &s );
  int compare ( char *s );

  /* Works like strcspn.  Citing Emacs *info*: 
     The `strcspn' ("string complement span") function returns the
     length of the initial substring of STRING that consists entirely
     of characters that are _not_ members of the set specified by the
     string STOPSET.  (In other words, it returns the offset of the
     first character in STRING that is a member of the set STOPSET.)

     For example,
          strcspn ("hello, world", " \t\n,.;!?")
              => 5
  */
  int string_complement_span ( char *stopset, int offset );
  int string_complement_span ( struct string &stopset, int offset );
  int string_complement_span ( char *stopset );
  
  /* Works like strspn.  Citing Emacs *info*: 
     The `strspn' ("string span") function returns the length of the
     initial substring of STRING that consists entirely of characters
     that are members of the set specified by the string SKIPSET.  The
     order of the characters in SKIPSET is not important.
     
     For example,
          strspn ("hello, world", "abcdefghijklmnopqrstuvwxyz")
              => 5
  */
  int string_span ( struct string &stopset, int offset );
  int string_span ( char *stopset, int offset );
  
  /* Searches 'needle' in *this and copies the substring beginning
     with 'needle' to 'result'.  Return value is 1 if 'needle' is
     found, 0 otherwise.  (strstr) */
  int string_string ( struct string &result, char *needle );
  int string_string ( struct string &result, struct string &needle );
  int string_string ( struct string &result, struct string &needle, 
		      int offset );
  /* Searches character 'c' in *this.  Return value is 1 if 'c' is
     found, 0 otherwise.  (strchr) */
  int string_character ( char c );

  /* In a way like strbrk.  Copies the string beginning with the first
     found member of 'needle' in *this to result.  
  */
  void string_pointer_break ( struct string &result, char *needle );

  /* Interpretes *this as a filename returns a pointer to the file,
     opened in mode 's'.  (fopen) */
  FILE *fileopen ( char *s );
  /* copies the contents of 'file' to *this. */
  int fileread (string &file);
  /* copies the contents of 'file' to *this and returns the number of
     lines. */
  int filereadc (string &file, char count);
  /* writes contents of *this to the file named 'file'.  Mode should
     be "w" or "a" according to fopen(). */
  int filewrite (string &file, char *mode);
  /* writes *this to stream *out. */
  int filewrite (FILE *out);

  /* stdlib's 'system' */
  int system_call ();

  void init ( int s, char *l = NULL );

  protected:
    char *str;
    void check_index ( int i );
};

void print ( struct string &s );

/* print to standard output in the following order: 'first', 'string',
   'last'.  The Elements printed form 'string' may be limited by
   'offset' (first printed element) and 'stop' (last printed
   element). */
void strprint ( struct string &s, char *first = NULL, char *last = NULL ); 
void strprint ( struct string &s, int offset, char *first = NULL, 
		char *last = NULL ); 
void strprint ( struct string &s, int offset, char stop, char *first = NULL, 
		char *last = NULL );

#endif



--------------030800020909010209070602
Content-Type: text/plain;
 name="simanneal.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="simanneal.h"

#ifndef SIMANNEAL_H
#define SIMANNEAL_H

#include "variable.h"
#include "safe_string.h"
#include "evaluate.h"

struct simanneal_varlist {
  simanneal_varlist ();
  ~simanneal_varlist ();

  void clean ();
  void clean (struct simanneal_varlist *svl);

  /* copies parametertext's to x_now */
  int pt2xn ();
  struct variablelist *vl;
  struct simanneal_varlist *next;
};

struct simulated_annealing {
  simulated_annealing ();
  simulated_annealing (struct variablelist *vlist, struct basisfile *bf, 
		       struct evaluate *eval, int tm, double tf, 
		       struct string *syscall);
  ~simulated_annealing ();
  /* list of all variables */
  struct variablelist *vl;
  /* list of variables relevant for simulated annealing */
  struct simanneal_varlist *svl;
  /* basisfile text */
  struct basisfile *text;
  /* abort criteria */
  struct evaluate *success;
  /* maximum value of tc */
  int tc_max; /* 100 */
  /* factor of decreasement for temperature, when tc reaches tc_max */
  double t_factor; /* 0.98 */
  /* system call */
  struct string *call;

  int build_varlist ();
  int optimize ();
  int vary_simvarlist ();
  int take_new_result (struct variable &fnew, struct variable &fold, double t);
};

int x_now_2_x_opt (struct simanneal_varlist *svl);

#endif


--------------030800020909010209070602
Content-Type: text/plain;
 name="simannealfile.dsp"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="simannealfile.dsp"

# Microsoft Developer Studio Project File - Name="simannealfile" - Package Owner=<4>
# Microsoft Developer Studio Generated Build File, Format Version 6.00
# ** NICHT BEARBEITEN **

# TARGTYPE "Win32 (x86) Dynamic-Link Library" 0x0102

CFG=simannealfile - Win32 Debug
!MESSAGE Dies ist kein gültiges Makefile. Zum Erstellen dieses Projekts mit NMAKE
!MESSAGE verwenden Sie den Befehl "Makefile exportieren" und führen Sie den Befehl
!MESSAGE 
!MESSAGE NMAKE /f "simannealfile.mak".
!MESSAGE 
!MESSAGE Sie können beim Ausführen von NMAKE eine Konfiguration angeben
!MESSAGE durch Definieren des Makros CFG in der Befehlszeile. Zum Beispiel:
!MESSAGE 
!MESSAGE NMAKE /f "simannealfile.mak" CFG="simannealfile - Win32 Debug"
!MESSAGE 
!MESSAGE Für die Konfiguration stehen zur Auswahl:
!MESSAGE 
!MESSAGE "simannealfile - Win32 Release" (basierend auf  "Win32 (x86) Dynamic-Link Library")
!MESSAGE "simannealfile - Win32 Debug" (basierend auf  "Win32 (x86) Dynamic-Link Library")
!MESSAGE 

# Begin Project
# PROP AllowPerConfigDependencies 0
# PROP Scc_ProjName ""
# PROP Scc_LocalPath ""
CPP=cl.exe
MTL=midl.exe
RSC=rc.exe

!IF  "$(CFG)" == "simannealfile - Win32 Release"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 0
# PROP BASE Output_Dir "Release"
# PROP BASE Intermediate_Dir "Release"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 0
# PROP Output_Dir "Release"
# PROP Intermediate_Dir "Release"
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMANNEALFILE_EXPORTS" /YX /FD /c
# ADD CPP /nologo /MT /W3 /GX /O2 /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMANNEALFILE_EXPORTS" /YX /FD /c
# ADD BASE MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "NDEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "NDEBUG"
# ADD RSC /l 0x407 /d "NDEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /machine:I386

!ELSEIF  "$(CFG)" == "simannealfile - Win32 Debug"

# PROP BASE Use_MFC 0
# PROP BASE Use_Debug_Libraries 1
# PROP BASE Output_Dir "Debug"
# PROP BASE Intermediate_Dir "Debug"
# PROP BASE Target_Dir ""
# PROP Use_MFC 0
# PROP Use_Debug_Libraries 1
# PROP Output_Dir "Debug"
# PROP Intermediate_Dir "Debug"
# PROP Ignore_Export_Lib 0
# PROP Target_Dir ""
# ADD BASE CPP /nologo /MTd /W3 /Gm /GX /ZI /Od /D "WIN32" /D "_DEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMANNEALFILE_EXPORTS" /YX /FD /GZ /c
# ADD CPP /nologo /MTd /W3 /GX /Od /I "$(PYTHON_INCLUDE)" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMANNEALFILE_EXPORTS" /YX /FD /GZ /c
# ADD BASE MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD MTL /nologo /D "_DEBUG" /mktyplib203 /win32
# ADD BASE RSC /l 0x407 /d "_DEBUG"
# ADD RSC /l 0x407 /d "_DEBUG"
BSC32=bscmake.exe
# ADD BASE BSC32 /nologo
# ADD BSC32 /nologo
LINK32=link.exe
# ADD BASE LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib /nologo /dll /debug /machine:I386 /pdbtype:sept
# ADD LINK32 kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib $(PYTHON_LIB) /nologo /dll /incremental:no /machine:I386 /out:"simannealfile.dll" /libpath:"C:\Python21\libs"
# SUBTRACT LINK32 /debug

!ENDIF 

# Begin Target

# Name "simannealfile - Win32 Release"
# Name "simannealfile - Win32 Debug"
# Begin Group "Quellcodedateien"

# PROP Default_Filter "cpp;c;cxx;rc;def;r;odl;idl;hpj;bat"
# Begin Source File

SOURCE=.\basisfile.cpp
# End Source File
# Begin Source File

SOURCE=.\calculate.cpp
# End Source File
# Begin Source File

SOURCE=.\evaluate.cpp
# End Source File
# Begin Source File

SOURCE=.\safe_string.cpp
# End Source File
# Begin Source File

SOURCE=.\simannealfile.cpp
# End Source File
# Begin Source File

SOURCE=.\simannealfile_wrap.cpp
# End Source File
# Begin Source File

SOURCE=.\variable.cpp
# End Source File
# End Group
# Begin Group "Header-Dateien"

# PROP Default_Filter "h;hpp;hxx;hm;inl"
# Begin Source File

SOURCE=.\basisfile.h
# End Source File
# Begin Source File

SOURCE=.\calculate.h
# End Source File
# Begin Source File

SOURCE=.\evaluate.h
# End Source File
# Begin Source File

SOURCE=.\safe_string.h
# End Source File
# Begin Source File

SOURCE=.\simanneal.h
# End Source File
# Begin Source File

SOURCE=.\variable.h
# End Source File
# End Group
# Begin Group "Ressourcendateien"

# PROP Default_Filter "ico;cur;bmp;dlg;rc2;rct;bin;rgs;gif;jpg;jpeg;jpe"
# End Group
# Begin Source File

SOURCE=.\simannealfile.i

!IF  "$(CFG)" == "simannealfile - Win32 Release"

!ELSEIF  "$(CFG)" == "simannealfile - Win32 Debug"

# Begin Custom Build - SWIG Routine
ProjDir=.
InputPath=.\simannealfile.i
InputName=simannealfile

"$(ProjDir)\$(InputName)_wrap.cpp" : $(SOURCE) "$(INTDIR)" "$(OUTDIR)"
	echo In order to function correctly, please ensure the following environment variables are correctly set: 
	echo PYTHON_INCLUDE: %PYTHON_INCLUDE% 
	echo PYTHON_LIB: %PYTHON_LIB% 
	echo on 
	swig -python -c++ -o $(ProjDir)\$(InputName)_wrap.cpp $(InputPath) 
	
# End Custom Build

!ENDIF 

# End Source File
# End Target
# End Project

--------------030800020909010209070602
Content-Type: text/plain;
 name="simannealfile.dsw"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="simannealfile.dsw"

Microsoft Developer Studio Workspace File, Format Version 6.00
# WARNUNG: DIESE ARBEITSBEREICHSDATEI DARF NICHT BEARBEITET ODER GELÖSCHT WERDEN!

###############################################################################

Project: "simannealfile"=.\simannealfile.dsp - Package Owner=<4>

Package=<5>
{{{
}}}

Package=<4>
{{{
}}}

###############################################################################

Global:

Package=<5>
{{{
}}}

Package=<3>
{{{
}}}

###############################################################################


--------------030800020909010209070602
Content-Type: text/plain;
 name="simannealfile.i"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="simannealfile.i"

%module simannealfile

%{
#include "simanneal.h"
#include "calculate.h"
#include "evaluate.h"
#include "safe_string.h"
#include "calculate.h"
%}


%rename(cleany) simanneal_varlist::clean();
%rename(calc_4args) calculate(struct variable &,struct variablelist *,struct basisfile *,struct string *); 
%rename(cat_string) &string::cat(string &);
%rename(copy_string) &string::copy(string &);
%rename(copy_char) &string::copy(char *);
%rename(copy_dl) string::copy(double ,long );
%rename(copy_i) string::copy(int );
%rename(ncopy_string_i) &string::ncopy(string &,int );
%rename(compose_str_str_char) &string::compose(string &,string &,char *);
%rename(compose_str_char_char) &string::compose(string &,char *,char *);
%rename(compose_str_d_char) &string::compose(string &,double ,char *);
%rename(compose_struct_string) string::compare(struct string &);
%rename(strcompspan_chari) string::string_complement_span(char *,int );
%rename(strcompspan_struct_stringi) string::string_complement_span(struct string &,int );
%rename(stringspan_struct_stringi) string::string_span(struct string &,int );
%rename(stringstring_struct_string_char) string::string_string(struct string &,char *);
%rename(stringstring_structstring_structstring) string::string_string(struct string &,struct string &);
%rename(filewrite_string_char) string::filewrite(string &,char *);
%rename(strprint_structstring_char_char) strprint(struct string &,char *,char *);
%rename(strprint_structstring_int_char_char) strprint(struct string &,int ,char *,char *);
%rename(simulated_annealing_6args) simulated_annealing::simulated_annealing(struct variablelist *,struct basisfile *,struct evaluate *,int ,double ,struct string *);
%rename(string_int_char) string::string(int ,char *);
%rename(string_char_char) string::string(char *,char *);
%rename(string_string_char) string::string(string &,char *);


%include simanneal.h
%include calculate.h
%include evaluate.h
%include safe_string.h
%include calculate.h




--------------030800020909010209070602
Content-Type: text/html;
 name="simannealfile.plg"
Content-Transfer-Encoding: 8bit
Content-Disposition: inline;
 filename="simannealfile.plg"

<html>
<body>
<pre>
<h1>Erstellungsprotokoll</h1>
<h3>
--------------------Konfiguration: simannealfile - Win32 Debug--------------------
</h3>
<h3>Befehlszeilen</h3>
Erstellen der temporären Datei  "C:\DOKUME~1\MKONER~1\LOKALE~1\Temp\RSP137.bat" mit Inhalten
[
@echo off
echo In order to function correctly, please ensure the following environment variables are correctly set:
echo PYTHON_INCLUDE: %PYTHON_INCLUDE%
echo PYTHON_LIB: %PYTHON_LIB%
echo on
swig -python -c++ -o .\simannealfile_wrap.cpp .\simannealfile.i
]
Erstellen der Befehlzeile "C:\DOKUME~1\MKONER~1\LOKALE~1\Temp\RSP137.bat"
Erstellen der temporären Datei  "C:\DOKUME~1\MKONER~1\LOKALE~1\Temp\RSP138.tmp" mit Inhalten
[
/nologo /MTd /W3 /GX /Od /I "c:\python21\include" /D "WIN32" /D "NDEBUG" /D "_WINDOWS" /D "_MBCS" /D "_USRDLL" /D "SIMANNEALFILE_EXPORTS" /Fp"Debug/simannealfile.pch" /YX /Fo"Debug/" /Fd"Debug/" /FD /GZ /c 
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\basisfile.cpp"
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\calculate.cpp"
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\evaluate.cpp"
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\safe_string.cpp"
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\simannealfile.cpp"
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\simannealfile_wrap.cpp"
"C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile\variable.cpp"
]
Creating command line "cl.exe @C:\DOKUME~1\MKONER~1\LOKALE~1\Temp\RSP138.tmp" 
SWIG Routine
In order to function correctly, please ensure the following environment variables are correctly set:
PYTHON_INCLUDE: c:\python21\include
PYTHON_LIB: c:\python21\libs\python21.lib

C:\Arbeit_Diplomarbeit\__Optimierer\TEM\simannealfile>swig -python -c++ -o .\simannealfile_wrap.cpp .\simannealfile.i 
Erstellen der temporären Datei  "C:\DOKUME~1\MKONER~1\LOKALE~1\Temp\RSP139.tmp" mit Inhalten
[
kernel32.lib user32.lib gdi32.lib winspool.lib comdlg32.lib advapi32.lib shell32.lib ole32.lib oleaut32.lib uuid.lib odbc32.lib odbccp32.lib c:\python21\libs\python21.lib /nologo /dll /incremental:no /pdb:"Debug/simannealfile.pdb" /machine:I386 /out:"simannealfile.dll" /implib:"Debug/simannealfile.lib" /libpath:"C:\Python21\libs" 
.\Debug\basisfile.obj
.\Debug\calculate.obj
.\Debug\evaluate.obj
.\Debug\safe_string.obj
.\Debug\simannealfile.obj
.\Debug\simannealfile_wrap.obj
.\Debug\variable.obj
]
Erstellen der Befehlzeile "link.exe @C:\DOKUME~1\MKONER~1\LOKALE~1\Temp\RSP139.tmp"
<h3>Ausgabefenster</h3>
Kompilierung läuft...
basisfile.cpp
calculate.cpp
evaluate.cpp
safe_string.cpp
simannealfile.cpp
simannealfile_wrap.cpp
variable.cpp
Linker-Vorgang läuft...
   Bibliothek Debug/simannealfile.lib und Objekt Debug/simannealfile.exp wird erstellt



<h3>Ergebnisse</h3>
simannealfile.dll - 0 Fehler, 0 Warnung(en)
</pre>
</body>
</html>

--------------030800020909010209070602
Content-Type: text/plain;
 name="simannealfile.py"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="simannealfile.py"

#import string,re,sys,glob,operator
import simannealfile

#instance1=simannealfile.simulated_annealing

#print 'test=',instance1


--------------030800020909010209070602
Content-Type: text/plain;
 name="variable.cpp"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="variable.cpp"

#include "variable.h"
#include "basisfile.h"

variable::variable () {
  sv = NULL;
  dprecision = 6;
  type = '0';
}

variable::variable (char t) {
  init (t);
}

variable::variable (double d, int prec) {
  init (d, prec);
}

variable::variable (int i) {
  init (i);
}

variable::variable (struct string &s) {
  init (s);
}

variable::~variable () {
}


void variable::init (char t) {
  type = t;
  sv = NULL;
}

void variable::init (double d, int prec) {
  sv = NULL;
  dv = d;
  dprecision = prec;
  type = 'd';
}

void variable::init (int i) {
  sv = NULL;
  iv = i;
  type = 'i';
}

void variable::init (struct string &s) {
  sv = new struct string;
  sv->copy (s);
  type = 's';
}

struct variable &variable::operator= (struct variable &v) {
  (*this).type = v.type;
  switch (v.type) {
  case 'd':
    (*this).dv = v.dv;
    (*this).dprecision = v.dprecision;
    break;
  case 'i':
    (*this).iv = v.iv;
    break;
  case 's':
    (*this).sv = new struct string;
    (*this).sv->copy (*(v.sv));
    break;
  default:
    printf ("&variable::operator= (struct variable &v):\n ");
    printf ("Unknown type `%c'.\n", v.type);
    exit (1);
    break;
  }
  return *this;
}

int variable::copy (struct string &s) {
  char *str;
  s.out (&str);
  switch (type) {
  case 'd' : /* double value */
    if (!sscanf(str, "%lf", &dv)) {
      printf ("variable::copy (struct string &s):\n ");
      printf ("Error while reading double value in from string:\n ");
      strprint (s, "`", "'\n");
      return 1;
    }
    break;
  case 'i' : /* integer value */
    if (!sscanf(str, "%d", &dv)) {
      printf ("variable::copy (struct string &s):\n ");
      printf ("Error while reading integer value in from string:\n ");
      strprint (s, "`", "'\n");
      return 1;
    }
    break;
    break;
  case 's' : /* string value */
    sv = new struct string (s);
    break;
  default :
    printf ("variable::copy (struct string &s):\n ");
    printf ("Unknown type of variable `%c'.\n", type);
    return 1;
  }
  return 0;
}

simanneal_parameter::simanneal_parameter () {
  dx = NULL;
}

simanneal_parameter::~simanneal_parameter () {
  if (dx) {
    delete dx;
    dx = NULL;
  }
}

variablelist::variablelist () {
  next = NULL;
  text = NULL;
  x_now = NULL;
  x_opt = NULL;
  x_min = NULL;
  x_max = NULL;
  sap = NULL;
}

variablelist::~variablelist () {
  clean ();
}

void variablelist::clean () {
  clean (this);
}

void variablelist::clean (struct variablelist *vl) {
  if (vl) {
    if (vl->next) {
      clean (vl->next);
      vl->next = NULL;
    }
    preseparator.clean ();
    pastseparator.clean ();
    if (x_opt) {
      delete x_opt;
      x_opt = NULL;
    }
    if (x_now) {
      delete x_now;
      x_now = NULL;
    }
    if (x_min) {
      delete x_min;
      x_min = NULL;
    }
    if (x_max) {
      delete x_max;
      x_max = NULL;
    }
    if (text) {
      delete text;
      text = NULL;
    }
    if (sap) {
      delete sap;
      sap = NULL;
    }
  }
}

int variablelist::pt2xn (int n) {
  int i=0;
  struct variablelist *help = this;
  
  while (help && i<n) {
    if (help->x_now->copy (help->text->parameter_text)) {
      printf ("variablelist::pt2xn (int n):\n ");
      printf ("Error while copying parameter_text to x_now.\n");
      return 1;
    }
    help = help->next;
    i++;
  }
  return 0;
}

int read_double (double &dv, struct variable *v) {
  if (v->type == 'd') {
    dv = v->dv;
    return 0;
  }
  printf ("read_double:\n");
  printf (" variable contains `%c'-value instead of double (`d').\n", v->type);
  return 1;
}


int random_step (struct variable *point, struct variable *intervall) {
  double p, i;
  switch (point->type) {
  case 'd' : /* double value */
    if (read_double(p, point)) {
      printf("random_step:\n Error while reading point.\n");
      return 1;
    }
    if (read_double(i, intervall)) {
      printf("random_step:\n Error while reading intervall.\n");
      return 1;
    }
    point->dv = point->dv - i + 2*i*rand()/RAND_MAX; 
    break;
  case 'i' : /* integer value */
    printf ("random_step:\n Stepping with integers isn't implemented yet.\n");
    return 1;
    break;
  case 's' : /* string value */
    printf ("random_step:\n Stepping with strings isn't implemented yet.\n");
    return 1;
    break;
  default :
    printf ("random_step:\n Unknown type of point `%c'.\n", point->type);
    return 1;
  }
  return 0;
}

int smaller (struct variable *v1, struct variable *v2) {
  switch (v1->type) {
  case 'd' : /* double value */
    double d2;
    if (read_double(d2, v2)) {
      printf("smaller:\n Error while reading v2.\n");
      return -1;
    }
    return (v1 < v2);
    break;
  case 'i' : /* integer value */
    printf ("smaller:\n Comparison with integers isn't implemented yet.\n");
    return -1;
    break;
  case 's' : /* string value */
    printf ("smaller:\n Comparison with strings isn't implemented yet.\n");
    return -1;
    break;
  default :
    printf ("smaller:\n Unknown type of v1 `%c'.\n", v1->type);
    return -1;
  }
  return 0;
}

int greater (struct variable *v1, struct variable *v2) {
  switch (v1->type) {
  case 'd' : /* double value */
    double d2;
    if (read_double(d2, v2)) {
      printf("greater:\n Error while reading v2.\n");
      return -1;
    }
    return (v1 > v2);
    break;
  case 'i' : /* integer value */
    printf ("greater:\n Comparison with integers isn't implemented yet.\n");
    return -1;
    break;
  case 's' : /* string value */
    printf ("greater:\n Comparison with strings isn't implemented yet.\n");
    return -1;
    break;
  default :
    printf ("greater:\n Unknown type of v1 `%c'.\n", v1->type);
    return -1;
  }
  return 0;
}

--------------030800020909010209070602
Content-Type: text/plain;
 name="variable.h"
Content-Transfer-Encoding: 7bit
Content-Disposition: inline;
 filename="variable.h"

#ifndef VARIABLE_H
#define VARIABLE_H

#include "safe_string.h"

struct variable {
  variable ();
  variable (char t);
  variable (double d, int prec = 6);
  variable (int i);
  variable (struct string &s);
  ~variable ();

  struct variable &operator = (struct variable &v); 

  void init (char t);
  void init (double d, int prec = 6);
  void init (int i);
  void init (struct string &s);
  
  int copy (struct string &s);

  char type;
  double dv;
  int dprecision;
  int iv;
  struct string *sv;
};

struct simanneal_parameter {
  simanneal_parameter ();
  ~simanneal_parameter ();

  /* maximum of deviation from actual x */
  struct variable *dx;
};

struct variablelist {
  variablelist ();
  ~variablelist ();

  void clean ();
  void clean (struct variablelist *vl);

  int number;
  int linenumber;
  int position;
  struct string preseparator;
  struct string pastseparator;
  struct string *x_opt;
  struct variable *x_now;
  struct variable *x_min;
  struct variable *x_max;
  struct filetext *text;

  struct variablelist *next;

  /* parameter for simulated annealing for one variable. */
  struct simanneal_parameter *sap;

  /* copies parametertext's to x_now for n variables.*/
  int pt2xn (int n);
};

int read_double (double &dv, struct variable *v);
int smaller (struct variable *v1, struct variable *v2);
int greater (struct variable *v1, struct variable *v2);
/* builds new point from point and intervall randomly.  New point is
   inside intervall [point-intervall; point+intervall]. */
int random_step (struct variable *point, struct variable *intervall);
void print (struct variablelist *vl);
#endif

--------------030800020909010209070602--