Skip to content

Commit f05b8d7

Browse files
committed
Apply pre-commmit fixes
1 parent baa1c9d commit f05b8d7

File tree

5 files changed

+873
-831
lines changed

5 files changed

+873
-831
lines changed

src/opflow/interface/opflow.cpp

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1797,15 +1797,14 @@ PetscErrorCode OPFLOWSetUp(OPFLOW opflow) {
17971797

17981798
ierr = MatCreate(opflow->comm->type, &opflow->Hes);
17991799
CHKERRQ(ierr);
1800-
ierr = MatSetSizes(opflow->Hes, opflow->nx, opflow->nx,
1801-
opflow->Nx, opflow->Nx);
1800+
ierr =
1801+
MatSetSizes(opflow->Hes, opflow->nx, opflow->nx, opflow->Nx, opflow->Nx);
18021802
CHKERRQ(ierr);
18031803
ierr = MatSetFromOptions(opflow->Hes);
18041804
CHKERRQ(ierr);
18051805
ierr = MatSeqAIJSetPreallocation(opflow->Hes, 6, NULL);
18061806
CHKERRQ(ierr);
1807-
ierr = MatSetOption(opflow->Hes, MAT_NEW_NONZERO_ALLOCATION_ERR,
1808-
PETSC_FALSE);
1807+
ierr = MatSetOption(opflow->Hes, MAT_NEW_NONZERO_ALLOCATION_ERR, PETSC_FALSE);
18091808
CHKERRQ(ierr);
18101809

18111810
/* Create natural to sparse dense ordering mapping (needed for some models)

src/opflow/model/power_bal_hiop/paramsrajahiop.h

Lines changed: 18 additions & 16 deletions
Original file line numberDiff line numberDiff line change
@@ -196,12 +196,12 @@ struct LINEParamsRajaHiop {
196196
constraint bound */
197197
int *linelimidx; /* Indices for subset of lines that have finite limits */
198198

199-
int *busf_idx; /* From bus index */
200-
int *bust_idx; /* To bus index */
201-
int *jacf_idx; /* Location number in the sparse Jacobian (from) */
202-
int *jact_idx; /* Location number in the sparse Jacobian (to) */
203-
int *jac_ieq_idx;/* Location number in sparse inequality Jacobian */
204-
int *hesssp_idx; /* Location number in sparse Hessian */
199+
int *busf_idx; /* From bus index */
200+
int *bust_idx; /* To bus index */
201+
int *jacf_idx; /* Location number in the sparse Jacobian (from) */
202+
int *jact_idx; /* Location number in the sparse Jacobian (to) */
203+
int *jac_ieq_idx; /* Location number in sparse inequality Jacobian */
204+
int *hesssp_idx; /* Location number in sparse Hessian */
205205

206206
// Device data
207207
double *Gff_dev_; /* From side self conductance */
@@ -226,12 +226,12 @@ struct LINEParamsRajaHiop {
226226
int *
227227
linelimidx_dev_; /* Indices for subset of lines that have finite limits */
228228

229-
int *busf_idx_dev_; /* From bus index */
230-
int *bust_idx_dev_; /* To bus index */
231-
int *jacf_idx_dev_; /* Location number in the sparse Jacobian (from) */
232-
int *jact_idx_dev_; /* Location number in the sparse Jacobian (to) */
233-
int *jac_ieq_idx_dev_;/* Location number in sparse inequality Jacobian */
234-
int *hesssp_idx_dev_; /* Location number in sparse Hessian */
229+
int *busf_idx_dev_; /* From bus index */
230+
int *bust_idx_dev_; /* To bus index */
231+
int *jacf_idx_dev_; /* Location number in the sparse Jacobian (from) */
232+
int *jact_idx_dev_; /* Location number in the sparse Jacobian (to) */
233+
int *jac_ieq_idx_dev_; /* Location number in sparse inequality Jacobian */
234+
int *hesssp_idx_dev_; /* Location number in sparse Hessian */
235235

236236
int allocate(OPFLOW);
237237
int destroy(OPFLOW);
@@ -267,12 +267,14 @@ struct PbpolModelRajaHiop : public _p_FormPBPOLRAJAHIOP {
267267
// GPU sparse model)
268268
int *i_jaceq,
269269
*j_jaceq; // Row and column indices for equality constrained Jacobian
270-
int *idx_jaceq_dev_; // Permuted triplet indexes for equality constrained Jacobian (on-device)
270+
int *idx_jaceq_dev_; // Permuted triplet indexes for equality constrained
271+
// Jacobian (on-device)
271272
int *i_jacineq,
272273
*j_jacineq; // Row and column indices for inequality constrained Jacobain
273-
int *idx_jacineq_dev_; // Permuted triplet indexes for inequality constrained Jacobian (on-device)
274-
int *i_hess, *j_hess; // Row and column indices for hessian
274+
int *idx_jacineq_dev_; // Permuted triplet indexes for inequality constrained
275+
// Jacobian (on-device)
276+
int *i_hess, *j_hess; // Row and column indices for hessian
275277
double *val_jaceq, *val_jacineq,
276-
*val_hess; // values for equality, inequality jacobians and hessian
278+
*val_hess; // values for equality, inequality jacobians and hessian
277279
int *idx_hess_dev_; // Permuted triplet indexes for Hessian (on-device)
278280
};

src/opflow/model/power_bal_hiop/pbpolrajahiopsparse.cpp

Lines changed: 16 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -234,7 +234,7 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
234234

235235
PSBUS bus = &(ps->bus[ibus]);
236236

237-
// Nonzero entries used by each *bus* starts here
237+
// Nonzero entries used by each *bus* starts here
238238

239239
// no matter what, each bus uses 2 rows and 2 columns
240240
// row 1 = real, row2 = reactive
@@ -243,11 +243,11 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
243243
nnz_eqjac += 2;
244244
busparams->jacsq_idx[ibus] = nnz_eqjac;
245245
nnz_eqjac += 2;
246-
246+
247247
if (bus->ide == ISOLATED_BUS) {
248248
continue;
249249
}
250-
250+
251251
if (opflow->include_powerimbalance_variables) {
252252
// 2 more entries on both real and reactive
253253
nnz_eqjac += 4;
@@ -264,7 +264,7 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
264264
genparams->eqjacsqbus_idx[igen1] = nnz_eqjac++;
265265
igen1++;
266266
}
267-
267+
268268
if (opflow->include_loadloss_variables) {
269269
// each load adds one real and reactive entry on each bus row
270270
// NOTE: iload is a system load counter
@@ -275,13 +275,12 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
275275
}
276276
}
277277

278-
279278
if (opflow->has_gensetpoint) {
280279
for (int bgen = 0; bgen < bus->ngen; ++bgen) {
281280
PSGEN gen;
282281
ierr = PSBUSGetGen(bus, bgen, &gen);
283282
CHKERRQ(ierr);
284-
283+
285284
if (!gen->status || gen->isrenewable)
286285
continue;
287286

@@ -297,10 +296,10 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
297296

298297
for (int iline = 0; iline <= ps->nline; ++iline) {
299298
PSLINE line = &(ps->line[iline]);
300-
299+
301300
if (!line->status)
302301
continue;
303-
302+
304303
// each line adds 4 (off-diagonal) entries for the to bus and 4
305304
// entries for the from bus. Each line also modifies 4 existing
306305
// to and from bus entries.
@@ -338,11 +337,11 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
338337
PSBUS bus = &(ps->bus[ibus]);
339338
if (bus->ide == PV_BUS || bus->ide == REF_BUS) {
340339
for (int bgen = 0; bgen < bus->ngen; ++bgen) {
341-
PSGEN gen;
342-
ierr = PSBUSGetGen(bus, bgen, &gen);
343-
CHKERRQ(ierr);
344-
if (!gen->status)
345-
continue;
340+
PSGEN gen;
341+
ierr = PSBUSGetGen(bus, bgen, &gen);
342+
CHKERRQ(ierr);
343+
if (!gen->status)
344+
continue;
346345
}
347346
nnz_ineqjac += 2;
348347
}
@@ -357,8 +356,8 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
357356
}
358357
}
359358

360-
std::cout << "Inequality Jacobian nonzero count: " << nnz_ineqjac << std::endl;
361-
359+
std::cout << "Inequality Jacobian nonzero count: " << nnz_ineqjac
360+
<< std::endl;
362361

363362
// Count non-zeros in *upper triangular* Hessian
364363

@@ -375,7 +374,6 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
375374
if (opflow->include_powerimbalance_variables) {
376375
nnz_hesssp += 2;
377376
}
378-
379377
}
380378

381379
for (int i = 0, igen = 0; i < ps->ngen; ++i) {
@@ -402,19 +400,18 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
402400
igen++;
403401
}
404402

405-
for (int iline=0; iline < ps->nline; ++iline) {
403+
for (int iline = 0; iline < ps->nline; ++iline) {
406404
PSLINE line = &(ps->line[iline]);
407405

408406
if (!line->status)
409407
continue;
410-
408+
411409
lineparams->hesssp_idx[iline] = nnz_hesssp;
412410

413411
// 3 diagonal entries for on the from-bus rows (already defined)
414412
// 3 diagonal entries for on the to-bus rows (already defined)
415413
// 4 off-diagonal entries in upper part
416414
nnz_hesssp += 4;
417-
418415
}
419416

420417
if (opflow->include_loadloss_variables) {
@@ -426,7 +423,6 @@ PetscErrorCode OPFLOWModelSetUp_PBPOLRAJAHIOPSPARSE(OPFLOW opflow) {
426423

427424
std::cout << "Hessian nonzero count: " << nnz_hesssp << std::endl;
428425

429-
430426
ierr = busparams->copy(opflow);
431427
ierr = genparams->copy(opflow);
432428
ierr = lineparams->copy(opflow);

0 commit comments

Comments
 (0)