First fit

Résolu
hadhoud2000 Messages postés 3 Date d'inscription jeudi 26 mars 2009 Statut Membre Dernière intervention 2 avril 2009 - 27 mars 2009 à 14:59
n@ss91 Messages postés 11 Date d'inscription dimanche 3 février 2013 Statut Membre Dernière intervention 4 décembre 2014 - 4 déc. 2014 à 02:43
bonjour,
j'ai besoin du code source de l'algorithme First fit(en c ou en vb ou en Matlab)

First fit=algorithme de calcul de longueur d'onde disponible dans un reseau
merci
A voir également:

5 réponses

Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
28 mars 2009 à 13:46
Private Sub FirstFit()
'Checks to make sure everything is initialized
If Elements Is Nothing Then Exit Sub

Dim ElementsCopy(Elements.GetUpperBound(0)) As Integer
ReDim Bins(0)
'Bin Number we are on, Bin Element we are on, Amount placed in the current Bin
Dim BinNumber, BinElement, BinCount As Integer
Dim i, j, k As Integer

'Make a copy of the array incase we need to sort it
DeepCopyArray(Elements, ElementsCopy)

'Sort in descending order if needed
If Me.Decreasing = True Then
Array.Sort(ElementsCopy)
Array.Reverse(ElementsCopy)
End If

'Declare the first element in the first Bin
ReDim Bins(0)(0)

'Loop through each Element and place in a Bin
For i = 0 To ElementsCopy.GetUpperBound(0)
Dim bPlaced As Boolean = False

'Loops through each Bin to find the first available spot
For j = 0 To BinNumber
BinElement = Bins(j).GetUpperBound(0)

'Count the amount placed in this Bin
BinCount = 0
For k = 0 To BinElement
BinCount += Bins(j)(k)
Next

If BinCount + ElementsCopy(i) <= Me.BinHeight Then
'There's room for this Element
ReDim Preserve Bins(j)(BinElement + 1)
Bins(j)(BinElement) = ElementsCopy(i)

bPlaced = True
Exit For
Else
'There's not room for this Element in this Bin
End If
Next

'There wasn't room for the Element in any existing Bin
'Create a new Bin
If bPlaced = False Then
'Add another Bin
ReDim Preserve Bins(BinNumber + 1)
BinNumber += 1

'Initialize first element of new bin
ReDim Bins(BinNumber)(1)
BinElement = 0

Bins(BinNumber)(BinElement) = ElementsCopy(i)

End If
Next

'All Elements have been place, now we go back and remove unused Elements
For i = 0 To BinNumber
For j = 0 To Bins(i).GetUpperBound(0)
If Bins(i)(j) = 0 Then
ReDim Preserve Bins(i)(j - 1)
End If
Next
Next

GC.Collect()
End Sub
3
Duke49 Messages postés 552 Date d'inscription jeudi 12 octobre 2006 Statut Non membre Dernière intervention 24 janvier 2023 4
27 mars 2009 à 15:19
0
hadhoud2000 Messages postés 3 Date d'inscription jeudi 26 mars 2009 Statut Membre Dernière intervention 2 avril 2009
28 mars 2009 à 13:32
merci pour ton aide ,mais ce document jle connais,
j'ai besoin d'un programme "firstfit" écrit en C/C++/VB/Matlab
0
hadhoud2000 Messages postés 3 Date d'inscription jeudi 26 mars 2009 Statut Membre Dernière intervention 2 avril 2009
2 avril 2009 à 14:05
merci bcp
0

Vous n’avez pas trouvé la réponse que vous recherchez ?

Posez votre question
n@ss91 Messages postés 11 Date d'inscription dimanche 3 février 2013 Statut Membre Dernière intervention 4 décembre 2014
4 déc. 2014 à 02:43
Salut hadhoud2000

Est ce possible d'avoir le code source de First Fit en Matlab?

Merci.
0
Rejoignez-nous