Optimizer

The optimizer is a tool for optimizing solutions of a level. It will reduce the number of moves and/or pushes of a solution. If you don't want to reduce the moves or pushes of solutions you don't need the optimizer tool. It's a tool for professional players.

 

You can open the optimizer by pressing F5 or through the optimizer menu.

 

Optimizer GUI

The optimizer GUI (click the image for a larger view) shows the level at the top right, so you can always see which level is currently open for optimization.

 

A list of all available solutions is displayed in the top left corner. The solution(s) to be optimized must be selected from this list.

 

There is also a log showing information about the optimization process.

 

In addition, there are several input elements that can be used to adjust the optimizer.

 

Optimizer log

At the top right a log is displayed:

While the optimizer is running, some information is displayed in the log. When the optimizer is opened, deadlocked box configurations that may occur in the level are identified in a background task. You can see the progress in the log. When the deadlock detection is finished, the message "Deadlock detection has finished" is displayed. The detection takes a maximum of 3 seconds. However, it is possible to start the optimizer even if the deadlock detection hasn't finished.

 

The deadlock detection only needs to be done once, when the optimizer is opened.

 

Solutions list

The "Solutions" list shows all solutions of the level:

Here you have to select a solution to optimize it. The list has the same shortcut menu as the solutions sidebar. See the solutions sidebar description for more information.

 

The optimizer uses the selected solution as the basis for finding a new, better solution. You can select multiple solutions at the same time. Then the optimizer will try to combine them while searching for a better solution.

 

Note: Selecting several solutions at once for optimization requires a lot of memory and the optimization run takes a long time.

 

After the optimizer finishes the optimization process, the newly found solution is added to the solution list and automatically selected. If the newly found solution is already saved in the solution list, the new solution won't be added, but the already saved one will be selected.

 

Optimization method

The optimizer can optimize a solution for these metrics:

  • Moves/Pushes optimizes a solution for moves and as second metric for pushes.
  • Pushes/Moves optimizes a solution for pushes and as second metric for moves
  • Pushes/Moves/BL/BC/PS optimizes a solution for 1. moves, 2. pushes, 3. box lines, 4. box changes and 5. pushing sessions. This method is a bit slower than the method that only optimizes "moves/pushes"
  • Pushes/Moves/BL/BC/PS optimizes a solution for 1. pushes, 2. moves, 3. box lines, 4. box changes and 5. pushing sessions. This method is a bit slower than the method that only optimizes "pushes/moves"
  • Moves/most Pushes
    Often a solution having fewer moves than the optimized solution will also have more pushes. This method optimizes the solution for moves and thereby also tries to increase the number of pushes. 
    This sometimes finds better move solutions than optimizing for moves/pushes.
  • Box lines/...
    These methods can be used to "shuffle" a solution. This results in a new solution with a different structure than the one selected for optimization. Sometimes this new solution with a different structure can be optimized further, resulting in new best solutions. You can "shuffle" a solution when the optimizer doesn't find any new best solutions by letting it optimize some of the available solutions with this method.
  • Box changes/...  
    These methods can be used to "shuffle" a solution. This results in a new solution with a different structure than the one selected for optimization. Sometimes this new solution with a different structure can be optimized further, resulting in new best solutions. You can "shuffle" a solution when the optimizer doesn't find any new best solutions by letting it optimize some of the available solutions with this method.
    Note: The method "b Box changes" uses a fast method that can be used to quickly reduce the number of box changes. However, it's less powerful than the other "box changes" methods.

You can quickly select a specific method by clicking on the drop-down box and then typing in the number of the method you want to select.

Restricting the search

The optimizer algorithm searches all possible paths to a new better solution. However, such a search would take far too long in most levels. Therefore, the search has to be limited. This can be done by setting the "vicinity squares":

This restricts the search to the "vicinity" of the base solution selected for improvement.
The more boxes and the more vicinity squares, the more RAM the optimizer will use and the longer the search will take.
For large levels only one box should be selected
For smaller levels, 2 boxes with a small number of vicinity squares can be a good choice.
For example: 2 boxes with 10 neighborhood squares each.

 

The program can't automatically determine the perfect settings for a level. The perfect setting depends on the available RAM, the level and the solution. That's why it is necessary to try several different settings to optimize a solution.

 

Note: The more boxes and the higher the proximity squares are, the better the results will be (but the longer the search will take). For a quick result, use low values and only one box. Then increase the values and the number of selected boxes. If the optimizer log shows the message "Insufficient memory. Optimizing is done in stages.", you should stop the optimizer and use lower values / fewer boxes until the optimizer doesn't display this message anymore.

 

Advanced optimizing

The following topics are intended only for users who want to optimize the optimizer for best results. It's not necessary to understand or use these features to optimize solutions if you're only interested in "pretty good" solutions.

 

Restricting the pushes range

By default, the optimizer optimizes the entire solution. For example, if you're sure that the first 10 pushes of a solution are already perfectly optimized, you can set the range of pushes to be optimized from 11 - "end of solution".

 

The "optimize pushes range" can be used to restrict the search for a better solution to a part of the solution, which can be specified by a "from" push and a "to" push.

The optimizer automatically creates a new level from the pushes in the selected range.
Boxes which aren't pushed in this pushes range of the solution are converted to walls in order to reduce the number of boxes in the level.

 

If the Intervals checkbox is checked, the optimizer will divide the solution into several parts and optimize them one after the other. This is advantageous for large levels, since the smaller parts can be optimized with higher vicinity square settings.

 

Maximum number of box configurations

JSoko tries to calculate the required RAM before the optimizer starts. Depending on this, the maximum number of box configurations is calculated. Usually this calculation is only a rough estimate. In the log, the optimizer shows the available free RAM after the optimization. If there is still a lot of free RAM after the optimization is finished, you may get better solutions by manually increasing the maximum number of box configurations.

 

 

Iterative optimizing

If the optimizer finds a new solution with less or equal metrics compared to the selected solution, this new solution is saved for the level. It's possible to use this new solution as a new base solution that the optimizer should use to search for further improvements. This iterative optimization is done automatically when "Iterative Optimization" is selected. The optimizer will then optimize the selected solution and all better solutions it finds as long as further improvements can be found.

 

The optimizer will continue the search even if the newly found solution has the same metrics as the solution selected for optimization. This is due to the fact that even small changes in a solution can lead to further improvements in the next iteration run.

 

Of course, the optimizer will stop immediately if the newly found solution is identical to the solution selected for optimization.

 

If you select the "Stop when no improvement" checkbox, the optimizer will stop when there is no improvement according to the selected optimization method. 

For example: If the Moves/Pushes method is selected, the optimizer will stop when there is no improvement in moves or pushes.

 

 

In the process, the optimizer will save all the solutions it finds by adding them to the solutions of the level. This can result in a lot of new solutions.

 

If "Only save last solution" is selected, the optimizer will only save the last (=best) solution found.

 

Special settings

 

Preserve player end position

This is a special checkbox for users who split levels manually for a better optimization result. In these cases it can be helpful to set this flag:

If this flag is set, all new solutions found by the optimizer will have the same player position at the end of the solution (= when the level is solved) as in the selected solution to be optimized.

 

Number of CPUs to use (since JSoko version 1.69)

The optimizer can use multiple CPUs/cores when generating the box configurations and for the "Pushes/Moves/BL/BC/PS" and "Moves/Pushes/BL/BC/PS" optimizer methods. By default, JSoko uses all CPUs for these tasks. However, if this slows down your computer too much, you can set the maximum number of CPUs JSoko should use here.

 

Restricting the area to be optimized

Some levels are very large and contain many boxes. Therefore, the optimizer can only be used with small settings for the vicinity squares.

 

However, it is often possible to improve a solution just by rearranging the boxes in a small area.

 

It's possible to mark the area the optimizer should use for optimization. This can be done by simply marking an area in the level displayed in the upper right corner of the Optimizer GUI.

To select an area to be optimized, simply click into the level graphic and move the mouse while holding down the mouse button. This will draw a rectangle representing the area to be marked. When you release the mouse button, the selected area will be highlighted.

 

If at least one square is selected in this way and the optimizer is started, the optimizer will only optimize the selected area. Due to the smaller area to optimize, the number of generated box configurations is smaller than when optimizing the whole level. Therefore, it's possible to increase the settings for the vicinity squares without increasing the number of generated box configurations too much.

 

The selection of an area can be removed by pressing the right mouse button or the Ctrl key while the area is selected.

 

Double-clicking on the background graphic (or a wall graphic) inverts the selected area, i.e., all unselected squares are selected and all currently selected squares are deselected. 

This can be useful in situations like the one above, where the target room is marked and optimized first, and then the rest of the level is to be optimized. In these situations, a simple double-click will remove the markers in the goal room and set the markers for the rest of the level.