Minor fixes to viewer diagnostics
- When `mjData.nefc` was 0 (solver not run at all), we were plotting the stale diagnostics from the last run; now fixed. - In the case where islands were used, the semantic of the plotted diagnostic `sqrt_nnz` (square root of Hessian nonzeros) is changed. It used to be the sum of square roots of solver nonzeros per island, it is now the square root of the sum of all nonzeros in all islands. The semantic `sqrt(sum(nnz_i))` was found to be more consistent than `sum(sqrt(nnz_i))`, in the sense that switching islanding on/off leads to smaller changes and is more in line with the interpretation of islanding as [block-diagonalization](https://mujoco.readthedocs.io/en/3.3.7/computation/#constraint-islands). PiperOrigin-RevId: 827624908 Change-Id: I5fc86364ead585a4752a6d44823fb75cf6c7c318
This commit is contained in:
committed by
Copybara-Service
parent
501e561563
commit
abc02b736e
@@ -299,7 +299,7 @@ void UpdateProfiler(mj::Simulate* sim, const mjModel* m, const mjData* d) {
|
||||
memset(sim->figcost.linepnt, 0, mjMAXLINE*sizeof(int));
|
||||
|
||||
// number of islands that have diagnostics
|
||||
int nisland = mjMAX(1, mjMIN(d->nisland, mjNISLAND));
|
||||
int nisland = d->nefc ? mjMAX(1, mjMIN(d->nisland, mjNISLAND)) : 0;
|
||||
|
||||
// iterate over islands
|
||||
for (int k=0; k < nisland; k++) {
|
||||
@@ -403,9 +403,10 @@ void UpdateProfiler(mj::Simulate* sim, const mjModel* m, const mjData* d) {
|
||||
mjtNum sqrt_nnz = 0;
|
||||
int solver_niter = 0;
|
||||
for (int island=0; island < nisland; island++) {
|
||||
sqrt_nnz += mju_sqrt(d->solver_nnz[island]);
|
||||
sqrt_nnz += d->solver_nnz[island];
|
||||
solver_niter += d->solver_niter[island];
|
||||
}
|
||||
sqrt_nnz = mju_sqrt(sqrt_nnz);
|
||||
|
||||
// get sizes: nv, nbody, nefc, sqrt(nnz), ncont, iter
|
||||
float sdata[6] = {
|
||||
|
||||
@@ -634,14 +634,15 @@ void App::UpdateProfilerData() {
|
||||
cpu_other_.erase(cpu_other_.begin());
|
||||
cpu_other_.push_back(other);
|
||||
|
||||
// Dimensions.
|
||||
// Solver diagnostics.
|
||||
mjtNum sqrt_nnz = 0;
|
||||
int solver_niter = 0;
|
||||
const int nisland = mjMAX(1, mjMIN(Data()->nisland, mjNISLAND));
|
||||
for (int island = 0; island < nisland; island++) {
|
||||
sqrt_nnz += mju_sqrt(Data()->solver_nnz[island]);
|
||||
const int nisland = Data()->nefc ? mjMAX(1, mjMIN(Data()->nisland, mjNISLAND)) : 0;
|
||||
for (int island=0; island < nisland; island++) {
|
||||
sqrt_nnz += Data()->solver_nnz[island];
|
||||
solver_niter += Data()->solver_niter[island];
|
||||
}
|
||||
sqrt_nnz = mju_sqrt(sqrt_nnz);
|
||||
|
||||
dim_dof_.erase(dim_dof_.begin());
|
||||
dim_dof_.push_back(Model()->nv);
|
||||
|
||||
Reference in New Issue
Block a user