Bonjour tous,

Je cherche un code source concernant le problème de transport par primal dual (optimisation des coûts !).
En effet, cet algorithme m'aidera à réaliser mon projet qui consiste à optimiser les attribution des modules sur les professeurs.
voici un code sur C qui ne donne pas les résultats attendus :
-----------------------------------------------------------------
Code : Sélectionner tout - Visualiser dans une fenêtre à part
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
#include<stdio.h>
#include<iostream.h>
#include<conio.h>
 
main()
{
int flag=0,flag1=0;
int s[10],d[10],sn,eop=1,dm,a[10][10];
int i,j,sum=0,min,x[10][10],k,fa,fb;
 
system("clr");
			 /* Getting The Input For the Problem*/
 
printf("Enter the number of Supply");
scanf("%d",&sn);
printf("Enter the number of Demand");
scanf("%d",&dm);
printf("Enter the Supply Values");
for(i=0;i<sn;i++)
scanf("%d",&s[i]);
printf("Enter the Demand Values");
for(j=0;j<sn;j++)
scanf("%d",&d[j]);
printf("Enter the elements of the array");
for(i=0;i<sn;i++)
 {
  for(j=0;j<dm;j++)
   {
     scanf("%d",&a[i][j]);
     }
 }
		 /* Calculation For the Transportation */
 i=0;j=0;
 for(i=0,j=0;i<sn,j<dm;)
  {
    if(s[i]<d[j])          // Check supply less than demand
     {
      x[i][j]=a[i][j]*s[i];  // Calculate  amount * supply
      d[j]=d[j]-s[i];        // Calculate demand - supply
      i++;                  // Increment i for the deletion of the row  or column
     }
   else if(s[i]>=d[j])   //Check the supply greater than equal to demand
    {
    x[i][j]=a[i][j]*d[j];      // Calculate  amount * demand
    s[i]=s[i]-d[j];           // Calculate supply - demand
    j++;                     // Increment j for the deletion of the row or column
    }
 
  }
  /* The  Cost Matrix is Estimated here */
  printf("Given Cost Matrix is :");
   for(fa=0;fa<sn;fa++)
    {
      for(fb=0;fb<dm;fb++)
       {
	printf("%d	",a[fa][fb]);
       }
       printf(" ");
    }
   /*  The Allocated Cost Matrix is */
 
    printf("Allocated Cost Matrix is ");
    for(fa=0;fa<sn;fa++)
     {
      for(fb=0;fb<dm;fb++)
       {
	printf("%d	",x[fa][fb]);
	 sum=sum+x[fa][fb];
       }
       printf("");
     }
    /* Transportation Cost Estimated and Sum is Printed*/
  printf("The Transportation cost:%d",sum);
  getch();
  }
----------------------------------------
J'espère que vous pourriez m'aider. Merci !