0
votes

would it be possible to write vba code for genetic algorithm in MSP as like as excel ?

I want to optimize the duration of project's tasks according to minimize total cost, for this aim I need to run genetic algorithm to change duration of each task randomly, if i can write this algorithm with Vba in microsoft project, MSP will level resources based on new duration of each task and by new total duration of project, I can calculate the new cost.

I know there are vba genetic codes available for optimization in excel, is it possible to write the same code in Vba of MSP ?

if it is not, what about exporting data from MSP and importing them to excel for running the algorithm and then at the same time importing that data to MSP again?

thanks a lot,

1
Excel and Optimize are rarely in the same sentence! You could certainly make almost any algorithm in excel, but surely going a little further and using vb.net would increase performance drastically.Davesoft
i'm agree that it would be better to use vb net for running these algorithms but as i want to interact with ms project simultaneously, i'm likely to use vba in MS project and if it doesn't work, is it easier to import data from MS project in excel or vb net for running the algorithm?Maziyar khadivi
MS Project has VBA and its own Object Model. If you have an example to a Genetic Optimization algorithm in Excel VBA, then porting it to Project should be possible. It all depends on how extensively it uses the Excel Object Model and how hard that is to translate to Project (hopefully only the data handling)chris neilsen

1 Answers

0
votes

I want to optimize the duration of project's tasks according to minimize total cost, for this aim I need to run genetic algorithm to change duration of each task randomly

Yes, you can do this in MS Project using VBA (Task object methods and properties). And you need to do this in MS Project since you rely on Project's CPM engine and leveling capabilities.

Algorithm

  1. Loop through all tasks and change duration to random number. Skip Summary tasks as Duration is read-only and skip tasks that are complete, and optionally skip tasks that have already started.
  2. Level the resources.
  3. Calculate total cost.
  4. Store the durations for all tasks in the Duration1 field and store the total cost in the Cost1 of the first task.
  5. Repeat steps 1-4 nine times, storing the durations in Duration2-Duration10 and total cost in Cost2-Cost10.
  6. Determine the iteration that had the lowest cost and move those durations to the Duration1 field.
  7. Repeat steps 5-6 until cost is optimized sufficiently.
  8. Move the durations from the Duration1 field to the Duration field skipping tasks per Step 1.