Method for the computer-aided optimization of the occupancy of magazine spaces (P) with tools within at least one tool magazine (R) for a machine tool, comprising the following steps: a) acquiring a set of magazine spaces (P) in at least one tool magazine (R), b) acquiring a first set of tools that occupy at least one magazine space, and their occupied magazine spaces, c) acquiring a second set of tools that are additionally to be received in the at least one tool magazine, d) acquiring a space requirement and possibly at least one further property for each tool, e) acquiring a respective set of permissible magazine spaces for each tool, wherein a permissible magazine space depends on the space requirement and/or at least one further property of the tool and/or a property of the magazine space, f) acquiring a set of permissible magazine space pairs, wherein a first tool is able to be placed in a first magazine space of the magazine space pair that is permissible for this tool, and a second tool is able to be placed in the second magazine space of the magazine space pair that is permissible for this tool, without any collision in terms of their respective space requirement, and acquiring the size of the free gap between the first already placed tool and the second already placed tool, characterized in that g) optimizing the occupancy of the magazine spaces with tools of the first set and at least one tool to be received from the second set by way of mixed integer linear optimization, such that the number of relocations of the tools from the first set required due to the reception of said tool is minimized, wherein the required relocations and placements of the tools from the second set is performed in a compact manner such that the sum of the sizes of the free gaps between two adjacently placed tools is minimized and the magazine space pair of these adjacently placed tools is from the set of magazine space pairs permissible for this tool pair. a) acquiring a set of magazine spaces (P) in at least one tool magazine (R), b) acquiring a first set of tools that occupy at least one magazine space, and their occupied magazine spaces, c) acquiring a second set of tools that are additionally to be received in the at least one tool magazine, d) acquiring a space requirement and possibly at least one further property for each tool, e) acquiring a respective set of permissible magazine spaces for each tool, wherein a permissible magazine space depends on the space requirement and/or at least one further property of the tool and/or a property of the magazine space, f) acquiring a set of permissible magazine space pairs, wherein a first tool is able to be placed in a first magazine space of the magazine space pair that is permissible for this tool, and a second tool is able to be placed in the second magazine space of the magazine space pair that is permissible for this tool, without any collision in terms of their respective space requirement, and acquiring the size of the free gap between the first already placed tool and the second already placed tool, characterized in that g) optimizing the occupancy of the magazine spaces with tools of the first set and at least one tool to be received from the second set by way of mixed integer linear optimization, such that the number of relocations of the tools from the first set required due to the reception of said tool is minimized, wherein the required relocations and placements of the tools from the second set is performed in a compact manner such that the sum of the sizes of the free gaps between two adjacently placed tools is minimized and the magazine space pair of these adjacently placed tools is from the set of magazine space pairs permissible for this tool pair. <EOS>