您在谈论 CPM - 关键路径方法。
评估每个条件类型(完成到开始,...)是一个简单的选择 - 案例。
您需要先评估早期日期,然后再评估后期日期。这决定了关键路径。
如果您的算法包括针对某些任务的 ASAP - ALAP,您可以评估 Scheduled Dates 附加通过。
我对每个通道使用递归算法(早期日期,最新日期......)。这会发现条件循环并显示它们(Task1 -> Task2 -> Task1)。
CPM 最简单的任务是日历管理。
没有那个函数
Date1 = Calendar.Eval_DateFinish(Start, Duration)
成为基于资源日历间隔的函数。
这是我的早期约会功能。
Private Sub cpm_fmte(ByVal n As Int32)
Dim a = Actividades(n), fi, f As FechaCpm, ncit As Integer = 0
fi.value = Integer.MinValue
Dim cal As Calend = a.Cal, dur As Integer = a.dur
sw(n) = 255 : RaBucle.Add(a) 'Marco la actividad para detectar bucle condicionantes
For Each c In a.Predecesoras '/* calcular predecesoras */
If c._Act >= nHitos Then
If c._Act < nTResumen Then Continue For
Select Case sw(c._Act)
Case 0 : cpm_fmte(c._Act)
Case 255 : ShowBucle(c._Act) : Throw New Exception("Cpm_ftme: Error - Bucle Condicionantes")
'case Else - 1 - Ya calculada anteriormente
End Select
End If
Dim Pred = Actividades(c._Act)
Select Case c.Tipo
Case "D"c : f.value = Pred.ffmte.value + c.Demora
Case "I"c : f.value = Pred.fimte.value + c.Demora : ncit += 1
Case "T"c : f = cal.Calc_Fi(Pred.ffmte + c.Demora, dur) : ncit += 1
Case Else : Throw New Exception(String.Format("Error condic.: {0} {1} {2} {3} {4}", _
a.Id, c.Tipo, Pred.Id, c.Demora))
End Select
If f > fi Then fi = f
Next
RaBucle.Count -= 1
If fi.value = Integer.MinValue Then fi = Proyecto.Actprj.FechaPrj
If dur > 0 Then fi = cal.Fecha_Jla_Av(fi)
a.fimte.value = fi.value : a.ffmte = cal.Calc_Ff(fi, dur)
a.Fip = a.fimte : a.Ffp = a.ffmte
If a.ffmte.value > Fmax.value Then mfmax.value = a.ffmte.value
If a.fimte.value < Fmin.value Then mFmin.value = a.fimte.value
sw(n) = 1 'Actividad calculada
End Sub
注释。那我是西班牙人:
- Fmte -> 早期日期(Fechas más Tempranas),Fmta -> 最新日期,Fp - 预定。
- Fi -> 开始日期 (Fecha Inicio), FF -> 完成日期 (Fecha Fín)
- Actividades - 任务
- “D”c ->(完成 - 开始),“Después”,
- “I”c ->(开始 - 开始)“Inician...”
- “T”c ->(完成 - 完成)“Terminan ...”
- 从未使用过开始 - 结束条件。
我使用 FechaCpm 类型(结构),它评估为 Int32 类型 (FechaCpm.Value) 并解释为分钟时间间隔单位。
您可以在 SourceForge 上获得更多 CPM 代码,但我在 Net 上从未找到任何代码。
您可以看到“Open WorkBench” - Java 或“Planner” - C++。
我的代码基于 CPM,大多数规划程序都是基于资源的支持 CPM。
我只使用一种资源(人力资源),然后日历是一个任务属性。