Note that there are some explanatory texts on larger screens.

plurals
  1. POAccess Violation
    primarykey
    data
    text
    <p>Greetings everyone, going to need some help in clearing this exception.</p> <p>I get the following when debugging my compiled program in Microsoft Visual C++ 6.0:</p> <pre><code>Loaded 'ntdll.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\kernel32.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\tsappcmp.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\msvcrt.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\advapi32.dll', no matching symbolic information found. Loaded 'C:\WINDOWS\system32\rpcrt4.dll', no matching symbolic information found. First-chance exception in SA.exe: 0xC0000005: Access Violation. </code></pre> <p>Here are the relevant screenshots from the debugger.</p> <p>Showing ostream.h:</p> <p>http://img237.imageshack.us/my.php?image=accessviolation.png'>http://img237.imageshack.us/img237/1116/accessviolation.th.png' border='0'/></p> <p>Showing main.ccp:</p> <p>http://img509.imageshack.us/my.php?image=accessviolation2.png'>http://img509.imageshack.us/img509/3619/accessviolation2.th.png' border='0'/></p> <p>I've tried to scour my code for null pointers and have also tried to ignore the exception with no luck. Here are the three main components of my script:</p> <p>main.ccp</p> <pre><code>#include &lt;iostream&gt; #include "SA.h" using namespace std; // For the use of text generation in application int main() { SimAnneal Go; cout &lt;&lt; "Quadratic Function" &lt;&lt; endl &lt;&lt; "Solving method: Simulated Annealing" &lt;&lt; endl; cout &lt;&lt; "\nSelect desired Initial Temperature:" &lt;&lt; endl &lt;&lt; "&gt; "; cin &gt;&gt; Go.T_initial; cout &lt;&lt; "\nSelect desired number of Temperature Iterations:" &lt;&lt; endl &lt;&lt; "&gt; "; cin &gt;&gt; Go.N_max; cout &lt;&lt; "\nSelect desired number of step Iterations:" &lt;&lt; endl &lt;&lt; "&gt; "; cin &gt;&gt; Go.N_step; cout &lt;&lt; "\nSelect desired Absolute Temperature:" &lt;&lt; endl &lt;&lt; "&gt; "; cin &gt;&gt; Go.T_abs; Go.LoadCities(); Go.Initialize(); Go.SA(); system ("PAUSE"); return 0; } </code></pre> <p>SA.h</p> <pre><code> #ifndef SA_H #define SA_H class SimAnneal { double S_order [15]; double S_trial [15]; int SwapNum1; int SwapNum2; double CityArray [15][15]; double E_initial; double E_current; double T; void Metropolis (double, int, int); void Next_State (double, int); double Schedule (double, int); double ObjFunction (double CityOrder []); void EquateArray (); void OrderInt (); void OrderTrial (); void OrderList (double array[]); void WriteResults (double, double, double, double, double); public: int N_step; int N_max; double T_initial; double T_abs; void SA (); void Initialize (); void LoadCities (); }; double Random_Number_Generator(double nHigh, double nLow); #endif </code></pre> <p>SA.cpp</p> <pre><code>#include &lt;math.h&gt; #include &lt;iostream&gt; #include &lt;fstream&gt; #include &lt;iterator&gt; #include &lt;iomanip&gt; #include &lt;time.h&gt; #include &lt;cstdlib&gt; #include "SA.h" using namespace std; void SimAnneal::SA() { T = T_initial; E_current = E_initial; for ( int N_temperatures = 1 ; N_temperatures &lt;= N_max ; N_temperatures++ ) { Metropolis(T, N_step, N_temperatures); T = Schedule(T, N_temperatures); if (T &lt;= T_abs) break; } cout &lt;&lt; "\nResults:" &lt;&lt; endl &lt;&lt; "Distance&gt; " &lt;&lt; E_current &lt;&lt; endl &lt;&lt; "Temperature&gt; " &lt;&lt; T &lt;&lt; endl; OrderList(S_order); } void SimAnneal::Metropolis(double T_current, int N_Steps, int N_temperatures) { for ( int i=1; i &lt;= N_step; i++ ) Next_State(T_current, N_temperatures); } void SimAnneal::Next_State (double T_current, int i) { OrderTrial(); double EXP = 2.718281828; double E_t = ObjFunction(S_trial); double E_c = ObjFunction(S_order); double deltaE = E_t - E_c; if ( deltaE &lt;= 0 ) { EquateArray(); E_current = E_t; } else { double R = Random_Number_Generator(1,0); double Ratio = 1-(float)i/(float)N_max; double ctrl_pram = pow(EXP, (-deltaE / T_current)); if (R &lt; ctrl_pram*Ratio) { EquateArray(); E_current = E_t; } else E_current = E_c; } } double SimAnneal::Schedule (double Temp, int i) { double CoolingRate = 0.9999; return Temp *= CoolingRate; } double SimAnneal::ObjFunction (double CityOrder []) { int a, b; double distance = 0; for (int i = 0; i &lt; 15 - 1; i++) { a = CityOrder [i]; b = CityOrder [i + 1]; distance += CityArray [a][b]; } return distance; } void SimAnneal::Initialize () { int a, b; double distance = 0; OrderInt(); for (int i = 0; i &lt; 15 -1; i++) { a = S_order [i]; b = S_order [i + 1]; distance += CityArray [a][b]; } E_initial = distance; } void SimAnneal::EquateArray () { for (int i = 0; i &lt; 15; i++) { S_order [i] = S_trial [i]; } } void SimAnneal::OrderInt () { for (int i = 0; i &lt;15; i++) { S_order [i] = i; } } void SimAnneal::OrderTrial () { for (int i = 0; i &lt; 15; i++) { S_trial [i] = S_order [i]; } SwapNum1 = (int)Random_Number_Generator(15, 0); SwapNum2 = (int)Random_Number_Generator(15, 0); for (int n = 0; n &lt;= 100000; n++) { SwapNum2 = (int)Random_Number_Generator(15, 0); if ( SwapNum1 != SwapNum2 ) break; } S_trial [SwapNum1] = S_order [SwapNum2]; S_trial [SwapNum2] = S_order [SwapNum1]; } void SimAnneal::OrderList (double array[]) { cout &lt;&lt; "Array List : " &lt;&lt; endl; for (int i = 0; i &lt; 15; i++) { cout &lt;&lt; " &gt; " &lt;&lt; array[i] &lt;&lt; endl; } cout &lt;&lt; "End of array" &lt;&lt; endl; } void SimAnneal::LoadCities () { int x, y; for (y = 0; y &lt; 15; y++) { for (x = 0; x &lt; 15; x++) { if (x == y) { CityArray[x][y] = 0.0; } else if (x != y) { CityArray[x][y] = Random_Number_Generator(7, 1); } } } for (y = 0; y &lt; 15; y++) { for (x = 0; x &lt; 15; x++) { if (y &gt; x) CityArray[y][x] = CityArray[x][y]; } } } double Random_Number_Generator(double nHigh, double nLow) { double fr = ((rand() % ((int)nHigh*1000 - (int)nLow*1000 + 1)) + nLow) / 1000; return fr; } </code></pre> <p>Any Assistance would be much appriciated. I'm all out of ideas myself.</p>
    singulars
    1. This table or related slice is empty.
    plurals
    1. This table or related slice is empty.
    1. This table or related slice is empty.
    1. This table or related slice is empty.
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload