I defined some variables in
the form of array but after some calculation the value of some other variables
changes without any reason. I will give you an example.Please look at the
following part of my programm:
#include <iostream>
#include <stdio.h>
#include <math.h>
using std::cout;
using std::endl;
int main()
{
int i,j,k, index;
const int
arc=6, path=4;
double mi,delta,
dif[3],teta[3],p,q,r,demand, A[arc], B[arc],fa[2][arc],ca[2][arc], cp[path],
h[2][path], d[arc];
//Set Parameters
A[1]=5;
A[2]=10;
A[3]=100;
A[4]=10;
A[5]=5;
B[1]=0.2;
B[2]=0.1;
B[3]=5;
B[4]=0.1;
B[5]=0.2;
demand=10;
//Set initial
soloution
k=0;
h[1][1]=3;
h[1][2]=3;
h[1][3]=4;
fa[1][1]=h[1][1]+h[1][3];
fa[1][2]=h[1][2];
fa[1][3]=h[1][3];
fa[1][4]=h[1][1];
fa[1][5]=h[1][2]+h[1][3];
printf ("Iteration 0:
//Start FW
algorithm
do
{
k=k+1;
//Compute cost
of arcs
for
(i=1;i<6;i++)
{
ca[1][i]=A[i]+B[i]*fa[1][i]*fa[1][i];
}
//Compute cost
of paths
cp[1]=ca[1][1]+ca[1][4];
cp[2]=ca[1][2]+ca[1][5];
cp[3]=ca[1][1]+ca[1][3]+ca[1][5];
//Find the
sortest path
if
((cp[1]<=cp[2])&&(cp[1]<=cp[3])) index=1;
if
((cp[2]<=cp[1])&&(cp[2]<=cp[3])) index=2;
if
((cp[3]<=cp[1])&&(cp[3]<=cp[2])) index=3;
for (i=1;i<4;i++)
{
h[2][i]=0;
}
//Assign all
demand to the shortest path
h[2][index]=demand;
//Find LP path
soloution
fa[2][1]=h[2][1]+h[2][3];
fa[2][2]=h[2][2];
fa[2][3]=h[2][3];
fa[2][4]=h[2][1];
fa[2][5]=h[2][2]+h[2][3];
...
At this point when fa[2][i]
are computed, the value of B[i] changes without any reason and if I fixed the
value of B[i] again, the value of fa[2][i] changes. I do not know what is wrong
with my programming.Could you please hel me.