Search EggHeadCafe's Job Board
EggHeadCafe Silverlight WPF ASP.NET VB.NET C# Excel SQL Server SharePoint
search
MicrosoftArticlesForumsFAQs
C# .NET
VB.NET
Visual Studio .NET
ADO.NET
Xml / Xslt
VB 6.0
.NET CF
GDI+
LINQ
Deployment
Security
FoxPro
Silverlight / WPF
Entity Framework
RIA Services

WebArticlesForumsFAQs
JavaScript
ASP
ASP.NET
WCF

DatabasesArticlesForumsFAQs
SQL Server
Access
Oracle
MySQL
Other Databases

OfficeArticlesForumsFAQs
Excel
Word
Powerpoint
Outlook
Publisher
Money

Non-MicrosoftArticlesForumsFAQs
NHibernate
Perl
PHP
Ruby
Java
Linux / Unix
Apple
Open Source

Operating SysArticlesForumsFAQs
Windows 7
Windows Server
Windows Vista
Windows XP
Windows Update
MAC
Linux / UNIX

Server PlatformsArticlesForumsFAQs
BizTalk
Site Server
Exhange Server
IIS

Graphic DesignArticlesForumsFAQs
Macromedia Flash
Adobe PhotoShop
Expression Blend
Expression Design
Expression Web

OtherArticlesForumsFAQs
Lounge
Subversion / CVS
Ask Dr. Dotnetsky
Active Directory
Networking
Uninstall Virus
Job Openings
Product Reviews
Search Engines
Resumes

 

  View Other C# .NET Posts   Ask New Question  Ask New Question With Power Editor

Interaction of variables on each other (C++)
Amir mimi posted at Friday, November 06, 2009 10:52 PM





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.

Reply    Reply Using Power Editor
  Rank Winnings Points
November 0 $0.00 0
October 0 $0.00 0