1#ifndef ZONOOPT_SOLVER_DATA_STRUCUTURES_HPP_
2#define ZONOOPT_SOLVER_DATA_STRUCUTURES_HPP_
41 virtual std::unique_ptr<SolverSettings>
clone()
const = 0;
78 double t_max = std::numeric_limits<double>::max();
172 std::unique_ptr<SolverSettings>
clone()
const override
174 return std::make_unique<OptSettings>(*
this);
195 return (general_valid && admm_valid && mi_valid);
205 std::stringstream ss;
206 ss <<
"OptSettings structure: " << std::endl;
207 ss <<
" verbose: " << (
verbose ?
"true" :
"false") << std::endl;
209 ss <<
" t_max: " <<
t_max << std::endl;
210 ss <<
" k_max_admm: " <<
k_max_admm << std::endl;
211 ss <<
" rho: " <<
rho << std::endl;
212 ss <<
" eps_dual: " <<
eps_dual << std::endl;
213 ss <<
" eps_prim: " <<
eps_prim << std::endl;
214 ss <<
" k_inf_check: " <<
k_inf_check << std::endl;
215 ss <<
" inf_norm_conv: " << (
inf_norm_conv ?
"true" :
"false") << std::endl;
218 ss <<
" search_mode: " <<
search_mode << std::endl;
219 ss <<
" polish: " <<
polish << std::endl;
222 ss <<
" eps_r: " <<
eps_r << std::endl;
223 ss <<
" eps_a: " <<
eps_a << std::endl;
224 ss <<
" k_max_bnb: " <<
k_max_bnb << std::endl;
228 ss <<
" max_nodes: " <<
max_nodes << std::endl;
234 ss <<
" eps_perturb: " <<
eps_perturb << std::endl;
235 ss <<
" k_restart: " <<
k_restart << std::endl;
236 ss <<
" enable_rng_seed: " << (
enable_rng_seed ?
"true" :
"false") << std::endl;
237 ss <<
" rng_seed: " <<
rng_seed << std::endl;
271 virtual std::shared_ptr<ExternalSolverResults>
clone()
const = 0;
274 virtual std::string
print()
const {
return "ExternalSolverResults"; }
340 std::stringstream ss;
341 ss <<
"OptSolution structure:" << std::endl;
342 ss <<
" z: vector of length " <<
z.size() << std::endl;
343 ss <<
" J: " <<
J << std::endl;
344 ss <<
" run_time: " <<
run_time << std::endl;
346 ss <<
" iter: " <<
iter << std::endl;
347 ss <<
" converged: " << (
converged ?
"true" :
"false") << std::endl;
348 ss <<
" infeasible: " << (
infeasible ?
"true" :
"false") << std::endl;
349 ss <<
" x: vector of length " <<
x.size() << std::endl;
350 ss <<
" u: vector of length " <<
u.size() << std::endl;
376 inline std::unique_ptr<SolverSettings>& default_settings_storage()
378 static std::unique_ptr<SolverSettings> p = std::make_unique<OptSettings>();
390 return *detail::default_settings_storage();
406 detail::default_settings_storage() = settings.
clone();
#define zono_float
Defines the floating-point type used in ZonoOpt.
Definition ZonoOpt.hpp:45
Definition ZonoOpt.hpp:58
const SolverSettings & get_default_solver_settings()
Returns a reference to the current program-wide default solver settings.
Definition SolverDataStructures.hpp:388
void set_default_solver_settings(const SolverSettings &settings)
Replaces the program-wide default solver settings with a polymorphic copy of settings.
Definition SolverDataStructures.hpp:403
Abstract base for external-solver-specific solution metadata.
Definition SolverDataStructures.hpp:267
virtual std::shared_ptr< ExternalSolverResults > clone() const =0
Polymorphic copy; required so callers can deep-copy an OptSolution.
virtual std::string print() const
Human-readable summary of the solver-specific fields.
Definition SolverDataStructures.hpp:274
virtual ~ExternalSolverResults()=default
Settings for the internal ZonoOpt ADMM / branch-and-bound solver.
Definition SolverDataStructures.hpp:68
bool polish
flag to perform solution polishing
Definition SolverDataStructures.hpp:112
int k_inf_check
check infeasibility every k_inf_check iterations
Definition SolverDataStructures.hpp:95
int k_restart
perform restart operation if primal residual does not improve over this many iterations in ADMM-FP
Definition SolverDataStructures.hpp:163
bool use_interval_contractor
flag to use interval contractor for constraint tightening / implication
Definition SolverDataStructures.hpp:101
double t_max
max time for optimization
Definition SolverDataStructures.hpp:78
int k_max_bnb
max number of branch-and-bound iterations
Definition SolverDataStructures.hpp:127
unsigned int rng_seed
rng seed for ADMM-FP
Definition SolverDataStructures.hpp:169
bool enable_rng_seed
enable rng seed for ADMM-FP
Definition SolverDataStructures.hpp:166
std::unique_ptr< SolverSettings > clone() const override
Polymorphic copy. Must be overridden by every concrete subclass.
Definition SolverDataStructures.hpp:172
int cycle_detection_buffer_size
in ADMM-FP, this is the max size of the buffer that checks for cycles
Definition SolverDataStructures.hpp:157
zono_float eps_r
relative convergence tolerance
Definition SolverDataStructures.hpp:121
bool enable_restart_admm_fp
enable restarts (significant perturbations) in ADMM-FP
Definition SolverDataStructures.hpp:148
zono_float eps_a
absolute convergence tolerance
Definition SolverDataStructures.hpp:124
bool verbose
display optimization progress
Definition SolverDataStructures.hpp:72
std::string print() const
displays settings as string
Definition SolverDataStructures.hpp:203
int n_threads_bnb
max threads for branch and bound
Definition SolverDataStructures.hpp:130
zono_float eps_prim_search
primal residual convergence tolerance during branch and bound and search
Definition SolverDataStructures.hpp:118
int contractor_tree_search_depth
when applying interval contractor in branch and bound, this is how deep to search the constraint tree...
Definition SolverDataStructures.hpp:142
zono_float eps_prim
primal convergence tolerance
Definition SolverDataStructures.hpp:92
int k_max_admm_fp_ph2
max ADMM iterations for ADMM-FP phase 2 (no objective)
Definition SolverDataStructures.hpp:154
OptSettings()=default
OptSettings constructor.
bool inf_norm_conv
use infinity norm for convergence check (if false, scaled 2-norm is used)
Definition SolverDataStructures.hpp:98
int verbosity_interval
print every verbose_interval iterations
Definition SolverDataStructures.hpp:75
zono_float rho
admm penalty parameter, higher prioritizes feasibility during iterations, lower prioritizes optimalit...
Definition SolverDataStructures.hpp:86
int k_max_admm_fp_ph1
max ADMM iterations for ADMM-FP phase 1 (objective included)
Definition SolverDataStructures.hpp:151
int k_max_admm
max convex admm iterations
Definition SolverDataStructures.hpp:83
zono_float eps_dual
dual convergence tolerance
Definition SolverDataStructures.hpp:89
std::string solver_name() const override
Return name of the solver backend selected by this settings type, e.g., "ZonoOpt",...
Definition SolverDataStructures.hpp:242
bool enable_perturb_admm_fp
enable perturbations in ADMM-FP
Definition SolverDataStructures.hpp:145
int max_nodes
terminate if more than this many nodes are in branch and bound queue
Definition SolverDataStructures.hpp:139
zono_float eps_perturb
relative tolerance for cycle detection, triggers perturbation
Definition SolverDataStructures.hpp:160
int search_mode
0: best first, 1: best dive
Definition SolverDataStructures.hpp:109
zono_float eps_dual_search
dual residual convergence tolerance during branch and bound and search
Definition SolverDataStructures.hpp:115
bool settings_valid() const
Checks whether settings struct is valid.
Definition SolverDataStructures.hpp:183
bool single_threaded_admm_fp
enables single-threaded ADMM-FP solution, overrides n_threads_bnb, n_threads_admm_fp
Definition SolverDataStructures.hpp:136
int contractor_iter
number of interval contractor iterations
Definition SolverDataStructures.hpp:104
int n_threads_admm_fp
max threads for ADMM-FP
Definition SolverDataStructures.hpp:133
Solution data structure for optimization routines in ZonoOpt library.
Definition SolverDataStructures.hpp:288
zono_float dual_residual
dual residual, corresponds to optimality
Definition SolverDataStructures.hpp:324
bool infeasible
true if optimization problem is provably infeasible
Definition SolverDataStructures.hpp:304
Eigen::Vector< zono_float, -1 > x
ADMM primal variable, approximately equal to z when converged.
Definition SolverDataStructures.hpp:315
Eigen::Vector< zono_float, -1 > z
solution vector
Definition SolverDataStructures.hpp:292
double run_time
time to compute solution (seconds)
Definition SolverDataStructures.hpp:298
std::string print() const
displays solution as string
Definition SolverDataStructures.hpp:338
zono_float J
objective
Definition SolverDataStructures.hpp:295
zono_float primal_residual
primal residual, corresponds to feasibility
Definition SolverDataStructures.hpp:321
std::shared_ptr< ExternalSolverResults > external_results
Definition SolverDataStructures.hpp:331
int iter
number of iterations
Definition SolverDataStructures.hpp:312
double startup_time
time to factorize matrices and run interval contractors
Definition SolverDataStructures.hpp:309
bool converged
true if optimization has converged (proved optimal for external solvers; satisfied tolerances for int...
Definition SolverDataStructures.hpp:301
Eigen::Vector< zono_float, -1 > u
ADMM dual variable.
Definition SolverDataStructures.hpp:318
Abstract base for all solver settings.
Definition SolverDataStructures.hpp:35
virtual void verify_available() const
Verify the solver backend selected by this settings type is usable.
Definition SolverDataStructures.hpp:53
virtual std::string solver_name() const =0
Return name of the solver backend selected by this settings type, e.g., "ZonoOpt",...
virtual std::unique_ptr< SolverSettings > clone() const =0
Polymorphic copy. Must be overridden by every concrete subclass.
virtual ~SolverSettings()=default