I have an optimization problem where there is $ n $ activities and

I want to find an optimal schedule for these activities.

The calendar is specified as $ S = ( mathbf {t}, p) $ or:

- $ mathbf {t} = left (t_ {1}, dots, t_ {n} right) $ specifies the allocated times

activities - $ p $ is the order of the activities, so is a member of the whole

permutations on $ n $ elements.

The constraint is mainly that there is a total time finite, so $ sum {} _ {i = 0} ^ {n} t_ {i} = T $. There is also the constraint that for all $ i $, $ t_ {i}> $ 0.

The objective function, to maximize, is $ F ( mathbf {t}, p) $; to keep the question brief, I'm going to mention the form of $ F $, in case it is relevant, after the question.

The question is how to integrate this problem of optimization in Mathematica. There would be dozens of variables, so I can not go through all the permutations, but a heuristic / local search algorithm would probably do a great job; I do not need the global maximum.

My main problem is with $ p $, namely put in the order of the activities. Without the order, I can put it in Mathematica with NMaximize as follows:

```
NMaximize[
{
u1[t1]+ u2[t2]+ u3[t3],
{t1 + t2 + t3 == 365, t1> 0, t2> 0, t3> 0}
}, {t1, t2, t3}
]
```

I just showed an example with 3 variables for brevity, but I can do the same thing with dozens of variables and it seems to work well.

**Additional idea**: Another way to model it is to specify $ 2n $ variables, a start time and an end time for each activity, and somehow produce all the constraints that two activities should not overlap. This would eventually leave the time off without activity, but it should be fine.

**Information on the form of $ F $ (in case this is relevant)**

$$

F ( mathbf {t}, p) = sum limits_ {i = 0} ^ {n} left (u_ {i} left (t_ {i} right) -p_ {i} left (s_ {i} right) right)

$$

or:

- $ u_ {i} $ is a utility / benefit to put $ t_ {i} $ time of activity $ i $; I will specify it for each activity and it would be a monotonically but non-linear growth function in general.
- $ s_ {i} $ is the start time of the activity $ i $, which is equivalent to the sum

of $ t_ {i} $ for the activities that precede it (according to the

order specified by $ p $). So, $ s_ {i} $ depends on both $ p $ and $ mathbf {t} $. - $ p_ {i} $ is a penalty function that gives a decrease in utility / benefit due to the delay of the activity $ s_ {i} $ time.