Hello Ana,
To adapt your simulated annealing code from solving a backpack optimization problem to a task sequencing problem, you may follow the below steps:
- Backpack Problem: Typically involves items with weights and values, and a capacity constraint. The objective is to maximize value while staying within weight capacity. The constraint is the weight capacity limit.
- Task Sequencing Problem: Involves tasks that need to be scheduled on machines to minimize the total completion time. The objective is to minimize the total time to complete all tasks. The constraint says that all tasks must be scheduled, respecting the order and machine constraints.
Steps to Adapt the Code:
- Define the Problem Parameters: Read the task and machine data from your Excel file. Define a matrix where rows represent tasks and columns represent machines, with each entry being the time to complete a task on a machine.
- Objective Function: Implement a function that calculates the total completion time for a given task sequence.
- Simulated Annealing Algorithm: Modify the solution representation to be a sequence of tasks. Adjust the "neighbor" generation function to swap tasks or alter the sequence.
I hope this helps!