15 views

Uploaded by habibi_cr

- Software Progress Report_ Group 9
- Lecture 5
- siri1
- Array
- 2d arrays
- L22_7Segments and Arrays.pdf
- Program
- data-lec1
- Lecture01.Article 5136
- Fortran
- Les03
- Examination Java Jg 310 Sem 1 A
- Notes For Computer Science 10th Class BISE
- ch05
- Array Rotation
- Decision Making 4
- VBCSetup
- Data Driven Test Using Selenium
- c++
- instruction plan

You are on page 1of 6

If Elements Is Nothing Then Exit Sub

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 As Integer

DeepCopyArray(Elements, ElementsCopy)

If Me.Decreasing = True Then

Array.Sort(ElementsCopy)

Array.Reverse(ElementsCopy)

End If

ReDim Bins(0)(0)

For i = 0 To ElementsCopy.GetUpperBound(0)

If BinCount + ElementsCopy(i) > Me.BinHeight Then

'Remove extra, unused Element of this Bin

ReDim Preserve Bins(BinNumber)(BinElement - 1)

ReDim Preserve Bins(BinNumber + 1)

BinNumber += 1

ReDim Bins(BinNumber)(0)

BinElement = 0

BinCount = 0

End If

'Place task

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

'Keep track of how much is stored in this bin

BinCount += ElementsCopy(i)

If i < ElementsCopy.GetUpperBound(0) Then

ReDim Preserve Bins(BinNumber)(BinElement + 1)

BinElement += 1

End If

Next

GC.Collect()

End Sub

Private Sub FirstFit()

'Checks to make sure everything is initialized

If Elements Is Nothing Then Exit Sub

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

DeepCopyArray(Elements, ElementsCopy)

If Me.Decreasing = True Then

Array.Sort(ElementsCopy)

Array.Reverse(ElementsCopy)

End If

ReDim Bins(0)(0)

For i = 0 To ElementsCopy.GetUpperBound(0)

Dim bPlaced As Boolean = False

For j = 0 To BinNumber

BinElement = Bins(j).GetUpperBound(0)

BinCount = 0

For k = 0 To BinElement

BinCount += Bins(j)(k)

Next

'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

'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

'Checks to make sure everything is initialized

If Elements Is Nothing Then Exit Sub

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 WorstBin, WorstBinAmount As Integer

Dim i, j, k As Integer

DeepCopyArray(Elements, ElementsCopy)

If Me.Decreasing = True Then

Array.Sort(ElementsCopy)

Array.Reverse(ElementsCopy)

End If

ReDim Bins(0)(0)

For i = 0 To ElementsCopy.GetUpperBound(0)

WorstBin = -1

WorstBinAmount = Me.BinHeight + 1

For j = 0 To BinNumber

BinElement = Bins(j).GetUpperBound(0)

BinCount = 0

For k = 0 To BinElement

BinCount += Bins(j)(k)

Next

'Find the least full Bin that can hold this Element

If WorstBinAmount > BinCount AndAlso BinCount +

ElementsCopy(i) <= Me.BinHeight Then

WorstBinAmount = BinCount

WorstBin = j

End If

Next

If WorstBin = -1 Then

'There wasn't room for the Element in any existing Bin

'Create a new Bin

ReDim Preserve Bins(BinNumber + 1)

BinNumber += 1

ReDim Bins(BinNumber)(1)

BinElement = 0

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

Else

'There's room for this Element in an existing Bin

'Place Element in "Best Bin"

BinElement = Bins(WorstBin).GetUpperBound(0)

ReDim Preserve Bins(WorstBin)(BinElement + 1)

Bins(WorstBin)(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

'Checks to make sure everything is initialized

If Elements Is Nothing Then Exit Sub

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 BestBin, BestBinAmount As Integer

Dim i, j, k As Integer

DeepCopyArray(Elements, ElementsCopy)

If Me.Decreasing = True Then

Array.Sort(ElementsCopy)

Array.Reverse(ElementsCopy)

End If

ReDim Bins(0)(0)

For i = 0 To ElementsCopy.GetUpperBound(0)

BestBin = -1

BestBinAmount = -1

For j = 0 To BinNumber

BinElement = Bins(j).GetUpperBound(0)

BinCount = 0

For k = 0 To BinElement

BinCount += Bins(j)(k)

Next

'Find the most full Bin that can hold this Element

If BestBinAmount < BinCount AndAlso BinCount +

ElementsCopy(i) <= Me.BinHeight Then

BestBinAmount = BinCount

BestBin = j

End If

Next

If BestBin = -1 Then

'There wasn't room for the Element in any existing Bin

'Create a new Bin

ReDim Preserve Bins(BinNumber + 1)

BinNumber += 1

ReDim Bins(BinNumber)(1)

BinElement = 0

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

Else

'There's room for this Element in an existing Bin

'Place Element in "Best Bin"

BinElement = Bins(BestBin).GetUpperBound(0)

ReDim Preserve Bins(BestBin)(BinElement + 1)

Bins(BestBin)(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

- Software Progress Report_ Group 9Uploaded byAhmad Hazimeh
- Lecture 5Uploaded byAla'a Abu Haibeh
- siri1Uploaded byanvithnet
- ArrayUploaded byAnonymous IhmXvCHj3c
- 2d arraysUploaded byamandeep651
- L22_7Segments and Arrays.pdfUploaded byAhmed M H Al-Yousif
- ProgramUploaded bypebdalal
- data-lec1Uploaded byMohit Pahuja
- Lecture01.Article 5136Uploaded byMohamed EL-Fayomy
- FortranUploaded byTGODA_13
- Les03Uploaded bybanala.kalyan
- Examination Java Jg 310 Sem 1 AUploaded bylakhwinder
- Notes For Computer Science 10th Class BISEUploaded byH S Wajid Hussain
- ch05Uploaded byNeneFI
- Array RotationUploaded byAnshul
- Decision Making 4Uploaded by....
- VBCSetupUploaded byjay_siri
- Data Driven Test Using SeleniumUploaded byThiru Rao
- c++Uploaded byPrerak Dedhia
- instruction planUploaded byRohit Sahu
- Lab ManualUploaded byChandan Mishra
- ICSE Class 10 Sample Paper 4Uploaded byChirag
- CS 11 MP1 SpecificationsUploaded byPaul Rossener Regonia
- ArrayUploaded byrameshragala
- Model-Robust Factorial DesignsUploaded byJessica Li
- Maple programmingUploaded byHimraj Bachoo
- R_Programming.pptxUploaded bySrinivasan Krishnan
- ArraysUploaded bysomag83
- Class 6Uploaded byHaneesha Muddasani
- C_chap03Uploaded byDODI

- Test Your Kvpy Quotient 1Uploaded byHimansu Mookherjee
- Settheory NotationUploaded byAdolf Memeler
- Approximate Pattern Matching Using Fuzzy LogicUploaded byMauliadi
- Functional AnFunctional Analysis Lecture Notes Jeff Schenkeralysis Jeff SchenkerUploaded bynim1987
- 10. M.A.- M.Sc. Maths SyllabusUploaded bybaburaogtrw
- Skip ListsUploaded bysonal
- d2group13Uploaded byTruong Cai
- A Curvature Smoothing Hsieh–Clough–Tocher Element for Yield Design of Reinforced Concrete SlabsUploaded byPhuc Phung
- Algebra HandbookUploaded byDhiman Nath
- SS JNTU HYDUploaded bygiribabukande
- DESIGN AND DEVELOPMENT OF CSP TECHNIQUES FOR FINDING ROBUST SOLUTIONS IN JOB-SHOP SCHEDULING PROBLEMS WITH OPERATORSUploaded byforoughi9300
- Math 780 NotesUploaded byVlad Copil
- denest.pdfUploaded byararaonline
- Application of Genetic Algorithm to Pipe Network OptimizationUploaded byAlexander Hernandez
- Game TheoryUploaded bykshitijsaxena
- Visual Algebra Through SymmetryUploaded byWilliam G. Mandras
- dunnoUploaded byCasey J. Murphy
- gammaFormulasUploaded byAmur Al-Manji
- 1991 State Countdown RoundUploaded byPrecise Accuracy
- Lec_1Uploaded byJL
- Variable Gradient MethodUploaded bySudhin Pk
- Operating System Lecturer NotesUploaded bySaroj Misra
- Ahinf Norm ProofUploaded byMehmet Taner Karslı
- Calculus of Vector Valued FunctionsUploaded byDilo Tan
- Lecture 3 - Interior Point Methods and Meggido’s AlgorithmUploaded bygdenunzio
- overarching eus and eqsUploaded byapi-267873526
- Math TopicsUploaded bysureshJOHNrajagopal
- AMSP Inequalities StrategiesUploaded bykll93
- Theory of the Finite Element MethodUploaded byEric Kerr
- Spring 12 Math 106 Sample Final Key (1)Uploaded byAli Jonson