////
  // Copyright (c) 2021, 2025 Contributors to the Eclipse Foundation
  //
  // This program and the accompanying materials are made
  // available under the terms of the Eclipse Public License 2.0
  // which is available at https://www.eclipse.org/legal/epl-2.0/
  //
  // SPDX-License-Identifier: EPL-2.0
////

include::_initCommon.adoc[]

== Generate Max-Plus Specification

The timing behavior of an activity execution is characterized by two elements, which are:
[horizontal]
 synchronization:: waiting for incoming claims, releases, or actions to finish
 delay:: action duration (specified either directly in the settings file, or derived from a motion specification)

A max-plus matrix can be used to concisely capture this timing behavior.
The matrix describes the longest path between each resource claim and release.
Computing the total execution time of an activity sequence can be done by multiplying the corresponding max-plus matrices.

The max-plus specification also contains the supervisory controller described by CIF.
Given all possible activity sequences and the corresponding max-plus matrices, the worst-case and best-case throughput and makespan can be computed.

To generate a max-plus specification, click on the activity file and select "Generate Max-Plus Specification".
 
image::{imgsdir}/maxplusClick.png[]

Next, select the respective CIF file. 
If the CIF file contains cycles, the minimum/maximum throughput can be computed.
If the CIF file does not contain cycles, the minimum/maximum throughput can be computed.

Modify the CIF file as it is shown below in order to include a cycle.
---- 
include::{codedir}/tutorial.cif[lines=10..1000]
----

Now, we are ready to generate the activity dispatching sequence ensuring the maximum throughput.

image::{imgsdir}/maxplusThroughput.png[]

The result of the computation is shown in the Error Log, including some additional details about the computation times of the steps.

image::{imgsdir}/maxplusresult.png[]

[NOTE]
====
The max-plus specification is used mostly for experimental features, including for example partial-order reduction.
Computing the maximum throughput or minimum makespan can also done without first computing the max-plus specification, as described in <<dispatching-generation>>.

====
