File kernel/src/simulationTools/OneStepNSProblem.hpp

Go to the source code of this file

Interface to formalize and solve Non-Sooth problems.

class OneStepNSProblem
#include <OneStepNSProblem.hpp>

Non Smooth Problem Formalization and Simulation.

This is an abstract class, that provides an interface to define a non smooth problem:

  • a formulation (ie the way the problem is written)

  • a solver (algorithm and solving formulation, that can be different from problem formulation)

  • routines to compute the problem solution.

Two types of problem formulation are available :

  • Quadratic Problem

  • Linear Problem

See derived classes (QP and LinearOSNS) for details.

For Linear problems, the following formulations exists:

The usual way to build and initialize a one-step nonsmooth problem is :

  • call constructor with the id of the required Numerics solver. (see Solver class or Numerics documentation for details on algorithm name and parameters).

  • initialize(simulation) Initialize process is usually done through model->initialize(simulation). See Examples for practical details.

Subclassed by LinearOSNS, QP

Public Functions

OneStepNSProblem(SP::SolverOptions options)

constructor from a pre-defined solver options set.


virtual ~OneStepNSProblem()


virtual int compute(double time) = 0

To run the solver for ns problem.


int information about the solver convergence.

  • time: current time

virtual void computeDiagonalInteractionBlock(const InteractionsGraph::VDescriptor &vd) = 0

compute diagonal Interaction block

  • vd: a vertex descriptor

virtual void computeInteractionBlock(const InteractionsGraph::EDescriptor &ed) = 0

compute extra-diagonal interactionBlock-matrix

  • ed: an edge descriptor

virtual void display() const
virtual void displayBlocks(SP::InteractionsGraph indexSet)

Display the set of blocks for a given indexSet.

  • indexSet: the concerned index set

SP::SimpleMatrix getOSIMatrix(OneStepIntegrator &osi, SP::DynamicalSystem ds)

get the OSI-related matrices used to compute the current InteractionBlock (Ex: for MoreauJeanOSI, W)


the required matrix.

  • osi: the OSI of the concerned dynamical system

  • ds: the concerned dynamical system

unsigned int getSizeOutput() const

returns the dimension of the nonsmooth problem

bool hasBeenUpdated()


bool _hasBeenUpdated

bool hasInteractions() const

Check if the OSNSPb has interactions.


bool = true if the osnsp has interactions, i.e. indexSet(_indexSetLevel)->size >0

unsigned int indexSetLevel() const

get indexSetLevel


an unsigned int

virtual void initialize(SP::Simulation sim)

initialize the problem(compute topology …)

  • sim: the simulation, owner of this OSNSPB

unsigned int inputOutputLevel() const

get the Input/Output level


an unsigned int

unsigned int maxSize() const

get maximum value allowed for the dimension of the problem


an unsigned int

SP::SolverOptions numericsSolverOptions() const

To get the SolverOptions structure.


, the numerics structure used to save solver parameters

virtual void postCompute() = 0

post treatment for output of the solver

virtual bool preCompute(double time) = 0

prepare data of the osns for solving


true if the computation of the OSNS has to be carry on, false otherwise

  • time: the current time

void setHasBeenUpdated(bool v)

  • v: to set _hasBeenUpdated.

void setIndexSetLevel(unsigned int newVal)

set the value of level min

  • newVal: an unsigned int

void setInputOutputLevel(unsigned int newVal)

set the value of Input/Output level

  • newVal: an unsigned int

void setMaxSize(const unsigned int newVal)

set the value of maxSize

  • newVal: an unsigned int

void setNumericsVerboseLevel(int level)

set the verbose level in numerics solver

void setNumericsVerboseMode(bool vMode)

Turn on/off verbose mode in numerics solver.

void setSimulationPtr(SP::Simulation newS)

set the Simulation of the OneStepNSProblem


void setSolverId(int solverId)

change the solver type and its default parameters.

  • clear memory for the existing options set

  • create and initialize a new one

Check the available solvers id in Nonsmooth problems formulations and available solvers.

  • solverId: the new solver.

SP::Simulation simulation() const

get the simulation which owns this nonsmooth problem


a pointer on Simulation

virtual void updateInteractionBlocks()

compute interactionBlocks if necessary (this depends on the type of OSNS, on the indexSets …)

Protected Functions


default constructor


Protected Attributes

bool _hasBeenUpdated = false
unsigned int _indexSetLevel = 0

level of index sets that is considered by this osnsp

unsigned int _inputOutputLevel = 0

level of input and output variables of the nonsmooth problems.

We consider that the osnsp computes y[_inputOutputLevel] and lambda[_inputOutputLevel]

unsigned int _maxSize = 0

maximum value for sizeOutput.

Set to the number of declared constraints by default (topology->getNumberOfConstraints()); This value is used to allocate memory for M during initialize call. The best choice is to set maxSize to the estimated maximum dimension of the problem. It must not exceed …

SP::SolverOptions _numerics_solver_options

Numerics solver properties.

SP::Simulation _simulation

link to the simulation that owns the nonsmooth problem

unsigned int _sizeOutput = 0

size of the nonsmooth problem

Private Functions

OneStepNSProblem(const OneStepNSProblem&)

copy constructor, forbidden

OneStepNSProblem &operator=(const OneStepNSProblem &osnsp)

assignment, forbidden