SuperSCS  1.3.2
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Macros Pages
Data Structures | Macros | Typedefs | Functions
util.h File Reference
#include <stdlib.h>
#include <stdarg.h>
#include "scs.h"
#include <sys/time.h>
#include <time.h>

Go to the source code of this file.

Data Structures

struct  scs_timer
 SCS timer structure. More...
 

Macros

#define _POSIX_C_SOURCE   200112L
 

Typedefs

typedef struct scs_timer ScsTimer
 

Functions

void scs_tic (ScsTimer *timer)
 Starts the timer. More...
 
scs_float scs_toc (ScsTimer *timer)
 Stops the timer. More...
 
scs_float scs_strtoc (char *str, ScsTimer *timer)
 Stops the timer and prints a custom message. More...
 
scs_float scs_toc_quiet (ScsTimer *timer)
 Stops the timer. More...
 
void scs_print_cone_data (const ScsCone *RESTRICT cone)
 Prints the content of a Cone object. More...
 
void scs_print_data (const ScsData *data)
 Prints the content of a Data object. More...
 
void scs_print_work (const ScsWork *work)
 Prints the content of a Work object. More...
 
void scs_print_array (const scs_float *RESTRICT arr, scs_int n, const char *RESTRICT name)
 Prints an array. More...
 
void scs_set_default_settings (ScsData *RESTRICT data)
 Sets the settings to certain default values. More...
 
void scs_set_restarted_broyden_settings (ScsData *RESTRICT data, scs_int broyden_memory)
 
void scs_set_anderson_settings (ScsData *RESTRICT data, scs_int anderson_memory)
 
void scs_set_tolerance (ScsData *RESTRICT data, scs_float tolerance)
 
void scs_set_memory (ScsData *RESTRICT data, scs_int memory)
 
void scs_free_sol (ScsSolution *RESTRICT sol)
 Frees the memory allocated for a Sol object. More...
 
void scs_free_data (ScsData *RESTRICT data)
 
void scs_free_cone (ScsCone *RESTRICT cone)
 
void scs_free_data_cone (ScsData *RESTRICT d, ScsCone *RESTRICT k)
 Frees the memory allocate of a Data and a Cone object. More...
 
void scs_free_info (ScsInfo *RESTRICT info)
 Frees the memory allocated for an Info object. More...
 
int scs_special_print (scs_int print_mode, FILE *RESTRICT __stream, const char *RESTRICT __format,...)
 Custom print function for SCS. More...
 

Macro Definition Documentation

#define _POSIX_C_SOURCE   200112L

Typedef Documentation

typedef struct scs_timer ScsTimer

Typedef for the structure scs_timer

Function Documentation

void scs_free_cone ( ScsCone *RESTRICT  cone)

Frees the memory associated with an ScsCone structure

Parameters
conepointer to cone
void scs_free_data ( ScsData *RESTRICT  data)

Frees the memory associated with an ScsData structure.

Parameters
datapointer to data
See Also
scs_init_data
void scs_free_data_cone ( ScsData *RESTRICT  d,
ScsCone *RESTRICT  k 
)

Frees the memory allocate of a Data and a Cone object.

Parameters
dpointer to allocated ScsData structure
kpointer to allocated ScsCone structure
See Also
scs_set_default_settings
scs_init_data
scs_free_data
scs_free_cone
void scs_free_info ( ScsInfo *RESTRICT  info)

Frees the memory allocated for an Info object.

Parameters
infopointer to allocated ScsInfo structure
See Also
scs_init_info
void scs_free_sol ( ScsSolution *RESTRICT  sol)

Frees the memory allocated for a Sol object.

Parameters
solpointer to allocated ScsSolution structure
See Also
scs_init_sol
void scs_print_array ( const scs_float *RESTRICT  arr,
scs_int  n,
const char *RESTRICT  name 
)

Prints an array.

Parameters
arrpointer to array
nlength of array
namename of the array
void scs_print_cone_data ( const ScsCone *RESTRICT  cone)

Prints the content of a Cone object.

Parameters
conepointer to cone
void scs_print_data ( const ScsData data)

Prints the content of a Data object.

Parameters
datapointer to data
void scs_print_work ( const ScsWork work)

Prints the content of a Work object.

Parameters
workpointer to work
void scs_set_anderson_settings ( ScsData *RESTRICT  data,
scs_int  anderson_memory 
)

Calls scs_set_default_settings and sets the direction to anderson_acceleration and the memory to a specified value.

Note
Sets the memory to the maximum between 2 and the given memory.
Sets k0 to 1
Parameters
datapointer to data
anderson_memorydesired memory length
See Also
scs_set_restarted_broyden_settings
scs_set_tolerance
scs_set_default_settings
void scs_set_default_settings ( ScsData *RESTRICT  data)

Sets the settings to certain default values.

ParameterDefault valueDefault value Macro
normalize1SCS_NORMALIZE_DEFAULT
scale1.0SCS_SCALE_DEFAULT
rho_x0.001SCS_RHO_X_DEFAULT
max_iters10000SCS_MAX_ITERS_DEFAULT
max_time_milliseconds300000SCS_MAX_TIME_MILLISECONDS
previous_max_iters-1SCS_PMAXITER_DEFAULT
eps1e-3SCS_EPS_DEFAULT
alpha1.5SCS_ALPHA_DEFAULT
verbose1SCS_VERBOSE_DEFAULT
warm_start0SCS_WARM_START_DEFAULT
do_super_scs1SCS_DO_SUPERSCS_DEFAULT
k00SCS_K0_DEFAULT
k11SCS_K1_DEFAULT
k21SCS_K2_DEFAULT
c_bl0.999SCS_C_BL_DEFAULT
c10.9999SCS_C1_DEFAULT
cg_rate2.0SCS_CG_RATE_DEFAULT
ls10SCS_LS_DEFAULT
sse0.999SCS_SSE_DEFAULT
beta0.5SCS_BETA_DEFAULT
sigma0.01SCS_SIGMA_DEFAULT
directionanderson_acceleration SCS_DIRECTION_DEFAULT
thetabar0.1SCS_THETABAR_DEFAULT
memory5SCS_MEMORY_DEFAULT
broyden_init_scaling1SCS_BROYDEN_ISCS_SCALE_DEFAULT
do_record_progress0SCS_DO_RECORD_PROGRESS_DEFAULT
do_override_streams0SCS_OVERRIDE_STREAMS_DEFAULT
output_streamstdout SCS_OUT_STREAM_DEFAULT
Parameters
dataPointer to data
Warning
If you want to increase the maximum number of iteration with respect to the previous run and you have set do_record_progress to 1, then you should not use this function. If you really want to use it, however, you should set the parameter previous_max_iters to the maximum number of iterations you used in the previous run. This is in order to avoid memory management errors.
Alternatively, a simple solution is to invoke scs_free_info after you call scs and then again scs_init_info. Then it is safe to call this function and run scs again.
Note
If you have set do_record_progress to 0, you may ignore this warning.
See Also
scs_set_restarted_broyden_settings
scs_set_anderson_settings
scs_set_tolerance
easy configuration in MATLAB CVX
void scs_set_memory ( ScsData *RESTRICT  data,
scs_int  memory 
)

Sets the memory for limited-memory quasi-Newtonian direction methods.

Note
If memory is below 2 the memory is set to 2.
If memory is higher than the problem dimension, the memory is saturated to exactly the problem dimension. This rule applies to the Anderson acceleration method. It is not advisable to use too high memory values.
Parameters
datapointer to data
memorymemory length
void scs_set_restarted_broyden_settings ( ScsData *RESTRICT  data,
scs_int  broyden_memory 
)

Calls scs_set_default_settings and sets the direction to restarted_broyden and the memory to a specified value.

Note
Sets the memory to the maximum between 2 and the given memory.
Sets k0 to 0
Parameters
datapointer to data
broyden_memorydesired memory length
See Also
scs_set_anderson_settings
scs_set_tolerance
scs_set_default_settings
void scs_set_tolerance ( ScsData *RESTRICT  data,
scs_float  tolerance 
)

Sets the tolerance to a given value.

Note
If the specified tolerance is lower than 2 times the machine accuracy, the tolerance is set to that minimum value. That is, the minimum allowed tolerance is 10 * DBL_EPSILON.
Warning
If the user provides an illegal value such as negative or lower than 10 * DBL_EPSILON, the tolerance is set to 10 * DBL_EPSILON.
Note
Recommended range of tolerances: 1e-14 to 5e-2.
Parameters
datapointer to data
tolerancedesired tolerance
int scs_special_print ( scs_int  print_mode,
FILE *RESTRICT  __stream,
const char *RESTRICT  __format,
  ... 
)

Custom print function for SCS.

This functions allows to print in different streams. The argument print_mode specifies whether it is allowed to override the default stream and use a print function other than printf.

For example, if SCS is interfaced via a MEX function, MATLAB expects to use printf exclusively which it then delegated to mexPrintf; a function that prints the program's output to the console of MATLAB.

When SCS is called from other software, it is likely that print_mode has to be set to 0.

Parameters
print_modewhether to override the default behavior (using printf)
__streaman output stream
__formatstring format
...arguments specifying data to print
Returns
return value of print or vfprintf
scs_float scs_strtoc ( char *  str,
ScsTimer timer 
)

Stops the timer and prints a custom message.

Parameters
strstring
timerpointer to timer structure
Returns
elapsed time
void scs_tic ( ScsTimer timer)

Starts the timer.

Parameters
timerpointer to timer structure
scs_float scs_toc ( ScsTimer timer)

Stops the timer.

This function prints a message of the form:

time: %8.4f milli-seconds.\n

to the standard output using printf.

Parameters
timerpointer to timer structure
Returns
elapsed time in milliseconds
scs_float scs_toc_quiet ( ScsTimer timer)

Stops the timer.

Note
In contrast to scs_toc, this function does not print anything
Parameters
timerpointer to timer structure
Returns
elapsed time in milliseconds
See Also
scs_toc