Tunny Icon
TunnyDocs

The next-gen Grasshopper optimization tool.

Constraints and Performance

Why are there trials that don't satisfy the constraints even though constraints were set?

Because Tunny uses soft constraints.

Soft constraints are constraints in optimization problems that "should be satisfied if possible, but do not absolutely need to be met." This concept is contrasted with hard constraints.

Key characteristics

  1. Tolerance for violations
    1. Constraints can be violated.
    2. When violated, penalties guide the solution toward satisfying the constraints.
  2. Penalty mechanism
    1. Penalty scores are assigned based on the degree of constraint violation.
    2. These penalties are incorporated into the objective function and considered during optimization.
  3. Practical advantages
    1. In real-world problems, it is often difficult to satisfy all constraints completely.
    2. Soft constraints let you find more practical solutions.
    3. They expand the search space, increasing the chance of finding better solutions.

Why is it slower than other optimization components like Wallacei or Galapagos?

By default, Tunny saves the result of each trial to a separate file so that optimization can be restarted if Rhino crashes. This I/O makes it slower than other optimization components.

For faster performance, we recommend InMemoryMode. With this setting, all results are saved at once at the end of optimization rather than during the process, which improves speed.

Can I invalidate optimization trials when modeling or other aspects don't work as intended?

You can create an Attribute named IsFail. If it contains True, that Trial is treated as failed, and its result is not reflected in the optimization. Attribute names are converted to uppercase before they are compared, so a different casing such as ISFAIL is recognized as the same attribute.

Note that with methods like BO-GP, which use a surrogate to determine the next search point, the same point may be explored repeatedly even after it fails. This happens because the failure gives the optimization solver no information about whether the trial was good, bad, or failed.