Rename nnzJ to nJ in mjData.
This naming is more consistent. PiperOrigin-RevId: 691858223 Change-Id: Ife3db822afa0b51b30d0792548b35b3742da388a
This commit is contained in:
committed by
Copybara-Service
parent
554641060b
commit
c9f78ad8a8
@@ -169,7 +169,7 @@ struct mjData_ {
|
|||||||
int nf; // number of friction constraints
|
int nf; // number of friction constraints
|
||||||
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 nJ; // number of non-zeros in constraint Jacobian
|
||||||
int nisland; // number of detected constraint islands
|
int nisland; // number of detected constraint islands
|
||||||
|
|
||||||
// global properties
|
// global properties
|
||||||
@@ -361,13 +361,13 @@ struct mjData_ {
|
|||||||
int* efc_J_rownnz; // number of non-zeros in constraint Jacobian row (nefc x 1)
|
int* efc_J_rownnz; // number of non-zeros in constraint Jacobian row (nefc x 1)
|
||||||
int* efc_J_rowadr; // row start address in colind array (nefc x 1)
|
int* efc_J_rowadr; // row start address in colind array (nefc x 1)
|
||||||
int* efc_J_rowsuper; // number of subsequent rows in supernode (nefc x 1)
|
int* efc_J_rowsuper; // number of subsequent rows in supernode (nefc x 1)
|
||||||
int* efc_J_colind; // column indices in constraint Jacobian (nnzJ x 1)
|
int* efc_J_colind; // column indices in constraint Jacobian (nJ x 1)
|
||||||
int* efc_JT_rownnz; // number of non-zeros in constraint Jacobian row T (nv x 1)
|
int* efc_JT_rownnz; // number of non-zeros in constraint Jacobian row T (nv x 1)
|
||||||
int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
|
int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
|
||||||
int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
|
int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
|
||||||
int* efc_JT_colind; // column indices in constraint Jacobian T (nnzJ x 1)
|
int* efc_JT_colind; // column indices in constraint Jacobian T (nJ x 1)
|
||||||
mjtNum* efc_J; // constraint Jacobian (nnzJ x 1)
|
mjtNum* efc_J; // constraint Jacobian (nJ x 1)
|
||||||
mjtNum* efc_JT; // constraint Jacobian transposed (nnzJ x 1)
|
mjtNum* efc_JT; // constraint Jacobian transposed (nJ x 1)
|
||||||
mjtNum* efc_pos; // constraint position (equality, contact) (nefc x 1)
|
mjtNum* efc_pos; // constraint position (equality, contact) (nefc x 1)
|
||||||
mjtNum* efc_margin; // inclusion margin (contact) (nefc x 1)
|
mjtNum* efc_margin; // inclusion margin (contact) (nefc x 1)
|
||||||
mjtNum* efc_frictionloss; // frictionloss (friction) (nefc x 1)
|
mjtNum* efc_frictionloss; // frictionloss (friction) (nefc x 1)
|
||||||
|
|||||||
@@ -197,7 +197,7 @@ struct mjData_ {
|
|||||||
int nf; // number of friction constraints
|
int nf; // number of friction constraints
|
||||||
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 nJ; // number of non-zeros in constraint Jacobian
|
||||||
int nisland; // number of detected constraint islands
|
int nisland; // number of detected constraint islands
|
||||||
|
|
||||||
// global properties
|
// global properties
|
||||||
@@ -389,13 +389,13 @@ struct mjData_ {
|
|||||||
int* efc_J_rownnz; // number of non-zeros in constraint Jacobian row (nefc x 1)
|
int* efc_J_rownnz; // number of non-zeros in constraint Jacobian row (nefc x 1)
|
||||||
int* efc_J_rowadr; // row start address in colind array (nefc x 1)
|
int* efc_J_rowadr; // row start address in colind array (nefc x 1)
|
||||||
int* efc_J_rowsuper; // number of subsequent rows in supernode (nefc x 1)
|
int* efc_J_rowsuper; // number of subsequent rows in supernode (nefc x 1)
|
||||||
int* efc_J_colind; // column indices in constraint Jacobian (nnzJ x 1)
|
int* efc_J_colind; // column indices in constraint Jacobian (nJ x 1)
|
||||||
int* efc_JT_rownnz; // number of non-zeros in constraint Jacobian row T (nv x 1)
|
int* efc_JT_rownnz; // number of non-zeros in constraint Jacobian row T (nv x 1)
|
||||||
int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
|
int* efc_JT_rowadr; // row start address in colind array T (nv x 1)
|
||||||
int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
|
int* efc_JT_rowsuper; // number of subsequent rows in supernode T (nv x 1)
|
||||||
int* efc_JT_colind; // column indices in constraint Jacobian T (nnzJ x 1)
|
int* efc_JT_colind; // column indices in constraint Jacobian T (nJ x 1)
|
||||||
mjtNum* efc_J; // constraint Jacobian (nnzJ x 1)
|
mjtNum* efc_J; // constraint Jacobian (nJ x 1)
|
||||||
mjtNum* efc_JT; // constraint Jacobian transposed (nnzJ x 1)
|
mjtNum* efc_JT; // constraint Jacobian transposed (nJ x 1)
|
||||||
mjtNum* efc_pos; // constraint position (equality, contact) (nefc x 1)
|
mjtNum* efc_pos; // constraint position (equality, contact) (nefc x 1)
|
||||||
mjtNum* efc_margin; // inclusion margin (contact) (nefc x 1)
|
mjtNum* efc_margin; // inclusion margin (contact) (nefc x 1)
|
||||||
mjtNum* efc_frictionloss; // frictionloss (friction) (nefc x 1)
|
mjtNum* efc_frictionloss; // frictionloss (friction) (nefc x 1)
|
||||||
|
|||||||
@@ -689,13 +689,13 @@
|
|||||||
X( int, efc_J_rownnz, MJ_D(nefc), 1 ) \
|
X( int, efc_J_rownnz, MJ_D(nefc), 1 ) \
|
||||||
X( int, efc_J_rowadr, MJ_D(nefc), 1 ) \
|
X( int, efc_J_rowadr, MJ_D(nefc), 1 ) \
|
||||||
X( int, efc_J_rowsuper, MJ_D(nefc), 1 ) \
|
X( int, efc_J_rowsuper, MJ_D(nefc), 1 ) \
|
||||||
X( int, efc_J_colind, MJ_D(nnzJ), 1 ) \
|
X( int, efc_J_colind, MJ_D(nJ), 1 ) \
|
||||||
X( int, efc_JT_rownnz, MJ_M(nv), 1 ) \
|
X( int, efc_JT_rownnz, MJ_M(nv), 1 ) \
|
||||||
X( int, efc_JT_rowadr, MJ_M(nv), 1 ) \
|
X( int, efc_JT_rowadr, MJ_M(nv), 1 ) \
|
||||||
X( int, efc_JT_rowsuper, MJ_M(nv), 1 ) \
|
X( int, efc_JT_rowsuper, MJ_M(nv), 1 ) \
|
||||||
X( int, efc_JT_colind, MJ_D(nnzJ), 1 ) \
|
X( int, efc_JT_colind, MJ_D(nJ), 1 ) \
|
||||||
X( mjtNum, efc_J, MJ_D(nnzJ), 1 ) \
|
X( mjtNum, efc_J, MJ_D(nJ), 1 ) \
|
||||||
X( mjtNum, efc_JT, MJ_D(nnzJ), 1 ) \
|
X( mjtNum, efc_JT, MJ_D(nJ), 1 ) \
|
||||||
X( mjtNum, efc_pos, MJ_D(nefc), 1 ) \
|
X( mjtNum, efc_pos, MJ_D(nefc), 1 ) \
|
||||||
X( mjtNum, efc_margin, MJ_D(nefc), 1 ) \
|
X( mjtNum, efc_margin, MJ_D(nefc), 1 ) \
|
||||||
X( mjtNum, efc_frictionloss, MJ_D(nefc), 1 ) \
|
X( mjtNum, efc_frictionloss, MJ_D(nefc), 1 ) \
|
||||||
@@ -755,7 +755,7 @@
|
|||||||
X( int, nf ) \
|
X( int, nf ) \
|
||||||
X( int, nl ) \
|
X( int, nl ) \
|
||||||
X( int, nefc ) \
|
X( int, nefc ) \
|
||||||
X( int, nnzJ ) \
|
X( int, nJ ) \
|
||||||
X( int, nisland ) \
|
X( int, nisland ) \
|
||||||
X( mjtNum, time ) \
|
X( mjtNum, time ) \
|
||||||
X( uintptr_t, threadpool )
|
X( uintptr_t, threadpool )
|
||||||
|
|||||||
@@ -4692,7 +4692,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
doc='number of constraints',
|
doc='number of constraints',
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='nnzJ',
|
name='nJ',
|
||||||
type=ValueType(name='int'),
|
type=ValueType(name='int'),
|
||||||
doc='number of non-zeros in constraint Jacobian',
|
doc='number of non-zeros in constraint Jacobian',
|
||||||
),
|
),
|
||||||
@@ -5588,7 +5588,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
inner_type=ValueType(name='int'),
|
inner_type=ValueType(name='int'),
|
||||||
),
|
),
|
||||||
doc='column indices in constraint Jacobian',
|
doc='column indices in constraint Jacobian',
|
||||||
array_extent=('nnzJ',),
|
array_extent=('nJ',),
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='efc_JT_rownnz',
|
name='efc_JT_rownnz',
|
||||||
@@ -5616,7 +5616,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
type=PointerType(
|
type=PointerType(
|
||||||
inner_type=ValueType(name='int'),
|
inner_type=ValueType(name='int'),
|
||||||
),
|
),
|
||||||
doc='column indices in constraint Jacobian T (nnzJ x 1)', # pylint: disable=line-too-long
|
doc='column indices in constraint Jacobian T (nJ x 1)', # pylint: disable=line-too-long
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='efc_J',
|
name='efc_J',
|
||||||
@@ -5624,7 +5624,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
inner_type=ValueType(name='mjtNum'),
|
inner_type=ValueType(name='mjtNum'),
|
||||||
),
|
),
|
||||||
doc='constraint Jacobian',
|
doc='constraint Jacobian',
|
||||||
array_extent=('nnzJ',),
|
array_extent=('nJ',),
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='efc_JT',
|
name='efc_JT',
|
||||||
@@ -5632,7 +5632,7 @@ STRUCTS: Mapping[str, StructDecl] = dict([
|
|||||||
inner_type=ValueType(name='mjtNum'),
|
inner_type=ValueType(name='mjtNum'),
|
||||||
),
|
),
|
||||||
doc='constraint Jacobian transposed',
|
doc='constraint Jacobian transposed',
|
||||||
array_extent=('nnzJ',),
|
array_extent=('nJ',),
|
||||||
),
|
),
|
||||||
StructFieldDecl(
|
StructFieldDecl(
|
||||||
name='efc_pos',
|
name='efc_pos',
|
||||||
|
|||||||
@@ -408,7 +408,7 @@ def get_data_into(
|
|||||||
ncon = (d_i.contact.dist <= 0).sum()
|
ncon = (d_i.contact.dist <= 0).sum()
|
||||||
efc_active = (d_i.efc_J != 0).any(axis=1)
|
efc_active = (d_i.efc_J != 0).any(axis=1)
|
||||||
nefc = int(efc_active.sum())
|
nefc = int(efc_active.sum())
|
||||||
result_i.nnzJ = nefc * m.nv
|
result_i.nJ = nefc * m.nv
|
||||||
if ncon != result_i.ncon or nefc != result_i.nefc:
|
if ncon != result_i.ncon or nefc != result_i.nefc:
|
||||||
mujoco._functions._realloc_con_efc(result_i, ncon=ncon, nefc=nefc) # pylint: disable=protected-access
|
mujoco._functions._realloc_con_efc(result_i, ncon=ncon, nefc=nefc) # pylint: disable=protected-access
|
||||||
result_i.efc_J_rownnz[:] = np.repeat(m.nv, nefc)
|
result_i.efc_J_rownnz[:] = np.repeat(m.nv, nefc)
|
||||||
|
|||||||
@@ -747,7 +747,7 @@ void MjDataWrapper::Serialize(std::ostream& output) const {
|
|||||||
X(ncon);
|
X(ncon);
|
||||||
X(ne);
|
X(ne);
|
||||||
X(nf);
|
X(nf);
|
||||||
X(nnzJ);
|
X(nJ);
|
||||||
X(nefc);
|
X(nefc);
|
||||||
X(nisland);
|
X(nisland);
|
||||||
X(time);
|
X(time);
|
||||||
@@ -824,7 +824,7 @@ MjDataWrapper MjDataWrapper::Deserialize(std::istream& input) {
|
|||||||
X(ncon);
|
X(ncon);
|
||||||
X(ne);
|
X(ne);
|
||||||
X(nf);
|
X(nf);
|
||||||
X(nnzJ);
|
X(nJ);
|
||||||
X(nefc);
|
X(nefc);
|
||||||
X(nisland);
|
X(nisland);
|
||||||
X(time);
|
X(time);
|
||||||
|
|||||||
@@ -1943,7 +1943,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 = 0;
|
d->ne = d->nf = d->nl = d->nefc = d->nJ = 0;
|
||||||
|
|
||||||
// disabled or Jacobian not allocated: return
|
// disabled or Jacobian not allocated: return
|
||||||
if (mjDISABLED(mjDSBL_CONSTRAINT)) {
|
if (mjDISABLED(mjDSBL_CONSTRAINT)) {
|
||||||
@@ -1951,13 +1951,13 @@ void mj_makeConstraint(const mjModel* m, mjData* d) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// precount sizes for constraint Jacobian matrices
|
// precount sizes for constraint Jacobian matrices
|
||||||
int *nnz = mj_isSparse(m) ? &(d->nnzJ) : NULL;
|
int *nnz = mj_isSparse(m) ? &(d->nJ) : NULL;
|
||||||
int ne_allocated = mj_ne(m, d, nnz);
|
int ne_allocated = mj_ne(m, d, nnz);
|
||||||
int nf_allocated = mj_nf(m, d, nnz);
|
int nf_allocated = mj_nf(m, d, nnz);
|
||||||
int nl_allocated = mj_nl(m, d, nnz);
|
int nl_allocated = mj_nl(m, d, nnz);
|
||||||
int nefc_allocated = ne_allocated + nf_allocated + nl_allocated + mj_nc(m, d, nnz);
|
int nefc_allocated = ne_allocated + nf_allocated + nl_allocated + mj_nc(m, d, nnz);
|
||||||
if (!mj_isSparse(m)) {
|
if (!mj_isSparse(m)) {
|
||||||
d->nnzJ = nefc_allocated * m->nv;
|
d->nJ = nefc_allocated * m->nv;
|
||||||
}
|
}
|
||||||
d->nefc = nefc_allocated;
|
d->nefc = nefc_allocated;
|
||||||
|
|
||||||
@@ -1998,12 +1998,11 @@ void mj_makeConstraint(const mjModel* m, mjData* d) {
|
|||||||
mjERROR("nefc mis-allocation: found nefc=%d but allocated %d", d->nefc, nefc_allocated);
|
mjERROR("nefc mis-allocation: found nefc=%d but allocated %d", d->nefc, nefc_allocated);
|
||||||
}
|
}
|
||||||
|
|
||||||
// check that nnzJ was computed correctly
|
// check that nJ was computed correctly
|
||||||
if (d->nefc > 0) {
|
if (d->nefc > 0) {
|
||||||
int nnzJ = d->efc_J_rownnz[d->nefc - 1] + d->efc_J_rowadr[d->nefc - 1];
|
int nJ = d->efc_J_rownnz[d->nefc - 1] + d->efc_J_rowadr[d->nefc - 1];
|
||||||
if (d->nnzJ != nnzJ) {
|
if (d->nJ != nJ) {
|
||||||
mjERROR("constraint Jacobian mis-allocation: found nnzJ=%d but allocated %d",
|
mjERROR("constraint Jacobian mis-allocation: found nJ=%d but allocated %d", nJ, d->nJ);
|
||||||
nnzJ, d->nnzJ);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
} else if (d->nefc > nefc_allocated) {
|
} else if (d->nefc > nefc_allocated) {
|
||||||
|
|||||||
@@ -1815,7 +1815,7 @@ static void _resetData(const mjModel* m, mjData* d, unsigned char debug_value) {
|
|||||||
d->nf = 0;
|
d->nf = 0;
|
||||||
d->nl = 0;
|
d->nl = 0;
|
||||||
d->nefc = 0;
|
d->nefc = 0;
|
||||||
d->nnzJ = 0;
|
d->nJ = 0;
|
||||||
d->nisland = 0;
|
d->nisland = 0;
|
||||||
|
|
||||||
// clear global properties
|
// clear global properties
|
||||||
|
|||||||
@@ -156,7 +156,7 @@ TEST_F(EngineIoTest, ResetVariableSizes) {
|
|||||||
EXPECT_EQ(data->ne, 0);
|
EXPECT_EQ(data->ne, 0);
|
||||||
EXPECT_EQ(data->nf, 0);
|
EXPECT_EQ(data->nf, 0);
|
||||||
EXPECT_EQ(data->nefc, 0);
|
EXPECT_EQ(data->nefc, 0);
|
||||||
EXPECT_EQ(data->nnzJ, 0);
|
EXPECT_EQ(data->nJ, 0);
|
||||||
EXPECT_EQ(data->ncon, 0);
|
EXPECT_EQ(data->ncon, 0);
|
||||||
|
|
||||||
mj_deleteData(data);
|
mj_deleteData(data);
|
||||||
|
|||||||
@@ -4851,7 +4851,7 @@ public unsafe struct mjData_ {
|
|||||||
public int nf;
|
public int nf;
|
||||||
public int nl;
|
public int nl;
|
||||||
public int nefc;
|
public int nefc;
|
||||||
public int nnzJ;
|
public int nJ;
|
||||||
public int nisland;
|
public int nisland;
|
||||||
public double time;
|
public double time;
|
||||||
public fixed double energy[2];
|
public fixed double energy[2];
|
||||||
|
|||||||
Reference in New Issue
Block a user