Preparing and applying an optimization design

The examples assume a loaded Reader model named deck. In JavaScript, oor and solver are the loaded WASM modules. In Python, deck comes from oo_reader.read_model. See Getting started for package setup.

Reader supplies the model and design declarations to optimization loops written in JavaScript or Python. Solver computes the analyses, response derivatives, Jacobian products and supported Hessian products. See the Solver optimization guide for the complete iteration API, matrix conventions, callbacks and derivative limits. For parameters and response fields outside native design declarations, see the external optimization guide. It covers SOL 101, 103, 105 and 144, generic card/case updates, numerical derivatives, parallel workers and accepted-point archives.

oor.designCapabilities(deck) lists Reader’s editable card types, pending design problems, declarations it cannot apply, and the general card-editing and model-document facilities. Solver’s capabilities(model) and checkOptimization(model, declarations, settings) describe its supported analyses and native design fields.

Inspect variables and export declarations

JavaScript / WebAssembly

const design = oor.designVariables(deck);
console.log(design.variables, design.problems, design.notApplied);

// Independent owned buffers; safe to transfer to another module or worker.
const tables = oor.optimizationTables(deck);

Python / native C++

deck.validate_design()
variables = deck.query("designVariablesTable")
print(len(variables), variables.columns)

designVariables returns ID, label, initial value, bounds, move limit and dependency flag for every variable. problems lists declarations that prevent a valid design point. notApplied lists declarations that the Reader cannot write, with their card type, ID and reason.

optimizationTables exports the typed design variables, links, relations, constants, shape terms, compiled equations, responses, response arguments, constraints, constraint unions, subcase selections and screening rules. Each value is the corresponding query’s table package. No pointer into Reader memory is given to Solver. The optional IsoMat.sourceBlankFields card column identifies which of E, G or Poisson ratio was blank in the source. Solver uses it to recompute that implicit elastic constant at each designed point and perturbation.

The model and package formats are unchanged. Existing named queries still expose their complete design metadata; use runQuery and queryCatalogue when an application needs a particular table or selection.

Connect the solver

JavaScript / WebAssembly

const problem = solver.optimizationFromReader(oor, deck, {
  responses: [{ id: 101, type: "Volume", label: "volume" }],
  objective: { responseId: 101 },
});
const info = problem.metadata();
const point = problem.evaluate(info.initialValues);
try {
  console.log(point.values(), point.gradients());
} finally {
  point.delete();
  problem.delete();
}

Python / native C++

Declare response 101 and the objective in the input model for the Python example.

from oo_solver import optimization_from_reader

problem = optimization_from_reader(deck)
point = problem.evaluate(problem.initial_values)
print(point.objective, point.gradients()["objective"])

The application imports both built modules. The deck must define the variables and relations used by this example. The solver owns an immutable snapshot: trial evaluations never modify the Reader model. Edits to the deck require rebuilding the solver problem.

Apply the accepted point

JavaScript / WebAssembly

const ids = Array.from(info.independentIndices, i => info.variables[i].id);
const update = oor.applyDesignPoint(deck, ids, acceptedX);
console.log(update.changedFields, update.movedGrids);
const text = deck.toModelText();
deck.writeArchive("/work/accepted-model.ooh5"); // save the accepted model as native columns

Python / native C++

ids = [v["id"] for v in problem.variables]
accepted = deck.with_design_point(ids, accepted_x)
accepted.write_archive("accepted-model.ooh5")

Python returns a copy at the accepted point. The original deck remains available for another trial.

The IDs are explicit because Solver’s vector contains independent variables only, whereas Reader lists all variables. IDs must be distinct, defined, independent positive integers; values must be finite and within variable bounds. Omitted independent variables keep their initial value. Linked variables are computed from their links.

The operation reads the current design, evaluates relations and supported shape moves, then writes the point atomically. A validation failure leaves the model unchanged. It refuses unsupported declarations and field limit violations by default. Optional limits: "clip" | "ignore" changes the field limit policy; variable bounds remain checked.

setInitialValues defaults to true: the design variable cards are saved at the accepted point. Shape initial values and grid coordinates remain consistent, so applying the same point again does not repeat a shape move. The report includes each field’s before, requested and after values, clipping status and changed flag.

To save the accepted model with its result tables, attach it to the result set and call results.writeArchive. An archive reopened through results.model() shares its deck with subsequent archive writes. See model/results archives for ownership and loading behavior.

Declarations added only to the solver from JavaScript do not automatically create Reader cards. Add their declarations to the model before using applyDesignPoint, or write the final fields through the existing card-editing interface. Reader evaluates and writes design relations; derivatives of structural responses belong to Solver.