Beispiel #1
0
    Dict session() const{
			onion_dict *d=onion_request_get_session_dict(ptr);
			if (d)
				return Dict(d);
			else
				return Dict();
    }
Beispiel #2
0
 const Dict files() const{
   const onion_dict *d=onion_request_get_file_dict(ptr);
   if (d)
     return Dict(d);
   else
     return Dict();
 }
Beispiel #3
0
    const Dict post() const{
			const onion_dict *d=onion_request_get_post_dict(ptr);
			if (d)
				return Dict(d);
			else
				return Dict();
    }
Beispiel #4
0
namespace casadi {

  /** \brief  Load an external function
   * File name is assumed to be ./<f_name>.so
   */
  CASADI_EXPORT Function external(const std::string& name, const Dict& opts=Dict());

  /** \brief  Load an external function
   * File name given
   */
  CASADI_EXPORT Function external(const std::string& name, const std::string& bin_name,
                                  const Dict& opts=Dict());

  /** \brief  Load a just-in-time compiled external function
   * File name given
   */
  CASADI_EXPORT Function external(const std::string& name, const Compiler& compiler,
                                  const Dict& opts=Dict());

#ifndef SWIG
  /** \brief  Load an external function
   * Library given
   */
  CASADI_EXPORT Function external(const std::string& name, Library li,
                                  const Dict& opts=Dict());
#endif // SWIG

} // namespace casadi
Beispiel #5
0
namespace casadi {

  /** \brief Create a just-in-time compiled function from a C/C++ language string
   * The function can an arbitrary number of inputs and outputs that must all be
   * scalar-valued.
   * Only specify the function body, assuming that the inputs are stored in an array
   * named 'arg' and the outputs stored in an array named 'res'. The data type
   * used must be 'real_t', which is typically equal to 'double` or another data
   * type with the same API as 'double'.
   *
   * The final generated function will have a structure similar to:
   * 
   * void fname(const real_t* arg, real_t* res) {
   *   <FUNCTION_BODY>
   * }
   *
   */
  CASADI_EXPORT Function jit(const std::string& name, int n_in, int n_out,
                             const std::string& body, const Dict& opts=Dict());

#ifndef SWIG
  /** \brief Create a just-in-time compiled function from a .casadi file
   */
  CASADI_EXPORT Function jit(const ParsedFile& file);
#endif // SWIG

} // namespace casadi
Beispiel #6
0
DictionaryT* get_command_dict() {

    static DictionaryT* command_dict = NULL;

    if (command_dict == NULL) {
        command_dict = Dict();
        dict_add(command_dict, "n", &execute_new);
        dict_add(command_dict, "new", &execute_new);
        dict_add(command_dict, "f", &execute_finish);
        dict_add(command_dict, "finish", &execute_finish);
        dict_add(command_dict, "s", &execute_show);
        dict_add(command_dict, "show", &execute_show);
        dict_add(command_dict, "a", &execute_add_note);
        dict_add(command_dict, "add", &execute_add_note);
        dict_add(command_dict, "l", &execute_load);
        dict_add(command_dict, "load", &execute_load);
        dict_add(command_dict, "w", &execute_save);
        dict_add(command_dict, "write", &execute_save);
        dict_add(command_dict, "print", &execute_print);
        dict_add(command_dict, "p", &execute_print);
        dict_add(command_dict, "c", &execute_change);
        dict_add(command_dict, "change", &execute_change);
    }

    return command_dict;
}
void ff::Dict::SetDict(StringRef name, const Dict &value)
{
	ValuePtr newValue;
	assertRet(Value::CreateDict(Dict(value), &newValue));

	SetValue(name, newValue);
}
Beispiel #8
0
 static std::string toString(const std::pair<T1, T2>& x, const Field& field)
 {
     Format fs = (field.subformats.size()
                  ? field.subformats[0]
                  : fmt("({*1}, {*2})"));
     return fs % Dict()
         ("*1", x.first)
         ("*2", x.second);
 }
Beispiel #9
0
 Function Map::create(const std::string& parallelization, const Function& f, int n) {
   // Create instance of the right class
   string name = f.name() + "_" + to_string(n);
   Function ret;
   if (parallelization == "serial") {
     ret.assignNode(new Map(name, f, n));
   } else if (parallelization== "openmp") {
     ret.assignNode(new MapOmp(name, f, n));
   } else {
     casadi_error("Unknown parallelization: " + parallelization);
   }
   // Finalize creation
   ret->construct(Dict());
   return ret;
 }
Beispiel #10
0
namespace casadi {

  /** \defgroup main_expm

      Performs a matrix exponentiation
      expm(A)


      \generalsection{Expm}
      \pluginssection{Expm}

      \author Joris Gillis
      \date 2017
  */

  /** \defgroup expm
  * @copydoc main_expm
  *  @{
  */

  /** \if EXPANDED
  * @copydoc main_expm
  * \endif
  */
  ///@{
  CASADI_EXPORT Function expmsol(const std::string& name, const std::string& solver,
                           const Sparsity& A, const Dict& opts=Dict());
  ///@}

  /** \brief Get the number of expm solver inputs */
  CASADI_EXPORT casadi_int expm_n_in();

  /** \brief Get the number of expm solver outputs */
  CASADI_EXPORT casadi_int expm_n_out();

  /// Check if a particular plugin is available
  CASADI_EXPORT bool has_expm(const std::string& name);

  /// Explicitly load a plugin dynamically
  CASADI_EXPORT void load_expm(const std::string& name);

  /// Get the documentation string for a plugin
  CASADI_EXPORT std::string doc_expm(const std::string& name);

  /** @} */
} // namespace casadi
// *****************************************************************************
FilterBy &FilterBy::op(const std::string &logicOperator,
                       const std::string &path,
                       const std::string &relation,
                       const xmlrpc_c::value &value)
{
    // -------------------------------------------------------------------
    // The new simple condition
    Dict newCondition = Dict("path", path)
                        .add("relation", relation);

    // The value has to be converted to an array
    List valueList;
    if (value.type() == xmlrpc_c::value::TYPE_ARRAY)
    {
        fromXmlrpcValue(value, valueList);
    }
    else
    {
        valueList.append(value);
    }
    newCondition.add("values", valueList);
 
    // -------------------------------------------------------------------
    // Add the new simple condition to the conditions list
    List conditions;
    if (!m_filters.empty()) 
    {
        // The Original m_filters map now becomes a condition
        conditions.append(m_filters);
    }
    conditions.append(newCondition);

    // -------------------------------------------------------------------
    // Update the filters
    m_filters.clear();
    m_filters.add("logical_operator", logicOperator)
             .add("conditions", conditions);

    return *this;
}
Beispiel #12
0
		/**
		 * @short Returns a subdictionary.
		 * 
		 * For a given key, returns the subdictionary.
		 */
		Dict getDict(const std::string &k) const{
			return Dict(onion_dict_get_dict(ptr, k.c_str()));
		}
Beispiel #13
0
		/**
		 * @short Creates a real copy of all the elements on the dictionary.
		 */
		Dict hard_dup() const{
			return Dict(onion_dict_hard_dup(ptr), true);
		}
Beispiel #14
0
    // Creator function for internal class
    typedef Integrator* (*Creator)(const std::string& name, const Function& oracle);

    // No static functions exposed
    struct Exposed{ };

    /// Collection of solvers
    static std::map<std::string, Plugin> solvers_;

    /// Infix
    static const std::string infix_;

    /// Convert dictionary to Problem
    template<typename XType>
      static Function map2oracle(const std::string& name,
        const std::map<std::string, XType>& d, const Dict& opts=Dict());
  };

  struct CASADI_EXPORT FixedStepMemory : public IntegratorMemory {
    // Current time
    double t;

    // Discrete time
    int k;

    // Current state
    std::vector<double> x, z, p, q, rx, rz, rp, rq;

    // Previous state
    std::vector<double> x_prev, Z_prev, q_prev, rx_prev, RZ_prev, rq_prev;
Beispiel #15
0
 const Dict headers() const{
   return Dict(onion_request_get_header_dict(ptr));
 }
Beispiel #16
0
 /** \brief Computes the Moore-Penrose pseudo-inverse
  *
  * If the matrix A is fat (size1>size2), mul(A, pinv(A)) is unity.
  * If the matrix A is slender (size2<size1), mul(pinv(A), A) is unity.
  *
  */
 friend inline MatType pinv(const MatType& A, const std::string& lsolver,
                            const Dict& dict = Dict()) {
   return MatType::pinv(A, lsolver, dict);
 }
Beispiel #17
0
  MX variable(casadi_int n=1, casadi_int m=1, const std::string& attribute="full");

  /// Create a parameter (symbol); fixed during optimization
  MX parameter(casadi_int n=1, casadi_int m=1, const std::string& attribute="full");

  /// Set objective
  void minimize(const MX& f);

  /// brief Add constraints
  void subject_to(const MX& g);
  /// Clear constraints
  void subject_to();

  /// Solver
  void solver(const std::string& solver,
              const Dict& plugin_options=Dict(),
              const Dict& solver_options=Dict());

  /// @{
  /// Set initial value for decision variables
  void set_initial(const MX& x, const DM& v);
  void set_initial(const std::vector<MX>& assignments);
  /// @}

  /// @{
  /** \brief Set value of parameter
  *
  * Each parameter must be given a value before 'solve' can be called
  */
  void set_value(const MX& x, const DM& v);
  void set_value(const std::vector<MX>& assignments);
Beispiel #18
0
 /** \brief Forward directional derivative */
 friend inline std::vector<std::vector<MatType> >
 forward(const std::vector<MatType> &ex, const std::vector<MatType> &arg,
         const std::vector<std::vector<MatType> > &v,
         const Dict& opts = Dict()) {
   return MatType::forward(ex, arg, v, opts);
 }
Beispiel #19
0
namespace casadi {

  ///@{
  /** \brief Obtain collocation points of specific order and scheme
  \param scheme  'radau' or 'legendre'
  **/
  CASADI_EXPORT
    std::vector<double> collocationPoints(int order, const std::string& scheme="radau");
#ifndef SWIG
  CASADI_EXPORT
    std::vector<long double> collocationPointsL(int order, const std::string& scheme="radau");
#endif // SWIG
  ///@}

  /** \brief Obtain collocation interpolating matrices
  \param tau_root  location of collocation points, as obtained from collocationPoints
  \param[out] C interpolating coefficients to obtain derivatives
      Length: order+1, order + 1

    \verbatim
      dX/dt @collPoint(j) ~ Sum_i C[j][i]*X@collPoint(i)
    \endverbatim
    
  \param[out] D interpolating coefficients to obtain end state
      Length: order+1
  */
#ifndef SWIG
  CASADI_EXPORT
    void collocationInterpolators(const std::vector<double> & tau_root,
                                  std::vector< std::vector<double> > &C,
                                  std::vector< double > &D);
#else // SWIG
  CASADI_EXPORT
    void collocationInterpolators(const std::vector<double> & tau_root,
                                  std::vector< std::vector<double> > &OUTPUT,
                                  std::vector< double > &OUTPUT);
#endif // SWIG

  // Type of collocation points
  enum CollocationPoints {LEGENDRE, RADAU};

  /** \brief Construct an explicit Runge-Kutta integrator
   * The constructed function (which is of type MXFunction), has three inputs,
   * corresponding to initial state (x0), parameter (p) and integration time (h)
   * and one output, corresponding to final state (xf).
   *
   * \param f     ODE function with two inputs (x and p) and one output (xdot)
   * \param N     Number of integrator steps
   * \param order Order of interpolating polynomials
   */
  CASADI_EXPORT MXFunction simpleRK(Function f, int N=10, int order=4);

  /** \brief Construct an implicit Runge-Kutta integrator using a collocation scheme
   * The constructed function (which is of type MXFunction), has three inputs,
   * corresponding to initial state (x0), parameter (p) and integration time (h)
   * and one output, corresponding to final state (xf).
   *
   * \param f      ODE function with two inputs (x and p) and one output (xdot)
   * \param N      Number of integrator steps
   * \param order  Order of interpolating polynomials
   * \param scheme Collocation scheme, as excepted by collocationPoints function.
  */
  CASADI_EXPORT
  MXFunction simpleIRK(Function f, int N=10, int order=4, const std::string& scheme="radau",
                       const std::string& solver="newton",
                       const Dict& solver_options = Dict());

  /** \brief Simplified wrapper for the Integrator class
   * Constructs an integrator using the same syntax as simpleRK and simpleIRK.
   * The constructed function (which is of type MXFunction), has three inputs,
   * corresponding to initial state (x0), parameter (p) and integration time (h)
   * and one output, corresponding to final state (xf).
   *
   * \param f      ODE function with two inputs (x and p) and one output (xdot)
   * \param N      Number of integrator steps
   * \param order  Order of interpolating polynomials
   * \param scheme Collocation scheme, as excepted by collocationPoints function.
  */
  CASADI_EXPORT
  MXFunction simpleIntegrator(Function f, const std::string& integrator="cvodes",
                              const Dict& integrator_options = Dict());
} // namespace casadi
Beispiel #20
0
 std::string str(const T& x, const Format& f)
 {
     return f % Dict()("*", &x);
 }
Beispiel #21
0
 std::string str(const T& x, const std::string& f = "{*}")
 {
     bool abbrev = (f.find('{') == std::string::npos);
     return fmt(abbrev ? "{*:" + f + "}" : f) % Dict()("*", &x);
 }
Beispiel #22
0
		/**
		 * @short Convert a JSON string to an onion dictionary. 
		 * 
		 * This is not full JSON support, only dict side, and with strings.
		 */
		static ::Onion::Dict fromJSON(const std::string &jsondata){
			return Dict(onion_dict_from_json(jsondata.c_str()));
		}
Beispiel #23
0
 /** \brief Matrix inverse */
 inline friend MatType inv(const MatType& A,
   const std::string& lsolver,
   const Dict& options=Dict()) {
     return MatType::inv(A, lsolver, options);
 }
Beispiel #24
0
Classifier::Classifier() {
    this->features = Dict();
    this->labels = Dict();
}
Beispiel #25
0
 /** \brief Solve a system of equations: A*x = b
  */
 friend inline MatType solve(const MatType& A, const MatType& b,
                             const std::string& lsolver,
                             const Dict& dict = Dict()) {
   return MatType::solve(A, b, lsolver, dict);
 }
// *****************************************************************************
FilterBy::FilterBy() : m_filters(Dict())
{
}
Beispiel #27
0
 /** \brief Calculate Jacobian
 */
 inline friend MatType jacobian(const MatType &ex, const MatType &arg,
                                const Dict& opts = Dict()) {
   return MatType::jacobian(ex, arg, opts);
 }
Beispiel #28
0
 const Dict query() const{
   return Dict(onion_request_get_query_dict(ptr));
 }
Beispiel #29
0
 /** \brief Reverse directional derivative */
 friend inline std::vector<std::vector<MatType> >
 reverse(const std::vector<MatType> &ex, const std::vector<MatType> &arg,
         const std::vector<std::vector<MatType> > &v,
         const Dict& opts = Dict()) {
   return MatType::reverse(ex, arg, v, opts);
 }
Beispiel #30
0
            with
                U: horzcat([u0, u1, ..., u_(N-1)])
                X: horzcat([x1, x2, ..., x_N])
                Y: horzcat([y0, y1, ..., y_(N-1)])

            and
                x1, y0 <- f(x0, u0)
                x2, y1 <- f(x1, u1)
                ...
                x_N, y_(N-1) <- f(x_(N-1), u_(N-1))
        \endverbatim


    */
    Function mapaccum(const std::string& name, int n, int n_accum=1,
                      const Dict& opts = Dict()) const;
    Function mapaccum(const std::string& name, int n,
                      const std::vector<int>& accum_in,
                      const std::vector<int>& accum_out,
                      const Dict& opts=Dict()) const;
    Function mapaccum(const std::string& name, int n,
                      const std::vector<std::string>& accum_in,
                      const std::vector<std::string>& accum_out,
                      const Dict& opts=Dict()) const;
    ///@}

    /** \brief  Create a mapped version of this function

        Suppose the function has a signature of:
        \verbatim
           f: (a, p) -> ( s )