API

class vdx.Problem

Bases: handle, matlab.mixin.Copyable

A class represnting an NLP in the form:

TODO(@anton) figure out how to write the NLP in docs in a nice way

Parameters:

casadi_type (string) – either ‘SX’ (default) or ‘MX’ which determines the kind of CasADi symbolics uesd for all vdx.Vector.

Variables:

obj.w.x – This is a test

Property Summary
w

Primal variabiles

Type:

vdx.PrimalVector

g

Constraints

Type:

vdx.ConstraintVector

p

Parameters

Type:

vdx.ParameterVector

f

Objective

Type:

casadi.SX|casadi.MX

f_result

Objective value

Type:

double

solver_name

Solver name

Type:

char

solver

CasADi nlpsol object for the given problem. generated by create_solver() and is [] before the first time it is called.

Method Summary
create_solver(casadi_options, plugin)

Creates the CasADi nlpsol object based on the current symbolics in w, g, p, and f.

Parameters:
  • casadi_options (struct) – Options passed to casadi.nlpsol TODO(@anton) link to CasADi docs here.

  • plugin (char) – casadi.nlpsol plugin to use.

solve()
Solves the NLP with the data currently in w, g, p.

Populates the results and Lagrange multipliers fielts of the same. TODO(@anton) figure out how to link attrs of other classes

Returns:

Stats and nlp_results.

class vdx.Vector

Bases: handle, matlab.mixin.indexing.RedefinesDot, matlab.mixin.CustomDisplay, matlab.mixin.Copyable

A class which provides a wrapper around CasADi symbolics and tracks the indicies of vdx.Variable within it.

TODO(@anton) if mathworks ever fixes their bugs we can add back dynamic props. :param vdx.Problem problem: Problem which this vector is a member of. :param string casadi_type: either ‘SX’ (default) or ‘MX’ which determines the kind of CasADi symbolic stored.

Property Summary
sym

CasADi symbolic vector that is wrapped by this object.

Type:

casadi.SX|casadi.MX

casadi_type

Casadi type

problem

pointer to parent problem

Method Summary
print(varargin)

Pretty prints this vector with the specified columns.

Available columns are the strings in the union of numerical_properties and numerical_outputs, which are passed as string arguments to this method. Default prints all columns.

to_string(varargin)

obj.apply_queued_assignments();

sort_by_index()

Sorts this vector so that the vectors occur in column major order with lower dimensional vdx.Variable always occuring before higher dimensional vdx.Variable. This can be useful to recover any sparsity structure in the problem that comes from the structure of constaraints and variables.

add_variable_group(name, vars, varargin)

Adds a vdx.VariableGroup to this vector

class vdx.PrimalVector

Bases: vdx.Vector

A subclass of vdx.Vector for primal variables.

Parameters:
  • problem (vdx.Problem) – Problem which this vector is a member of.

  • casadi_type (string) – either ‘SX’ (default) or ‘MX’ which determines the kind of CasADi symbolic stored.

Numerical Properties:

lb (double): Lower bound ub (double): Upper bound

class vdx.ConstraintVector

Bases: vdx.Vector

A subclass of vdx.Vector for algebraic constraints.

Parameters:
  • problem (vdx.Problem) – Problem which this vector is a member of.

  • casadi_type (string) – either ‘SX’ (default) or ‘MX’ which determines the kind of CasADi symbolic stored.

Variables:
  • lb (double) – Lower bound.

  • ub (double) – Upper bound.

  • init_mult (double) – Initial value of bound multipliers.

  • eval (double) – Output: evaluation of constraint functions.

  • violation (double) – Output: violation of bounds.

  • mult (double) – Output: multiplier results for the bounds.

class vdx.ParameterVector

Bases: vdx.Vector

A subclass of vdx.Vector for parameters.

Parameters:
  • problem (vdx.Problem) – Problem which this vector is a member of.

  • casadi_type (string) – either ‘SX’ (default) or ‘MX’ which determines the kind of CasADi symbolic stored.

Variables:
  • val (double) – Value of the parameter.

  • mult (double) – Output: multiplier (sensitivity) of the problem to the parameter value.

class vdx.Variable

Bases: handle, matlab.mixin.indexing.RedefinesParen, matlab.mixin.indexing.RedefinesDot, matlab.mixin.CustomDisplay, matlab.mixin.Copyable

Property Summary
indices

Indices of this vdx.Variable in its :class:vdx.Vector.

Type:

cell

vector

vdx.Vector that this vdx.Variable is a member of.

name

name of this variable

depth

Number of indices supported by this variable.

Type:

double

Method Summary
to_string(varargin)

Pretty prints this variable with the specified columns.

Available columns are: ‘sym’, ‘lb’, ‘ub’, ‘init’, ‘res’, and ‘mult’, which are passed as string arguments to this method. Default outputs all columns.

print(varargin)

Pretty prints this variable with the specified columns.

Available columns are: ‘sym’, ‘lb’, ‘ub’, ‘init’, ‘res’, and ‘mult’, which are passed as string arguments to this method. Default prints all columns.

set_is_terminal(is_terminal)

This only does anything for scalar variables