Getting started

The easiest way to use the ProxToolbox is to run one of the demonstrations that are located in the demos folder. Consider, for instance, the demonstration that uses the Cyclic Projections (CP) algorithm on the CDI experiment.

Running the CP algorithm on the CDI experiment

Assuming ProxPython is in your current folder, change your current folder to demos by:

cd ProxPython/demos

Then just type:

python3 tasse_cp.py

This demonstration will produce the following text output:

Loading data file CDI_intensity
Using farfield formula.
Running CP on CDI...
Took 667 iterations and 5.126296758651733 seconds.

It will also open a few windows to display several plots. Closing all the windows will end this python script.

Now, let us examine the content of the tasse_cp.py demonstration:

1
2
3
4
5
6
import SetProxPythonPath
from proxtoolbox.experiments.phase.CDI_Experiment import CDI_Experiment

CDI = CDI_Experiment(algorithm='CP', MAXIT=5000)
CDI.run()
CDI.show()

The first line makes sure that the folder ProxPython is in the python path. The second line imports the CDI_Experiment class that we are going to use. Line 4 creates a CDI_Experiment object using two arguments. The algorithm argument specifies which algorithm to use, while the MAXIT argument gives the maximum number of iterations the algorithm can run. The next line runs the algorithm on the CDI experiment and the last line displays the relevant plots for this experiment.

Modifying this demonstration

The CDI_Experiment class, like every experiment in the ProxToolbox, defines default parameters via its static method getDefaultParameters()

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
@staticmethod
def getDefaultParameters():
   defaultParams = {
      'experiment_name': 'CDI',
      'object': 'nonnegative',
      'constraint': 'nonnegative and support',
      'Nx': 128,
      'Ny': 128,
      'Nz': 1,
      'sets': 10,
      'farfield': True,
      'MAXIT': 6000,
      'TOL': 1e-8,
      'lambda_0': 0.5,
      'lambda_max': 0.50,
      'lambda_switch': 30,
      'data_ball': .999826e-30,
      'diagnostic': True,
      'iterate_monitor_name': 'FeasibilityIterateMonitor',
      'rotate': False,
      'verbose': 0,
      'graphics': 1,
      'anim': False,
      'debug': True
   }
   return defaultParams

In the previous demonstration, the MAXIT argument was used during the creation of the experiment object to override the default value of 6000.

For additional practice, we can create an experiment object that will use a different algorithm and specific values for the parameters lambda_0 and lambda_max which govern how the relaxation constant is calculated:

1
CDI = CDI_Experiment(algorithm='CDRl', lambda_0=0.7, lambda_max=0.9)