casadi 3.6.6__cp39-none-manylinux2014_aarch64.whl → 3.6.7__cp39-none-manylinux2014_aarch64.whl
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- casadi/_casadi.so +0 -0
- casadi/casadi.py +207 -182
- casadi/cmake/casadi-config-version.cmake +1 -1
- casadi/include/casadi/config.h +6 -6
- casadi/include/casadi/core/casadi_misc.hpp +39 -0
- casadi/include/casadi/core/mx.hpp +5 -0
- casadi/include/casadi/core/runtime/casadi_nlp.hpp +17 -4
- casadi/include/casadi/doc.i +514 -459
- casadi/include/casadi/doc_merged.i +380 -326
- casadi/include/fatrop/auxiliary/Common.hpp +1 -0
- casadi/include/fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp +2 -1
- casadi/include/fatrop/fatrop.hpp +39 -0
- casadi/include/fatrop/ocp/FatropOCPResto.hpp +299 -0
- casadi/include/fatrop/ocp/OCPLSRiccati.hpp +7 -0
- casadi/include/fatrop/ocp/StageOCPApplication.hpp +1 -1
- casadi/include/fatrop/solver/AlgBuilder.hpp +13 -3
- casadi/include/fatrop/solver/FatropAlg.hpp +15 -2
- casadi/include/fatrop/solver/FatropOptions.hpp +5 -4
- casadi/include/fatrop/solver/IterationData.hpp +2 -1
- casadi/include/fatrop/solver/LineSearch.hpp +1 -1
- casadi/include/fatrop/templates/NLPAlg.hpp +2 -0
- casadi/libcasadi.so +0 -0
- casadi/libcasadi.so.3.7 +0 -0
- casadi/libcasadi_conic_fatrop.so +0 -0
- casadi/libcasadi_conic_fatrop.so.3.7 +0 -0
- casadi/libcasadi_conic_superscs.so +0 -0
- casadi/libcasadi_conic_superscs.so.3.7 +0 -0
- casadi/libcasadi_nlpsol_fatrop.so +0 -0
- casadi/libcasadi_nlpsol_fatrop.so.3.7 +0 -0
- casadi/libcasadi_nlpsol_knitro.so +0 -0
- casadi/libcasadi_nlpsol_knitro.so.3.7 +0 -0
- casadi/libcoinmetis.la +1 -1
- casadi/libcoinmetis.so +0 -0
- casadi/libcoinmetis.so.2 +0 -0
- casadi/libcoinmetis.so.2.0.0 +0 -0
- casadi/libfatrop.so +0 -0
- casadi/libipopt.so +0 -0
- casadi/libipopt.so.3 +0 -0
- casadi/libipopt.so.3.14.11 +0 -0
- casadi/libmatlab_ipc.so +0 -0
- casadi/libsipopt.so +0 -0
- casadi/libsipopt.so.3 +0 -0
- casadi/libsipopt.so.3.14.11 +0 -0
- casadi/pkgconfig/casadi.pc +1 -1
- {casadi-3.6.6.dist-info → casadi-3.6.7.dist-info}/METADATA +1 -1
- {casadi-3.6.6.dist-info → casadi-3.6.7.dist-info}/RECORD +47 -45
- {casadi-3.6.6.dist-info → casadi-3.6.7.dist-info}/WHEEL +0 -0
@@ -326,7 +326,7 @@ namespace fatrop
|
|
326
326
|
blasfeo_dvecse(nels(), val, vec_, offset());
|
327
327
|
}
|
328
328
|
|
329
|
-
void copy(const FatropVecBF &fm);
|
329
|
+
void copy(const FatropVecBF &fm) const;
|
330
330
|
void copyto(std::vector<double> &dest) const;
|
331
331
|
void operator=(const std::vector<double> &fm);
|
332
332
|
/** \brief set data pointer*/
|
@@ -381,6 +381,7 @@ namespace fatrop
|
|
381
381
|
double LinfScaled(const FatropVecBF &va, const FatropVecBF &scales);
|
382
382
|
double minabs(const FatropVecBF &va);
|
383
383
|
double L1(const FatropVecBF &va);
|
384
|
+
double sumsqr(const FatropVecBF &va);
|
384
385
|
|
385
386
|
/** \brief this class is used for the allocation of a blasfeo vector, the dimsensions are set from a vector */
|
386
387
|
class FatropMemoryVecBF
|
@@ -0,0 +1,39 @@
|
|
1
|
+
/*
|
2
|
+
* Fatrop - A fast trajectory optimization solver
|
3
|
+
* Copyright (C) 2022 - 2024 Lander Vanroye, KU Leuven. All rights reserved.
|
4
|
+
*
|
5
|
+
* This file is part of Fatrop.
|
6
|
+
*
|
7
|
+
* Fatrop is free software: you can redistribute it and/or modify
|
8
|
+
* it under the terms of the GNU Lesser General Public License as published by
|
9
|
+
* the Free Software Foundation, either version 3 of the License, or
|
10
|
+
* (at your option) any later version.
|
11
|
+
*
|
12
|
+
* Fatrop is distributed in the hope that it will be useful,
|
13
|
+
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
14
|
+
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
15
|
+
* GNU Lesser General Public License for more details.
|
16
|
+
*
|
17
|
+
* You should have received a copy of the GNU Lesser General Public License
|
18
|
+
* along with Fatrop. If not, see <http://www.gnu.org/licenses/>. */
|
19
|
+
#ifndef FATROP_INCLUDED
|
20
|
+
#define FATROP_INCLUDED
|
21
|
+
#include "fatrop/ocp/StageOCPApplication.hpp"
|
22
|
+
// #include "fatrop/blasfeo_wrapper/LinearAlgebraBlasfeo.hpp"
|
23
|
+
// #include "fatrop/ocp/OCPKKT.hpp"
|
24
|
+
// #include "fatrop/ocp/OCPAdapter.hpp"
|
25
|
+
// #include "fatrop/ocp/OCPAbstact.hpp"
|
26
|
+
// #include "fatrop/auxiliary/FatropVector.hpp"
|
27
|
+
// #include "fatrop/solver/FatropAlg.hpp"
|
28
|
+
// #include "fatrop/solver/FatropData.hpp"
|
29
|
+
// #include "fatrop/ocp/OCPScalingMethod.hpp"
|
30
|
+
// #include "fatrop/ocp/OCPNoScaling.hpp"
|
31
|
+
// #include "fatrop/solver/AlgStrategy.hpp"
|
32
|
+
// #include "fatrop/solver/FatropOptions.hpp"
|
33
|
+
// #include "fatrop/function_evaluation/CasadiCodegen.hpp"
|
34
|
+
// #include "fatrop/solver/AlgBuilder.hpp"
|
35
|
+
// #include "fatrop/ocp/StageOCPApplication.hpp"
|
36
|
+
// #include "fatrop/ocp/FatropOCPBuilder.hpp"
|
37
|
+
|
38
|
+
// #include "SparseSolvers/InterfaceMUMPS.hpp"
|
39
|
+
#endif //FATROP_INCLUDED
|
@@ -0,0 +1,299 @@
|
|
1
|
+
#pragma once
|
2
|
+
#include "FatropOCP.hpp"
|
3
|
+
#include "fatrop/solver/FatropOptions.hpp"
|
4
|
+
#include <memory>
|
5
|
+
namespace fatrop
|
6
|
+
{
|
7
|
+
class FatropOCPResto : public FatropNLP
|
8
|
+
{
|
9
|
+
public:
|
10
|
+
FatropOCPResto(const std::shared_ptr<FatropOCP> &orig, const std::shared_ptr<FatropOptions> &opts) : orig_(orig), orig_dims_(orig->get_nlp_dims()), lower_(orig_dims_.nineqs), upper_(orig_dims_.nineqs), x_start_(orig_dims_.nvars), s_start_(orig_dims_.nineqs), x_tmp_(orig_dims_.nvars), s_tmp_(orig_dims_.nineqs), upper_bounded_(orig_dims_.nineqs), lower_bounded_(orig_dims_.nineqs), slack_dummy_(orig_dims_.nineqs), sigma_dummy_(orig_dims_.nineqs), gradb_dummy_(orig_dims_.nineqs), zl_dummy_(orig_dims_.nineqs), zu_dummy_(orig_dims_.nineqs), sigma_cache_(orig_dims_.nineqs * 3), gradb_cache_(orig_dims_.nineqs * 3)
|
11
|
+
{
|
12
|
+
opts->register_option(DoubleOption::lower_bounded("resto_rho", "Resto L1 penalty parameter", &rho, 1000., 0.0));
|
13
|
+
opts->register_option(DoubleOption::lower_bounded("resto_xi", "Resto xi parameter", &xi, 1., 0.0));
|
14
|
+
auto lower_v = lower_[0];
|
15
|
+
auto upper_v = upper_[0];
|
16
|
+
orig_->get_bounds(lower_v, upper_v);
|
17
|
+
n_p = orig_dims_.nineqs;
|
18
|
+
n_n = orig_dims_.nineqs;
|
19
|
+
for (fatrop_int i = 0; i < orig_dims_.nineqs; ++i)
|
20
|
+
{
|
21
|
+
bool lower_bounded = !std::isinf(lower_v.at(i));
|
22
|
+
bool upper_bounded = !std::isinf(upper_v.at(i));
|
23
|
+
upper_bounded_[i] = upper_bounded;
|
24
|
+
lower_bounded_[i] = lower_bounded;
|
25
|
+
}
|
26
|
+
this_dims_.nvars = orig_dims_.nvars;
|
27
|
+
this_dims_.nineqs = orig_dims_.nineqs + n_n + n_p;
|
28
|
+
this_dims_.neqs = orig_dims_.neqs;
|
29
|
+
}
|
30
|
+
virtual void pre_solve(const FatropVecBF &x_init, const FatropVecBF &s_init) override
|
31
|
+
{
|
32
|
+
x_start_[0].copy(x_init);
|
33
|
+
s_start_[0].copy(s_init.block(0, orig_dims_.nineqs));
|
34
|
+
};
|
35
|
+
virtual fatrop_int eval_lag_hess(
|
36
|
+
double obj_scale,
|
37
|
+
const FatropVecBF &primal_vars,
|
38
|
+
const FatropVecBF &slack_vars,
|
39
|
+
const FatropVecBF &lam) override
|
40
|
+
{
|
41
|
+
FatropVecBF slack_dummy_v = slack_dummy_[0];
|
42
|
+
update_slack_vars(slack_vars, slack_dummy_v);
|
43
|
+
orig_->eval_lag_hess(0.0, primal_vars, slack_dummy_v, lam);
|
44
|
+
// compute delta's
|
45
|
+
axpby(xi, primal_vars, -xi, x_start_[0], x_tmp_[0]);
|
46
|
+
axpby(xi, slack_vars.block(0, orig_dims_.nineqs), -xi, s_start_[0], s_tmp_[0]);
|
47
|
+
// iterate over all RSQrq's
|
48
|
+
|
49
|
+
{
|
50
|
+
OCPKKTMemory* OCP =&this->orig_->ocpkktmemory_;
|
51
|
+
// horizon length
|
52
|
+
fatrop_int K = OCP->K;
|
53
|
+
// offsets
|
54
|
+
const fatrop_int *offs_ux = (const fatrop_int *)OCP->aux.ux_offs.data();
|
55
|
+
OCPMACRO(MAT *, RSQrqt, _p);
|
56
|
+
VEC* x_tmp_p = (VEC*) x_tmp_[0];
|
57
|
+
OCPMACRO(fatrop_int *, nu, _p);
|
58
|
+
OCPMACRO(fatrop_int *, nx, _p);
|
59
|
+
for (fatrop_int k = 0; k < K; k++)
|
60
|
+
{
|
61
|
+
fatrop_int nu_k = nu_p[k];
|
62
|
+
fatrop_int nx_k = nx_p[k];
|
63
|
+
fatrop_int offs_ux_k = offs_ux[k];
|
64
|
+
// add xi to RSQrq diagonal
|
65
|
+
DIARE(nx_k + nu_k, xi, RSQrqt_p + k, 0, 0);
|
66
|
+
// add gradient to rq
|
67
|
+
ROWAD(nu_k + nx_k, 1.0, x_tmp_p, offs_ux_k, RSQrqt_p+k, nu_k + nx_k, 0);
|
68
|
+
}
|
69
|
+
}
|
70
|
+
return 0;
|
71
|
+
};
|
72
|
+
|
73
|
+
virtual fatrop_int eval_constr_jac(
|
74
|
+
const FatropVecBF &primal_vars,
|
75
|
+
const FatropVecBF &slack_vars) override
|
76
|
+
{
|
77
|
+
FatropVecBF slack_dummy_v = slack_dummy_[0];
|
78
|
+
update_slack_vars(slack_vars, slack_dummy_v);
|
79
|
+
orig_->eval_constr_jac(primal_vars, slack_dummy_v);
|
80
|
+
return 0;
|
81
|
+
};
|
82
|
+
void update_slack_vars(const FatropVecBF &slack_vars, FatropVecBF &slack_dummy)
|
83
|
+
{
|
84
|
+
fatrop_int offs_n = orig_dims_.nineqs;
|
85
|
+
fatrop_int offs_p = orig_dims_.nineqs + n_n;
|
86
|
+
for (fatrop_int i = 0; i < orig_dims_.nineqs; ++i)
|
87
|
+
{
|
88
|
+
slack_dummy.at(i) = slack_vars.at(i) - slack_vars.at(i + offs_n) + slack_vars.at(i + offs_p);
|
89
|
+
}
|
90
|
+
}
|
91
|
+
virtual fatrop_int eval_constraint_viol(
|
92
|
+
const FatropVecBF &primal_vars,
|
93
|
+
const FatropVecBF &slack_vars,
|
94
|
+
FatropVecBF &constraint_violation) override
|
95
|
+
{
|
96
|
+
FatropVecBF slack_dummy_v = slack_dummy_[0];
|
97
|
+
update_slack_vars(slack_vars, slack_dummy_v);
|
98
|
+
orig_->eval_constraint_viol(primal_vars, slack_dummy_v, constraint_violation);
|
99
|
+
return 0;
|
100
|
+
};
|
101
|
+
virtual fatrop_int eval_obj_grad(
|
102
|
+
double obj_scale,
|
103
|
+
const FatropVecBF &primal_vars,
|
104
|
+
const FatropVecBF &slack_vars,
|
105
|
+
FatropVecBF &gradient_x,
|
106
|
+
FatropVecBF &gradient_s) override
|
107
|
+
{
|
108
|
+
// compute delta's
|
109
|
+
axpby(xi, primal_vars, -xi, x_start_[0], gradient_x);
|
110
|
+
axpby(xi, slack_vars.block(0, orig_dims_.nineqs), -xi, s_start_[0], gradient_s.block(0, orig_dims_.nineqs));
|
111
|
+
gradient_s.block(orig_dims_.nineqs, n_n + n_p) = rho;
|
112
|
+
return 0;
|
113
|
+
};
|
114
|
+
virtual fatrop_int eval_obj(
|
115
|
+
double obj_scale,
|
116
|
+
const FatropVecBF &primal_vars,
|
117
|
+
const FatropVecBF &slack_vars,
|
118
|
+
double &res) override
|
119
|
+
{
|
120
|
+
// compute delta's
|
121
|
+
axpby(1.0, primal_vars, -1.0, x_start_[0], x_tmp_[0]);
|
122
|
+
axpby(1.0, slack_vars.block(0, orig_dims_.nineqs), -1.0, s_start_[0], s_tmp_[0]);
|
123
|
+
res = 0.5*xi*(sumsqr(x_tmp_[0]) + sumsqr(s_tmp_[0]));
|
124
|
+
res += rho * sum(slack_vars.block(orig_dims_.nineqs, n_n + n_p));
|
125
|
+
return 0;
|
126
|
+
};
|
127
|
+
void get_initialization(const FatropVecBF &primal_vars_orig, FatropVecBF &intialization)
|
128
|
+
{
|
129
|
+
intialization.block(0, orig_dims_.nvars).copy(primal_vars_orig.block(0, orig_dims_.nvars));
|
130
|
+
}
|
131
|
+
virtual fatrop_int eval_dual_inf(
|
132
|
+
double obj_scale,
|
133
|
+
const FatropVecBF &lam,
|
134
|
+
const FatropVecBF &grad_x,
|
135
|
+
const FatropVecBF &grad_s,
|
136
|
+
FatropVecBF &du_inf_x, FatropVecBF &du_inf_s_wo_z) override
|
137
|
+
{
|
138
|
+
auto du_inf_s_wo_z_or = du_inf_s_wo_z.block(0, orig_dims_.nineqs);
|
139
|
+
orig_->eval_dual_inf(obj_scale, lam, grad_x, grad_s, du_inf_x, du_inf_s_wo_z_or);
|
140
|
+
auto lam_I = lam.block(orig_dims_.neqs - orig_dims_.nineqs, orig_dims_.nineqs);
|
141
|
+
axpby(1.0, lam_I, 1.0, grad_s.block(orig_dims_.nineqs, n_n), du_inf_s_wo_z.block(orig_dims_.nineqs, n_n));
|
142
|
+
axpby(-1.0, lam_I, 1.0, grad_s.block(orig_dims_.nineqs + n_n, n_p), du_inf_s_wo_z.block(orig_dims_.nineqs + n_n, n_p));
|
143
|
+
return 0;
|
144
|
+
}
|
145
|
+
void update_sigma_gradb(double inertia, const FatropVecBF &sigma_s, const FatropVecBF &sigma_n, const FatropVecBF &sigma_p, const FatropVecBF &gradb_s, const FatropVecBF &gradb_n, const FatropVecBF &gradb_p, const FatropVecBF &sigma_update, const FatropVecBF &gradb_update)
|
146
|
+
{
|
147
|
+
for (int i = 0; i < orig_dims_.nineqs; ++i)
|
148
|
+
{
|
149
|
+
double sigma_updt = 1.0 / (1.0 / (sigma_s.at(i) + inertia + xi) + 1.0 / (sigma_n.at(i) + inertia) + 1.0 / (sigma_p.at(i) + inertia));
|
150
|
+
sigma_update.at(i) = sigma_updt - inertia;
|
151
|
+
gradb_update.at(i) = ((gradb_s.at(i)) / (sigma_s.at(i) + inertia + xi) - (gradb_n.at(i)) / (sigma_n.at(i) + inertia) + (gradb_p.at(i)) / (sigma_p.at(i) + inertia)) * sigma_updt;
|
152
|
+
}
|
153
|
+
}
|
154
|
+
void update_delta_snp(double inertia, const FatropVecBF &sigma_s, const FatropVecBF &sigma_n, const FatropVecBF &sigma_p, const FatropVecBF &gradb_s, const FatropVecBF &gradb_n, const FatropVecBF &gradb_p, const FatropVecBF &lam_I, const FatropVecBF &delta_s, const FatropVecBF &delta_n, const FatropVecBF &delta_p)
|
155
|
+
{
|
156
|
+
for (int i = 0; i < orig_dims_.nineqs; ++i)
|
157
|
+
{
|
158
|
+
double lam_I_i = lam_I.at(i);
|
159
|
+
delta_s.at(i) = (-gradb_s.at(i) + lam_I_i) / (sigma_s.at(i) + inertia+xi);
|
160
|
+
delta_n.at(i) = (-gradb_n.at(i) - lam_I_i) / (sigma_n.at(i) + inertia);
|
161
|
+
delta_p.at(i) = (-gradb_p.at(i) + lam_I_i) / (sigma_p.at(i) + inertia);
|
162
|
+
}
|
163
|
+
}
|
164
|
+
|
165
|
+
virtual fatrop_int solve_pd_sys(
|
166
|
+
const double inertia_correction_w,
|
167
|
+
const double inertia_correction_c,
|
168
|
+
const FatropVecBF &ux,
|
169
|
+
const FatropVecBF &lam,
|
170
|
+
const FatropVecBF &delta_s,
|
171
|
+
const FatropVecBF &sigma_total,
|
172
|
+
const FatropVecBF &gradb_total) override
|
173
|
+
{
|
174
|
+
// (todo) check if quadratic penalty on delta s is treated right
|
175
|
+
inertia_correction_w_cache = inertia_correction_w;
|
176
|
+
sigma_cache_[0].copy(sigma_total);
|
177
|
+
gradb_cache_[0].copy(gradb_total);
|
178
|
+
auto lam_I = lam.block(orig_dims_.neqs - orig_dims_.nineqs, orig_dims_.nineqs);
|
179
|
+
auto sigma_s = sigma_total.block(0, orig_dims_.nineqs);
|
180
|
+
auto sigma_n = sigma_total.block(orig_dims_.nineqs, n_n);
|
181
|
+
auto sigma_p = sigma_total.block(orig_dims_.nineqs + n_n, n_p);
|
182
|
+
auto gradb_s = gradb_total.block(0, orig_dims_.nineqs);
|
183
|
+
auto gradb_n = gradb_total.block(orig_dims_.nineqs, n_n);
|
184
|
+
auto gradb_p = gradb_total.block(orig_dims_.nineqs + n_n, n_p);
|
185
|
+
auto delta_s_or = delta_s.block(0, orig_dims_.nineqs);
|
186
|
+
auto delta_n = delta_s.block(orig_dims_.nineqs, n_n);
|
187
|
+
auto delta_p = delta_s.block(orig_dims_.nineqs + n_n, n_p);
|
188
|
+
update_sigma_gradb(inertia_correction_w, sigma_s, sigma_n, sigma_p, gradb_s, gradb_n, gradb_p, sigma_dummy_[0], gradb_dummy_[0]);
|
189
|
+
int ret = orig_->solve_pd_sys(inertia_correction_w, inertia_correction_c, ux, lam, delta_s.block(0, orig_dims_.nineqs), sigma_dummy_[0], gradb_dummy_[0]);
|
190
|
+
update_delta_snp(inertia_correction_w, sigma_s, sigma_n, sigma_p, gradb_s, gradb_n, gradb_p, lam_I, delta_s_or, delta_n, delta_p);
|
191
|
+
return ret;
|
192
|
+
};
|
193
|
+
virtual fatrop_int solve_soc_rhs(
|
194
|
+
const FatropVecBF &ux,
|
195
|
+
const FatropVecBF &lam,
|
196
|
+
const FatropVecBF &delta_s,
|
197
|
+
const FatropVecBF &cosntraint_violation) override
|
198
|
+
{
|
199
|
+
auto lam_I = lam.block(orig_dims_.neqs - orig_dims_.nineqs, orig_dims_.nineqs);
|
200
|
+
auto sigma_s = sigma_cache_[0].block(0, orig_dims_.nineqs);
|
201
|
+
auto sigma_n = sigma_cache_[0].block(orig_dims_.nineqs, n_n);
|
202
|
+
auto sigma_p = sigma_cache_[0].block(orig_dims_.nineqs + n_n, n_p);
|
203
|
+
auto gradb_s = gradb_cache_[0].block(0, orig_dims_.nineqs);
|
204
|
+
auto gradb_n = gradb_cache_[0].block(orig_dims_.nineqs, n_n);
|
205
|
+
auto gradb_p = gradb_cache_[0].block(orig_dims_.nineqs + n_n, n_p);
|
206
|
+
auto delta_s_or = delta_s.block(0, orig_dims_.nineqs);
|
207
|
+
auto delta_n = delta_s.block(orig_dims_.nineqs, n_n);
|
208
|
+
auto delta_p = delta_s.block(orig_dims_.nineqs + n_n, n_p);
|
209
|
+
int ret = orig_->solve_soc_rhs(ux, lam, delta_s.block(0, orig_dims_.nineqs), cosntraint_violation);
|
210
|
+
update_delta_snp(inertia_correction_w_cache + xi, sigma_s, sigma_n, sigma_p, gradb_s, gradb_n, gradb_p, lam_I, delta_s_or, delta_n, delta_p);
|
211
|
+
return ret;
|
212
|
+
}
|
213
|
+
virtual NLPDims get_nlp_dims() const override { return this_dims_; };
|
214
|
+
virtual fatrop_int compute_scalings(
|
215
|
+
double &obj_scale,
|
216
|
+
FatropVecBF &x_scales,
|
217
|
+
FatropVecBF &lam_scales,
|
218
|
+
const FatropVecBF &grad_curr_x, const FatropVecBF &grad_curr_s) override
|
219
|
+
{
|
220
|
+
return orig_->compute_scalings(obj_scale, x_scales, lam_scales, grad_curr_x, grad_curr_s);
|
221
|
+
};
|
222
|
+
virtual fatrop_int initialize_slacks(double mu0,
|
223
|
+
FatropVecBF &s_curr) override
|
224
|
+
{
|
225
|
+
auto s_curr_or = s_curr.block(0, orig_dims_.nineqs);
|
226
|
+
auto n_curr = s_curr.block(orig_dims_.nineqs, n_n);
|
227
|
+
auto p_curr = s_curr.block(orig_dims_.nineqs + n_n, n_p);
|
228
|
+
FatropVecBF ineq_viol = s_tmp_[0];
|
229
|
+
int ret = orig_->initialize_slacks(mu0, ineq_viol);
|
230
|
+
for (int i = 0; i < orig_dims_.nineqs; i++)
|
231
|
+
{
|
232
|
+
double viol = 0.0;
|
233
|
+
viol = (ineq_viol.at(i));
|
234
|
+
double n_init = (mu0 - rho * viol) / (2 * rho) + std::sqrt(std::pow((mu0 - rho * viol) / (2 * rho), 2) + mu0 * viol / (2 * rho));
|
235
|
+
// if viol >>>> 0 -> n_init = 0 if viol <<< 0 n_init = viol
|
236
|
+
n_curr.at(i) = n_init;
|
237
|
+
p_curr.at(i) = viol + n_init;
|
238
|
+
}
|
239
|
+
return 0;
|
240
|
+
}
|
241
|
+
virtual fatrop_int initialize_dual(
|
242
|
+
const FatropVecBF &grad_x,
|
243
|
+
const FatropVecBF &grad_s,
|
244
|
+
FatropVecBF &dlam,
|
245
|
+
const FatropVecBF &zL,
|
246
|
+
const FatropVecBF &zU) override
|
247
|
+
{
|
248
|
+
// todo check if this is correct
|
249
|
+
// return orig_->initialize_dual(grad_x, grad_s, dlam, zL.block(0, orig_dims_.nineqs), zU.block(0, orig_dims_.nineqs));
|
250
|
+
return 0;
|
251
|
+
};
|
252
|
+
virtual fatrop_int get_bounds(
|
253
|
+
FatropVecBF &lower,
|
254
|
+
FatropVecBF &upper) const override
|
255
|
+
{
|
256
|
+
orig_->get_bounds(lower, upper);
|
257
|
+
lower.block(orig_dims_.nineqs, n_n) = 0.0;
|
258
|
+
lower.block(orig_dims_.nineqs + n_n, n_p) = 0.0;
|
259
|
+
upper.block(orig_dims_.nineqs, n_n) = std::numeric_limits<double>::infinity();
|
260
|
+
upper.block(orig_dims_.nineqs + n_n, n_p) = std::numeric_limits<double>::infinity();
|
261
|
+
return 0;
|
262
|
+
};
|
263
|
+
virtual fatrop_int get_initial_sol_guess(
|
264
|
+
FatropVecBF &initial) const override
|
265
|
+
{
|
266
|
+
orig_->get_initial_sol_guess(initial);
|
267
|
+
return 0;
|
268
|
+
}
|
269
|
+
virtual void update_mu(double mu) override
|
270
|
+
{
|
271
|
+
xi = std::sqrt(mu);
|
272
|
+
orig_->update_mu(mu);
|
273
|
+
};
|
274
|
+
virtual void reset() override
|
275
|
+
{
|
276
|
+
orig_->reset();
|
277
|
+
};
|
278
|
+
std::shared_ptr<FatropOCP> orig_;
|
279
|
+
NLPDims orig_dims_;
|
280
|
+
NLPDims this_dims_;
|
281
|
+
FatropMemoryVecBF lower_, upper_;
|
282
|
+
FatropMemoryVecBF x_start_, s_start_;
|
283
|
+
FatropMemoryVecBF x_tmp_, s_tmp_;
|
284
|
+
std::vector<bool> upper_bounded_;
|
285
|
+
std::vector<bool> lower_bounded_;
|
286
|
+
fatrop_int n_p = 0;
|
287
|
+
fatrop_int n_n = 0;
|
288
|
+
FatropMemoryVecBF slack_dummy_;
|
289
|
+
FatropMemoryVecBF sigma_dummy_;
|
290
|
+
FatropMemoryVecBF gradb_dummy_;
|
291
|
+
FatropMemoryVecBF zl_dummy_;
|
292
|
+
FatropMemoryVecBF zu_dummy_;
|
293
|
+
double inertia_correction_w_cache = 0.0;
|
294
|
+
FatropMemoryVecBF sigma_cache_;
|
295
|
+
FatropMemoryVecBF gradb_cache_;
|
296
|
+
double rho = 1e4;
|
297
|
+
double xi = 1.0;
|
298
|
+
};
|
299
|
+
};
|
@@ -186,6 +186,13 @@ namespace fatrop
|
|
186
186
|
std::shared_ptr<FatropOptions> options_;
|
187
187
|
std::shared_ptr<FatropPrinter> printer_;
|
188
188
|
bool it_ref = true;
|
189
|
+
bool perturbed_mode = false;
|
190
|
+
double perturbed_mode_param = 1e-6;
|
191
|
+
int min_it_ref = 0;
|
192
|
+
int max_it_ref = 5;
|
193
|
+
double it_ref_acc = 1e-8;
|
194
|
+
double lu_fact_tol = 1e-5;
|
195
|
+
bool diagnostic = false;
|
189
196
|
};
|
190
197
|
}; // namespace
|
191
198
|
#endif // OCPLSRICCATIINCLUDED
|
@@ -26,9 +26,9 @@ namespace fatrop
|
|
26
26
|
class AlgBuilder
|
27
27
|
{
|
28
28
|
public:
|
29
|
-
void build_fatrop_algorithm_objects(const std::shared_ptr<FatropNLP> &nlp,
|
29
|
+
void build_fatrop_algorithm_objects(const std::shared_ptr<FatropNLP> &nlp,const std::shared_ptr<FatropNLP> &nlp_resto,
|
30
30
|
const std::shared_ptr<FatropOptions> &fatropparams,
|
31
|
-
std::shared_ptr<FatropData> &fatropdata,
|
31
|
+
std::shared_ptr<FatropData> &fatropdata, std::shared_ptr<FatropData> &fatropdata_resto,
|
32
32
|
std::shared_ptr<Journaller> &journaller)
|
33
33
|
{
|
34
34
|
if (fatropprinter_ == nullptr)
|
@@ -36,10 +36,13 @@ namespace fatrop
|
|
36
36
|
fatropprinter_ = std::make_shared<FatropPrinter>();
|
37
37
|
}
|
38
38
|
fatropdata = std::make_shared<FatropData>(nlp->get_nlp_dims(), fatropparams, fatropprinter_);
|
39
|
+
fatropdata_resto = std::make_shared<FatropData>(nlp_resto->get_nlp_dims(), fatropparams, fatropprinter_);
|
39
40
|
journaller = std::make_shared<Journaller>(fatropparams->maxiter + 1, fatropprinter_);
|
40
41
|
fatropdata_ = fatropdata; // keep this around for building the algorithm
|
42
|
+
fatropdata_resto_ = fatropdata_resto;
|
41
43
|
journaller_ = journaller;
|
42
44
|
nlp_ = nlp;
|
45
|
+
nlp_resto_ = nlp_resto;
|
43
46
|
fatropoptions_ = fatropparams;
|
44
47
|
}
|
45
48
|
void set_printer(const std::shared_ptr<FatropPrinter> &printer)
|
@@ -51,13 +54,20 @@ namespace fatrop
|
|
51
54
|
// TODO unsafe if maxiter is changed during application
|
52
55
|
std::shared_ptr<Filter> filter = std::make_shared<Filter>(fatropoptions_->maxiter + 1);
|
53
56
|
std::shared_ptr<LineSearch> linesearch = std::make_shared<BackTrackingLineSearch>(fatropoptions_, nlp_, fatropdata_, filter, journaller_, fatropprinter_);
|
54
|
-
|
57
|
+
std::shared_ptr<Filter> filter_resto = std::make_shared<Filter>(fatropoptions_->maxiter + 1);
|
58
|
+
std::shared_ptr<LineSearch> linesearch_resto = std::make_shared<BackTrackingLineSearch>(fatropoptions_, nlp_resto_, fatropdata_resto_, filter_resto, journaller_, fatropprinter_);
|
59
|
+
std::shared_ptr<FatropAlg> orig_alg = std::make_shared<FatropAlg>(nlp_, fatropdata_, fatropoptions_, filter, linesearch, journaller_, fatropprinter_, nullptr, nullptr, false);
|
60
|
+
std::shared_ptr<FatropAlg> resto_alg = std::make_shared<FatropAlg>(nlp_resto_, fatropdata_resto_, fatropoptions_, filter_resto, linesearch_resto, journaller_, fatropprinter_, orig_alg, nullptr, true);
|
61
|
+
orig_alg-> set_resto_alg(resto_alg);
|
62
|
+
return orig_alg;
|
55
63
|
}
|
56
64
|
|
57
65
|
private:
|
58
66
|
std::shared_ptr<FatropNLP> nlp_;
|
67
|
+
std::shared_ptr<FatropNLP> nlp_resto_;
|
59
68
|
std::shared_ptr<FatropOptions> fatropoptions_;
|
60
69
|
std::shared_ptr<FatropData> fatropdata_;
|
70
|
+
std::shared_ptr<FatropData> fatropdata_resto_;
|
61
71
|
std::shared_ptr<Journaller> journaller_;
|
62
72
|
std::shared_ptr<FatropPrinter> fatropprinter_;
|
63
73
|
};
|
@@ -47,7 +47,8 @@ namespace fatrop
|
|
47
47
|
const std::shared_ptr<Filter> &filter,
|
48
48
|
const std::shared_ptr<LineSearch> &linesearch,
|
49
49
|
const std::shared_ptr<Journaller> &journaller,
|
50
|
-
const std::shared_ptr<FatropPrinter> &printer
|
50
|
+
const std::shared_ptr<FatropPrinter> &printer,
|
51
|
+
const std::shared_ptr<FatropAlg>&orig_, const std::shared_ptr<FatropAlg>&resto_alg_, bool resto_problem);
|
51
52
|
void initialize() ;
|
52
53
|
void reset() ;
|
53
54
|
void set_bounds(const std::vector<double> &lower, const std::vector<double> &upper) ;
|
@@ -62,8 +63,11 @@ namespace fatrop
|
|
62
63
|
double eval_objective_curr();
|
63
64
|
double eval_objective_trial();
|
64
65
|
fatrop_int eval_dual_infeasiblity();
|
65
|
-
fatrop_int
|
66
|
+
fatrop_int perform_initializiation_dual();
|
66
67
|
fatrop_int solve_pd_sys(double inertia_correction_w, double inertia_correction_c, double mu);
|
68
|
+
fatrop_int start_resto_alg(double mu, int iter);
|
69
|
+
fatrop_int return_from_resto_alg(double mu);
|
70
|
+
bool resto_stop_crit();
|
67
71
|
std::shared_ptr<FatropNLP> fatropnlp_;
|
68
72
|
std::shared_ptr<FatropData> fatropdata_;
|
69
73
|
std::shared_ptr<FatropOptions> fatropoptions_;
|
@@ -81,6 +85,10 @@ namespace fatrop
|
|
81
85
|
double acceptable_tol;
|
82
86
|
fatrop_int acceptable_iter;
|
83
87
|
fatrop_int maxiter;
|
88
|
+
void set_resto_alg(const std::shared_ptr<FatropAlg> &resto_alg)
|
89
|
+
{
|
90
|
+
resto_alg_ = resto_alg;
|
91
|
+
};
|
84
92
|
|
85
93
|
private:
|
86
94
|
double lammax;
|
@@ -103,6 +111,11 @@ namespace fatrop
|
|
103
111
|
double recalc_y_feas_tol;
|
104
112
|
// bool first_try_watchdog;
|
105
113
|
FatropStats stats;
|
114
|
+
std::weak_ptr<FatropAlg> orig_;
|
115
|
+
std::shared_ptr<FatropAlg> resto_alg_;
|
116
|
+
bool resto_problem_ = false;
|
117
|
+
fatrop_int start_iter_ = 0;
|
118
|
+
fatrop_int iter_count_ = 0;
|
106
119
|
};
|
107
120
|
} // namespace fatrop
|
108
121
|
#endif // FATROPALGINCLUDED
|
@@ -22,6 +22,7 @@
|
|
22
22
|
#include <map>
|
23
23
|
#include <type_traits>
|
24
24
|
#include <iostream>
|
25
|
+
#include <vector>
|
25
26
|
#include "fatrop/auxiliary/Common.hpp"
|
26
27
|
namespace fatrop
|
27
28
|
{
|
@@ -82,10 +83,10 @@ namespace fatrop
|
|
82
83
|
void register_option(const BooleanOption &option);
|
83
84
|
void register_option(const StringOption &option);
|
84
85
|
friend auto operator<<(std::ostream &os, const FatropOptions &m) -> std::ostream &;
|
85
|
-
std::map<std::string, DoubleOption
|
86
|
-
std::map<std::string, IntegerOption
|
87
|
-
std::map<std::string, BooleanOption
|
88
|
-
std::map<std::string, StringOption
|
86
|
+
std::map<std::string, std::vector<DoubleOption>> numeric_options;
|
87
|
+
std::map<std::string, std::vector<IntegerOption>> integer_options;
|
88
|
+
std::map<std::string, std::vector<BooleanOption>> boolean_options;
|
89
|
+
std::map<std::string, std::vector<StringOption>> string_options;
|
89
90
|
std::map<std::string, std::string> prebuilt_string;
|
90
91
|
std::map<std::string, double> prebuilt_double;
|
91
92
|
};
|
@@ -38,12 +38,13 @@ namespace fatrop
|
|
38
38
|
double alpha_pr = 0.0;
|
39
39
|
double alpha_du = 0.0;
|
40
40
|
char type = 'x';
|
41
|
+
bool resto = false;
|
41
42
|
};
|
42
43
|
class Journaller
|
43
44
|
{
|
44
45
|
public:
|
45
46
|
Journaller(const fatrop_int maxiter, const std::shared_ptr<FatropPrinter> &printer);
|
46
|
-
void print_iterations();
|
47
|
+
void print_iterations(bool no_header = false);
|
47
48
|
void push();
|
48
49
|
void reset();
|
49
50
|
fatrop_int print_count = 0;
|
@@ -43,7 +43,7 @@ namespace fatrop
|
|
43
43
|
const std::shared_ptr<FatropNLP> &nlp,
|
44
44
|
const std::shared_ptr<FatropData> &fatropdata, const std::shared_ptr<FatropPrinter> &printer);
|
45
45
|
virtual LineSearchInfo find_acceptable_trial_point(double mu, bool small_sd, bool from_backup) = 0;
|
46
|
-
|
46
|
+
fatrop_int eval_constr_viol_trial();
|
47
47
|
double eval_obj_trial();
|
48
48
|
void reset();
|
49
49
|
virtual fatrop_int update_trial_step(double alpha_pr, double alpha_du) const;
|
@@ -92,11 +92,13 @@ namespace fatrop
|
|
92
92
|
FatropVecBF &upper) const = 0;
|
93
93
|
virtual fatrop_int get_initial_sol_guess(
|
94
94
|
FatropVecBF &initial) const = 0;
|
95
|
+
virtual void pre_solve(const FatropVecBF& x_init,const FatropVecBF& s_init){};
|
95
96
|
// virtual fatrop_int GetDefaultParams(
|
96
97
|
// FatropOptions ¶ms) const = 0;
|
97
98
|
virtual fatrop_int Callback(FatropVecBF& primal_vars){return 0;};
|
98
99
|
virtual void finalize(){};
|
99
100
|
virtual void reset(){};
|
101
|
+
virtual void update_mu(double mu){};
|
100
102
|
};
|
101
103
|
} // namespace fatrop
|
102
104
|
#endif // NLPINCLUDED
|
casadi/libcasadi.so
CHANGED
Binary file
|
casadi/libcasadi.so.3.7
CHANGED
Binary file
|
casadi/libcasadi_conic_fatrop.so
CHANGED
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
Binary file
|
casadi/libcoinmetis.la
CHANGED
casadi/libcoinmetis.so
CHANGED
Binary file
|
casadi/libcoinmetis.so.2
CHANGED
Binary file
|
casadi/libcoinmetis.so.2.0.0
CHANGED
Binary file
|
casadi/libfatrop.so
CHANGED
Binary file
|
casadi/libipopt.so
CHANGED
Binary file
|
casadi/libipopt.so.3
CHANGED
Binary file
|
casadi/libipopt.so.3.14.11
CHANGED
Binary file
|
casadi/libmatlab_ipc.so
CHANGED
Binary file
|
casadi/libsipopt.so
CHANGED
Binary file
|
casadi/libsipopt.so.3
CHANGED
Binary file
|
casadi/libsipopt.so.3.14.11
CHANGED
Binary file
|
casadi/pkgconfig/casadi.pc
CHANGED
@@ -6,7 +6,7 @@ includedir=/work/install/casadi/include
|
|
6
6
|
Name: casadi
|
7
7
|
Description: CasADi is a symbolic framework for automatic differentation and numeric optimization
|
8
8
|
URL: http://casadi.org
|
9
|
-
Version: 3.6.
|
9
|
+
Version: 3.6.7
|
10
10
|
Requires:
|
11
11
|
Libs: -L${libdir} -lcasadi
|
12
12
|
Cflags: -I${includedir}
|