We have succeeded in creating a Delphi 64bit example-application for our 64bit version of the Cut2DX. Previously we have integrated our component in 64bit applications created with Visual Studio (C#, C++ and VB).

Delphi XE2 IDE is a 32 bit application that comes with microsoft product keys at Software Keep. Because of that you cannot install a 64bit component in the Component Palette. So, this time, you cannot drag the component as you did in the previous editions of Delphi. Instead, you have to manually create an instance of the component at the runtime.

So, here the are steps:

1. Make sure that 64bit edition was previously registered with regsvr32.exe (the one located in system32 folder!).

2. Create a VCL based application.

3. From Project Manager (located in the right side of the screen), right click the Target Platforms, choose Add Platform | 64 bit Windows.

4. From menu Component select Import Component | Type library.

5. From the list of registered type libraries, select optimal2dx_64Lib, then next.

6. No need to specify a Palette page, because anyway the component will not appear there.

7. Add unit to the current project. Finish.

8. Add optimal2dx_64Lib_TLB to the list of units used the current project.

9. Declare a variable: cut2d64: TCut2DX.

10. Create an instance of TCut2DX during the FormCreate event:
cut2d64 := TCut2DX.Create(Form1);

11. Create 2 event handlers for OnFinish and OnProgress events. Add the declarations in the interface:

A polynomial-time algorithm is that one whose running time is bounded by a polynomial function of its input size. For instance, if we have n = 1000 pieces to cut and the cutting algorithm would have the complexity O(n2), then the running time would have been directly and linear proportional to 10002 which is (106) units of time. Assuming that our computers can perform 109 operations per second, the cutting optimization algorithm would run in less than a fraction of a second. Sadly, this is not the case for the cutting optimization problem. There is no such fast algorithm for solving it.

The only perfect algorithm for solving the cutting optimization problem is an exponential one. An exponential algorithm will run in an exponential amount of time (2n, 3n, n! – where n is the number of pieces to be optimized). Thus, even for small instances (lets say 1000 pieces) an exponential algorithm will run as follows:

if the complexity is 2n , then the total number of operations is 21000 which can be approximated by 10300. Knowing that our computers can perform 109 operations / second we need 10291 second to run the algorithm. One year has about 108 seconds. This means that our algorithm would run in 10283 years. This is a huge value compared to the age of the universe which is only 109 years.

if the complexity is 3n , then the total number of operations is 31000 which can be approximated by 10477.

if the complexity is n! , then the total number of operations is 1000! which can be approximated by 102567.

These algorithms run in an impressive number of years. Even if we put all computers in the world to solve the problem in parallel we still don’t get a significant improvement in speed.

This is why another possibility (which is employed by our software too) is to use heuristics or approximation algorithms. A heuristic is an algorithm which is fast and returns a good solution (often the best one) of the problem. However,there is no guarantee that the obtained solution is the optimal one.

An important parameter of the software is the OptimizationLevel. This will basically tell how many configurations are explored before the best found solutions is outputted. If you set the OptimizationLevel to very low value you will obtain a solution very fast. But the quality of the solution might be not so good. If you set the OptimizationLevel to very high value you will obtain a good solution but not so fast. Thus, one must employ a trade-off between the quality of the solutions and the running time.