scheduling
There is not a graphing switch like there is for "sort by data spread" that would sort in the graph by start time.
What you need is a criteria that can vary only by activity, and does not depend on anything else -- i.e., if you add any indexes to any of the durations. The challenge with that is when you do what-if, you might get different starting time orderings in different scenarios. This happens, of course, in the Monte Carlo runs when your durations are also uncertain.Â
There are several possibilities for an invariant ordering, but it might not be ordered for specific scenarios where the start times are in different orders. For example, you could take the minimum starting time that occurs anywhere in the mid-value.
Once you have settled on a simple criteria to sort on, then the most obvious thing to do would be to add a new index, Sorted_activity, defined using SortIndex(...) on the simple criteria. You would then have a different node for Earliest_start_time that is indexed by Sorted_activity.
A next question to ask is whether it could be done without adding any new nodes. On the surface, it seems impossible because the sorted_activity index needs to use Earliest_start_time, but Earliest_start_time needs the list of activities to compute (the unsorted list). But there is a possible trick for this. What you can do is define:
Index Activity_idx ::= ComputedBy( Earliest_start_time ) Objective Earliest_startTime ::= LocalIndex A := #SetDifference( \(outputs of Activity), HandleFromIdentifier(identifier of self)); Local start_time_mid := Mid(Activity_start(A)); Local inds := IndexesOf(start_time_mid, except:A); Local sortCrit := if size(inds)=0 then start_time_mid Else Min( start_time_mid, ...inds); Activity_idx := sortIndex(sortCrit); If IsSampleEvalMode Then Activity_start(Activity_idx) Else start_time_mid[ A = Activity_idx ];
The trick part is the use of ComputedBy by the index, so that the start times can be computed in a local variable before you commit to the final sort order. I've add in the other things discussed above -- i.e., a sort criteria that uses the min of the mid-value start time along all other additional indexes that might appear. The definition of the local index A is just the former definition of Activity_idx.Â
Â
Â
Hi Lonnie,
One line of your code says:
Local inds := IndexesOf(start_time_mid, except:A); Local sortCrit := if size(inds)=0 then start_time_mid Else Min( start_time_mid, ...inds);
What is going on with the three dots? I can't find it in docs.Analytica.com.
Â
The three dots is called repeated parameter forwarding. The second parameter of Min is a repeated index parameter. If you know in advance that you would be taking the min over the I, J and K indexes, then you would write:Â
Min( X, I, J, K )
All three indexes are passed to the second parameter, since it is a repeated parameter. But what if you computed which indexes to take the min over? How would you pass the computed list of indexes? That's where repeated parameter forwarding comes in. It says to take the value of a variable (which in this case should be a list of index handles) and pass those indexes as if they were written explicitly. For example, this does the same thing, but computes the list of indexes:
Local inds := ListOfHandles( I, J, K ); { Pretend this is computed } Min( X, ...inds )
A common use case for this in when you want to take the Min over every index of X:
Min( X, ...indexesOf(X) )
Â
Â
Currently viewing this topic 1 guest.
- 4 Forums
- 87 Topics
- 286 Posts
- 2 Online
- 1,887 Members