I am a beginner in VB.Net. As a part of my studies, I am programming an iterative algorithm, called Tabu Search, to solve an optimization problem. At each iteration, one or several variables of the current best solution is changed to develop new solutions for the same problem. Depending on the quality of the solution found by this move, we might want to stop repeating it in the future iterations or promote advancing it. A list, called tabu list, keeps records of the quality of moves performed so far and the number of future iterations that these move should be either avoided or promoted.
I have defined the tabu list as a dictionary. My question is: How to keep the size of dictionary fixed while updating it at each iteration?
Lets say I want to only keep the last 30 items added to this dictionary. So when the item 31 is added, item 1 should be dropped out of the dictionary.
Here is a part of my code.
Public Class Move
Private mType As String
Private mTarget As DC
Property Type() As String
Get
Return mType
End Get
Set(value As String)
mType = value
End Set
End Property
Property TargetVariable() As VaiableDC
Get
Return mTarget
End Get
Set(value As VaiableDC)
mTarget = value
End Set
End Property
Part of the main algorithm**
Dim MoveTabuDic As New Dictionary(Of Move, UShort)
'****removed steps****
Dim aMove as new Move
'****removed steps****
MoveTabuDic .add(aMove,IterationID)
Thanks!