MCPcopy Create free account
hub / github.com/PSOPT/psopt / validate_user_input

Function validate_user_input

src/validate.cxx:35–250  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

33
34
35void validate_user_input(Prob& problem, Alg& algorithm, Workspace* workspace)
36{
37 char m[500];
38 int i;
39
40 if (algorithm.nlp_method != "IPOPT" && algorithm.nlp_method != "SNOPT" )
41 error_message("Incorrect NLP method specified. The only valid values are \"IPOPT\" or \"SNOPT\" ");
42 if (algorithm.collocation_method != "Legendre" && algorithm.collocation_method!="Chebyshev" && algorithm.collocation_method!="trapezoidal" && algorithm.collocation_method!="Hermite-Simpson")
43 error_message("Incorrect collocation method specified. Valid options are \"Legendre\" , \"Chebyshev\", \"trapezoidal\", and \"Hermite-Simpson\" ");
44 if (algorithm.scaling != "automatic" && algorithm.scaling!="user")
45 error_message("Incorrect scaling option specified. Valid options are \"automatic\" and \"user\" ");
46 if (algorithm.defect_scaling != "state-based" && algorithm.defect_scaling!="jacobian-based")
47 error_message("Incorrect differential defect scaling option specified. Valid options are \"state-based\" and \"jacobian-based\" ");
48 if (algorithm.derivatives != "automatic" && algorithm.derivatives!="numerical")
49 error_message("Incorrect derivatives option specified. Valid options are \"automatic\" and \"numerical\" ");
50 if (algorithm.hessian != "exact" && algorithm.hessian!="limited-memory")
51 error_message("Incorrect algorithm.hessian option specified. Valid options are \"limited-memory\" and \"exact\" ");
52 if (algorithm.hessian == "exact" && algorithm.nlp_method !="IPOPT") {
53 sprintf(workspace->text,"\n*** Warning: the 'exact' algorithm.hessian option is only available with the IPOPT solver");
54 psopt_print(workspace,workspace->text);
55 }
56 if (algorithm.diff_matrix != "standard" && algorithm.diff_matrix!="diff_matrix" && algorithm.diff_matrix!="central-differences" && algorithm.diff_matrix!="reduced-roundoff" )
57 error_message("Incorrect algorithm.diff_matrix option specified. Valid options are \"standard\", \"reduced-roundoff\" , \"central-differences\" ");
58
59
60 if (algorithm.hessian == "exact" && algorithm.derivatives !="automatic") {
61 sprintf(workspace->text,"\n*** Warning: the 'exact' algorithm.hessian option is only available with automatic derivatives");
62 psopt_print(workspace,workspace->text);
63 }
64 if (algorithm.nlp_tolerance <= 0)
65 error_message("algorithm.nlp_tolerance must be positive");
66 if (algorithm.nlp_iter_max <= 0)
67 error_message("algorithm.iter_max must be positive");
68
69 if (algorithm.nsteps_error_integration <= 0)
70 error_message("algorithm.nsteps_error_integration must be positive");
71
72 if (algorithm.ode_tolerance <= 0)
73 error_message("algorithm.ode_tolerance must be positive");
74
75 if (algorithm.mr_max_increment_factor <= 0 || algorithm.mr_max_increment_factor > 1 )
76 error_message("algorithm.mr_max_increment_factor must be in the interval (0,1]");
77 if (algorithm.mr_max_iterations <= 0)
78 error_message("algorithm.mr_max_iterations must be positive");
79 if (algorithm.mr_min_extrapolation_points < 2)
80 error_message("algorithm.mr_min_extrapolation_points must be >= 2");
81
82 if (algorithm.mr_initial_increment <= 0)
83 error_message("algorithm.mr_initial_increment must be positive");
84
85 if (algorithm.mr_kappa <= 0 || algorithm.mr_kappa>1.0 )
86 error_message("algorithm.mr_kappa must be in the interval (0,1]");
87
88 if (algorithm.mr_M1 <= 0 )
89 error_message("algorithm.mr_M1 must be positive");
90
91 if (algorithm.switch_order < 0 )
92 error_message("algorithm.mr_M1 must be >= 0");

Callers 1

psopt_mainFunction · 0.85

Calls 10

error_messageFunction · 0.85
psopt_printFunction · 0.85
lengthFunction · 0.85
isEmptyFunction · 0.85
onesFunction · 0.85
eyeFunction · 0.85
isSymmetricFunction · 0.85
resizeMethod · 0.45
colsMethod · 0.45
rowsMethod · 0.45

Tested by

no test coverage detected