Remove Newton Cholesky factor from mjData arena, rollback of b66da3d369.
PiperOrigin-RevId: 685726867 Change-Id: Ic2afd0dd35e38f403164d2cbe4618286abfa51ab
This commit is contained in:
committed by
Copybara-Service
parent
7ec94f46d4
commit
ee7b994021
@@ -170,7 +170,6 @@ struct mjData_ {
|
|||||||
int nl; // number of limit constraints
|
int nl; // number of limit constraints
|
||||||
int nefc; // number of constraints
|
int nefc; // number of constraints
|
||||||
int nnzJ; // number of non-zeros in constraint Jacobian
|
int nnzJ; // number of non-zeros in constraint Jacobian
|
||||||
int nnzL; // number of non-zeros in Newton Cholesky factor
|
|
||||||
int nisland; // number of detected constraint islands
|
int nisland; // number of detected constraint islands
|
||||||
|
|
||||||
// global properties
|
// global properties
|
||||||
@@ -392,13 +391,6 @@ struct mjData_ {
|
|||||||
int* efc_AR_colind; // column indices in sparse AR (nefc x nefc)
|
int* efc_AR_colind; // column indices in sparse AR (nefc x nefc)
|
||||||
mjtNum* efc_AR; // J*inv(M)*J' + R (nefc x nefc)
|
mjtNum* efc_AR; // J*inv(M)*J' + R (nefc x nefc)
|
||||||
|
|
||||||
// computed by mj_fwdConstraint (Newton solver)
|
|
||||||
int* L_rownnz; // number of non-zeros in Hessian factor L rows (nv x 1)
|
|
||||||
int* L_rowadr; // row start address in colind array (nv x 1)
|
|
||||||
int* L_colind; // column indices in sparse AR (nnzL x 1)
|
|
||||||
mjtNum* L; // chol(M + J'*diag(efc_D)*J) (nnzL x 1)
|
|
||||||
mjtNum* Lcone; // L with cone contributions (nnzL x 1)
|
|
||||||
|
|
||||||
//-------------------- arena-allocated: POSITION, VELOCITY dependent
|
//-------------------- arena-allocated: POSITION, VELOCITY dependent
|
||||||
|
|
||||||
// computed by mj_fwdVelocity/mj_referenceConstraint
|
// computed by mj_fwdVelocity/mj_referenceConstraint
|
||||||
|
|||||||
@@ -198,7 +198,6 @@ struct mjData_ {
|
|||||||
int nl; // number of limit constraints
|
int nl; // number of limit constraints
|
||||||
int nefc; // number of constraints
|
int nefc; // number of constraints
|
||||||
int nnzJ; // number of non-zeros in constraint Jacobian
|
int nnzJ; // number of non-zeros in constraint Jacobian
|
||||||
int nnzL; // number of non-zeros in Newton Cholesky factor
|
|
||||||
int nisland; // number of detected constraint islands
|
int nisland; // number of detected constraint islands
|
||||||
|
|
||||||
// global properties
|
// global properties
|
||||||
@@ -420,13 +419,6 @@ struct mjData_ {
|
|||||||
int* efc_AR_colind; // column indices in sparse AR (nefc x nefc)
|
int* efc_AR_colind; // column indices in sparse AR (nefc x nefc)
|
||||||
mjtNum* efc_AR; // J*inv(M)*J' + R (nefc x nefc)
|
mjtNum* efc_AR; // J*inv(M)*J' + R (nefc x nefc)
|
||||||
|
|
||||||
// computed by mj_fwdConstraint (Newton solver)
|
|
||||||
int* L_rownnz; // number of non-zeros in Hessian factor L rows (nv x 1)
|
|
||||||
int* L_rowadr; // row start address in colind array (nv x 1)
|
|
||||||
int* L_colind; // column indices in sparse AR (nnzL x 1)
|
|
||||||
mjtNum* L; // chol(M + J'*diag(efc_D)*J) (nnzL x 1)
|
|
||||||
mjtNum* Lcone; // L with cone contributions (nnzL x 1)
|
|
||||||
|
|
||||||
//-------------------- arena-allocated: POSITION, VELOCITY dependent
|
//-------------------- arena-allocated: POSITION, VELOCITY dependent
|
||||||
|
|
||||||
// computed by mj_fwdVelocity/mj_referenceConstraint
|
// computed by mj_fwdVelocity/mj_referenceConstraint
|
||||||
|
|||||||
@@ -707,14 +707,6 @@
|
|||||||
X( mjtNum, efc_force, MJ_D(nefc), 1 ) \
|
X( mjtNum, efc_force, MJ_D(nefc), 1 ) \
|
||||||
X( int, efc_state, MJ_D(nefc), 1 )
|
X( int, efc_state, MJ_D(nefc), 1 )
|
||||||
|
|
||||||
// array fields of mjData that are used in the dual problem
|
|
||||||
#define MJDATA_ARENA_POINTERS_NEWTON \
|
|
||||||
X( int, L_rownnz, MJ_M(nv), 1 ) \
|
|
||||||
X( int, L_rowadr, MJ_M(nv), 1 ) \
|
|
||||||
X( int, L_colind, MJ_D(nnzL), 1 ) \
|
|
||||||
X( mjtNum, L, MJ_D(nnzL), 1 ) \
|
|
||||||
X( mjtNum, Lcone, MJ_D(nnzL), 1 )
|
|
||||||
|
|
||||||
// array fields of mjData that are used in the dual problem
|
// array fields of mjData that are used in the dual problem
|
||||||
#define MJDATA_ARENA_POINTERS_DUAL \
|
#define MJDATA_ARENA_POINTERS_DUAL \
|
||||||
X( int, efc_AR_rownnz, MJ_D(nefc), 1 ) \
|
X( int, efc_AR_rownnz, MJ_D(nefc), 1 ) \
|
||||||
@@ -738,7 +730,6 @@
|
|||||||
#define MJDATA_ARENA_POINTERS \
|
#define MJDATA_ARENA_POINTERS \
|
||||||
MJDATA_ARENA_POINTERS_CONTACT \
|
MJDATA_ARENA_POINTERS_CONTACT \
|
||||||
MJDATA_ARENA_POINTERS_SOLVER \
|
MJDATA_ARENA_POINTERS_SOLVER \
|
||||||
MJDATA_ARENA_POINTERS_NEWTON \
|
|
||||||
MJDATA_ARENA_POINTERS_DUAL \
|
MJDATA_ARENA_POINTERS_DUAL \
|
||||||
MJDATA_ARENA_POINTERS_ISLAND
|
MJDATA_ARENA_POINTERS_ISLAND
|
||||||
|
|
||||||
@@ -762,7 +753,6 @@
|
|||||||
X( int, nl ) \
|
X( int, nl ) \
|
||||||
X( int, nefc ) \
|
X( int, nefc ) \
|
||||||
X( int, nnzJ ) \
|
X( int, nnzJ ) \
|
||||||
X( int, nnzL ) \
|
|
||||||
X( int, nisland ) \
|
X( int, nisland ) \
|
||||||
X( mjtNum, time ) \
|
X( mjtNum, time ) \
|
||||||
X( uintptr_t, threadpool )
|
X( uintptr_t, threadpool )
|
||||||
|
|||||||
@@ -4326,11 +4326,6 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='number of non-zeros in constraint Jacobian',
|
doc='number of non-zeros in constraint Jacobian',
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
|
||||||
name='nnzL',
|
|
||||||
type=ValueType(name='int'),
|
|
||||||
doc='number of non-zeros in Newton Cholesky factor',
|
|
||||||
),
|
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='nisland',
|
name='nisland',
|
||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
@@ -5287,41 +5282,6 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
),
|
),
|
||||||
doc="J*inv(M)*J' + R (nefc x nefc)", # pylint: disable=line-too-long
|
doc="J*inv(M)*J' + R (nefc x nefc)", # pylint: disable=line-too-long
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
|
||||||
name='L_rownnz',
|
|
||||||
type=PointerType(
|
|
||||||
inner_type=ValueType(name='int'),
|
|
||||||
),
|
|
||||||
doc='number of non-zeros in Hessian factor L rows (nv x 1)', # pylint: disable=line-too-long
|
|
||||||
),
|
|
||||||
StructFieldDecl(
|
|
||||||
name='L_rowadr',
|
|
||||||
type=PointerType(
|
|
||||||
inner_type=ValueType(name='int'),
|
|
||||||
),
|
|
||||||
doc='row start address in colind array (nv x 1)', # pylint: disable=line-too-long
|
|
||||||
),
|
|
||||||
StructFieldDecl(
|
|
||||||
name='L_colind',
|
|
||||||
type=PointerType(
|
|
||||||
inner_type=ValueType(name='int'),
|
|
||||||
),
|
|
||||||
doc='column indices in sparse AR (nnzL x 1)', # pylint: disable=line-too-long
|
|
||||||
),
|
|
||||||
StructFieldDecl(
|
|
||||||
name='L',
|
|
||||||
type=PointerType(
|
|
||||||
inner_type=ValueType(name='mjtNum'),
|
|
||||||
),
|
|
||||||
doc="chol(M + J'*diag(efc_D)*J) (nnzL x 1)", # pylint: disable=line-too-long
|
|
||||||
),
|
|
||||||
StructFieldDecl(
|
|
||||||
name='Lcone',
|
|
||||||
type=PointerType(
|
|
||||||
inner_type=ValueType(name='mjtNum'),
|
|
||||||
),
|
|
||||||
doc='L with cone contributions (nnzL x 1)', # pylint: disable=line-too-long
|
|
||||||
),
|
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='efc_vel',
|
name='efc_vel',
|
||||||
type=PointerType(
|
type=PointerType(
|
||||||
|
|||||||
@@ -1362,7 +1362,7 @@ Euler integrator, semi-implicit in velocity.
|
|||||||
|
|
||||||
def test_pickle_mjdata_clean(self):
|
def test_pickle_mjdata_clean(self):
|
||||||
data2 = pickle.loads(pickle.dumps(self.data))
|
data2 = pickle.loads(pickle.dumps(self.data))
|
||||||
attr_to_compare = ('time', 'qpos', 'qvel', 'mocap_pos', 'L')
|
attr_to_compare = ('time', 'qpos', 'qvel', 'mocap_pos')
|
||||||
self._assert_attributes_equal(data2, self.data, attr_to_compare)
|
self._assert_attributes_equal(data2, self.data, attr_to_compare)
|
||||||
|
|
||||||
def test_pickle_mjdata(self):
|
def test_pickle_mjdata(self):
|
||||||
@@ -1370,7 +1370,7 @@ Euler integrator, semi-implicit in velocity.
|
|||||||
data2 = pickle.loads(pickle.dumps(self.data))
|
data2 = pickle.loads(pickle.dumps(self.data))
|
||||||
attr_to_compare = (
|
attr_to_compare = (
|
||||||
'time', 'qpos', 'qvel', 'qacc', 'xpos', 'mocap_pos',
|
'time', 'qpos', 'qvel', 'qacc', 'xpos', 'mocap_pos',
|
||||||
'warning', 'energy', 'contact', 'efc_J', 'L'
|
'warning', 'energy', 'contact', 'efc_J'
|
||||||
)
|
)
|
||||||
self._assert_attributes_equal(data2, self.data, attr_to_compare)
|
self._assert_attributes_equal(data2, self.data, attr_to_compare)
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
@@ -1384,7 +1384,7 @@ Euler integrator, semi-implicit in velocity.
|
|||||||
data2 = pickle.loads(pickle.dumps(self.data))
|
data2 = pickle.loads(pickle.dumps(self.data))
|
||||||
attr_to_compare = (
|
attr_to_compare = (
|
||||||
'time', 'qpos', 'qvel', 'qacc', 'xpos', 'mocap_pos',
|
'time', 'qpos', 'qvel', 'qacc', 'xpos', 'mocap_pos',
|
||||||
'warning', 'energy', 'contact', 'efc_J', 'L'
|
'warning', 'energy', 'contact', 'efc_J'
|
||||||
)
|
)
|
||||||
self._assert_attributes_equal(data2, self.data, attr_to_compare)
|
self._assert_attributes_equal(data2, self.data, attr_to_compare)
|
||||||
for _ in range(10):
|
for _ in range(10):
|
||||||
|
|||||||
@@ -748,7 +748,6 @@ void MjDataWrapper::Serialize(std::ostream& output) const {
|
|||||||
X(ne);
|
X(ne);
|
||||||
X(nf);
|
X(nf);
|
||||||
X(nnzJ);
|
X(nnzJ);
|
||||||
X(nnzL);
|
|
||||||
X(nefc);
|
X(nefc);
|
||||||
X(nisland);
|
X(nisland);
|
||||||
X(time);
|
X(time);
|
||||||
@@ -764,9 +763,6 @@ void MjDataWrapper::Serialize(std::ostream& output) const {
|
|||||||
MJDATA_POINTERS
|
MJDATA_POINTERS
|
||||||
#undef X
|
#undef X
|
||||||
|
|
||||||
bool is_sparse_newton = this->model_->get()->opt.solver == mjSOL_NEWTON &&
|
|
||||||
mj_isSparse(this->model_->get());
|
|
||||||
|
|
||||||
#undef MJ_M
|
#undef MJ_M
|
||||||
#define MJ_M(x) this->model_->get()->x
|
#define MJ_M(x) this->model_->get()->x
|
||||||
#undef MJ_D
|
#undef MJ_D
|
||||||
@@ -779,9 +775,6 @@ void MjDataWrapper::Serialize(std::ostream& output) const {
|
|||||||
|
|
||||||
MJDATA_ARENA_POINTERS_CONTACT
|
MJDATA_ARENA_POINTERS_CONTACT
|
||||||
MJDATA_ARENA_POINTERS_SOLVER
|
MJDATA_ARENA_POINTERS_SOLVER
|
||||||
if (is_sparse_newton) {
|
|
||||||
MJDATA_ARENA_POINTERS_NEWTON
|
|
||||||
}
|
|
||||||
if (mj_isDual(this->model_->get())) {
|
if (mj_isDual(this->model_->get())) {
|
||||||
MJDATA_ARENA_POINTERS_DUAL
|
MJDATA_ARENA_POINTERS_DUAL
|
||||||
}
|
}
|
||||||
@@ -811,8 +804,6 @@ MjDataWrapper MjDataWrapper::Deserialize(std::istream& input) {
|
|||||||
|
|
||||||
bool is_dual = mj_isDual(&m);
|
bool is_dual = mj_isDual(&m);
|
||||||
|
|
||||||
bool is_sparse_newton = m.opt.solver == mjSOL_NEWTON && mj_isSparse(&m);
|
|
||||||
|
|
||||||
raw::MjData* d = mj_makeData(&m);
|
raw::MjData* d = mj_makeData(&m);
|
||||||
if (!d) {
|
if (!d) {
|
||||||
throw py::value_error("Failed to create mjData.");
|
throw py::value_error("Failed to create mjData.");
|
||||||
@@ -834,7 +825,6 @@ MjDataWrapper MjDataWrapper::Deserialize(std::istream& input) {
|
|||||||
X(ne);
|
X(ne);
|
||||||
X(nf);
|
X(nf);
|
||||||
X(nnzJ);
|
X(nnzJ);
|
||||||
X(nnzL);
|
|
||||||
X(nefc);
|
X(nefc);
|
||||||
X(nisland);
|
X(nisland);
|
||||||
X(time);
|
X(time);
|
||||||
@@ -873,9 +863,6 @@ MjDataWrapper MjDataWrapper::Deserialize(std::istream& input) {
|
|||||||
|
|
||||||
MJDATA_ARENA_POINTERS_CONTACT
|
MJDATA_ARENA_POINTERS_CONTACT
|
||||||
MJDATA_ARENA_POINTERS_SOLVER
|
MJDATA_ARENA_POINTERS_SOLVER
|
||||||
if (is_sparse_newton) {
|
|
||||||
MJDATA_ARENA_POINTERS_NEWTON
|
|
||||||
}
|
|
||||||
if (is_dual) {
|
if (is_dual) {
|
||||||
MJDATA_ARENA_POINTERS_DUAL
|
MJDATA_ARENA_POINTERS_DUAL
|
||||||
}
|
}
|
||||||
@@ -2035,7 +2022,6 @@ This is useful for example when the MJB is not available as a file on disk.)"));
|
|||||||
});
|
});
|
||||||
|
|
||||||
MJDATA_ARENA_POINTERS_SOLVER
|
MJDATA_ARENA_POINTERS_SOLVER
|
||||||
MJDATA_ARENA_POINTERS_NEWTON
|
|
||||||
MJDATA_ARENA_POINTERS_DUAL
|
MJDATA_ARENA_POINTERS_DUAL
|
||||||
MJDATA_ARENA_POINTERS_ISLAND
|
MJDATA_ARENA_POINTERS_ISLAND
|
||||||
|
|
||||||
|
|||||||
@@ -1917,7 +1917,7 @@ static int mj_nc(const mjModel* m, mjData* d, int* nnz) {
|
|||||||
// driver: call all functions above
|
// driver: call all functions above
|
||||||
void mj_makeConstraint(const mjModel* m, mjData* d) {
|
void mj_makeConstraint(const mjModel* m, mjData* d) {
|
||||||
// clear sizes
|
// clear sizes
|
||||||
d->ne = d->nf = d->nl = d->nefc = d->nnzJ = d->nnzL = 0;
|
d->ne = d->nf = d->nl = d->nefc = d->nnzJ = 0;
|
||||||
|
|
||||||
// disabled or Jacobian not allocated: return
|
// disabled or Jacobian not allocated: return
|
||||||
if (mjDISABLED(mjDSBL_CONSTRAINT)) {
|
if (mjDISABLED(mjDSBL_CONSTRAINT)) {
|
||||||
|
|||||||
@@ -1802,7 +1802,6 @@ static void _resetData(const mjModel* m, mjData* d, unsigned char debug_value) {
|
|||||||
d->nl = 0;
|
d->nl = 0;
|
||||||
d->nefc = 0;
|
d->nefc = 0;
|
||||||
d->nnzJ = 0;
|
d->nnzJ = 0;
|
||||||
d->nnzL = 0;
|
|
||||||
d->nisland = 0;
|
d->nisland = 0;
|
||||||
|
|
||||||
// clear global properties
|
// clear global properties
|
||||||
|
|||||||
@@ -1180,13 +1180,6 @@ void mj_printFormattedData(const mjModel* m, mjData* d, const char* filename,
|
|||||||
printSparse("EFC_J", d->efc_J, d->nefc, d->efc_J_rownnz,
|
printSparse("EFC_J", d->efc_J, d->nefc, d->efc_J_rownnz,
|
||||||
d->efc_J_rowadr, d->efc_J_colind, fp, float_format);
|
d->efc_J_rowadr, d->efc_J_colind, fp, float_format);
|
||||||
|
|
||||||
if (d->nnzL) {
|
|
||||||
// L sparse structure
|
|
||||||
printSparsity("L: Newton reverse Cholesky factor", m->nv, m->nv,
|
|
||||||
d->L_rowadr, d->L_rownnz, d->L_colind, fp);
|
|
||||||
printSparse("L", d->L, m->nv, d->L_rownnz, d->L_rowadr, d->L_colind, fp, float_format);
|
|
||||||
}
|
|
||||||
|
|
||||||
printArrayInt("EFC_AR_ROWNNZ", d->nefc, 1, d->efc_AR_rownnz, fp);
|
printArrayInt("EFC_AR_ROWNNZ", d->nefc, 1, d->efc_AR_rownnz, fp);
|
||||||
printArrayInt("EFC_AR_ROWADR", d->nefc, 1, d->efc_AR_rowadr, fp);
|
printArrayInt("EFC_AR_ROWADR", d->nefc, 1, d->efc_AR_rowadr, fp);
|
||||||
printSparse("EFC_AR", d->efc_AR, d->nefc, d->efc_AR_rownnz,
|
printSparse("EFC_AR", d->efc_AR, d->nefc, d->efc_AR_rownnz,
|
||||||
|
|||||||
@@ -4847,7 +4847,6 @@ public unsafe struct mjData_ {
|
|||||||
public int nl;
|
public int nl;
|
||||||
public int nefc;
|
public int nefc;
|
||||||
public int nnzJ;
|
public int nnzJ;
|
||||||
public int nnzL;
|
|
||||||
public int nisland;
|
public int nisland;
|
||||||
public double time;
|
public double time;
|
||||||
public fixed double energy[2];
|
public fixed double energy[2];
|
||||||
@@ -4985,11 +4984,6 @@ public unsafe struct mjData_ {
|
|||||||
public int* efc_AR_rowadr;
|
public int* efc_AR_rowadr;
|
||||||
public int* efc_AR_colind;
|
public int* efc_AR_colind;
|
||||||
public double* efc_AR;
|
public double* efc_AR;
|
||||||
public int* L_rownnz;
|
|
||||||
public int* L_rowadr;
|
|
||||||
public int* L_colind;
|
|
||||||
public double* L;
|
|
||||||
public double* Lcone;
|
|
||||||
public double* efc_vel;
|
public double* efc_vel;
|
||||||
public double* efc_aref;
|
public double* efc_aref;
|
||||||
public double* efc_b;
|
public double* efc_b;
|
||||||
|
|||||||
Reference in New Issue
Block a user