Install

To use the framework in an Python environment, use the following command:

pip install parepy-toolbox
# or pip install --upgrade parepy-toolbox

Files structure

Let's use the example of building a problem in PAREpy using Jupyter Notebook or Python file. Therefore, the basic file structure that you must assemble to use the library must be as follows:

 .
 .
 .
 └── problem_directory
       └── of_file.py
       └── your_problem.ipynb # or your_problem.py
       └── file 0
       └── file 1
       └── file 2
       ...
       └── file n-1
       └── file n

The of_file.py file should contain the objective function of the problem. The your_problem file is the file that will contain the call to the main function and other settings necessary for the use of the algorithm.

of_file.py

of_file.py is a Python function, and the user needs to define it for PAREpy to work. of_file.py has a fixed structure that must be respected, as described below:

def my_function(x, none_variable):
    # add your code
    return r, s, g

of_file.py has two parameters:

  • x (type list): list of design random variables. PAREpy generates this values
  • none_variable (type None, list, float, dictionary, str or any): The user can define this variable. The user can input any value in this variable when calling the framework's main function

of_file.py has three returns:

  • r (type list): list of values. In structural problems, we recommend putting the capacity in this variable;
  • s (type list): list of values. In structural problems, we recommend putting the demand in this variable;
  • g (type list): State limit function \(\mathbf{G} = \mathbf{R} - \mathbf{S}\).

The lists r, s and g must have the same size and will be defined in the main function setup.

To demostrate how to create a object function we use Beck [1] example. The State Limit Function is given by:

\[ \mathbf{G} = \mathbf{R}_d - \mathbf{D} - \mathbf{L} \]

(1)

def example_function(x, none_variable):
    """Beck example
    """

    # random variables statement  
    r_d = x[0]
    d = x[1]
    l = x[2]

    # state limite function
    r = r_d
    s = d + l
    g = r - s

    return [r], [s], [g]

# or

def example_function(x, none_variable):
    """Beck example
    """

    # random variables statement  
    r_d = x[0]
    d = x[1]
    l = x[2]

    # state limite function
    g = r_d - d - l

    return [r_d], [d+l], [g]

# or

def example_function(x, none_variable):
    """Beck example
    """

    # random variables statement  
    r_d = x[0]
    d = x[1]
    l = x[2]

    # state limite function
    r = [r_d]
    s = [d + l]
    g = [r - s]

    return r, s, g

Using two state limit functions:

\[ \mathbf{G}_0 = \mathbf{R}_d - \mathbf{D} - \mathbf{L} \]

(1)

\[ \mathbf{G}_1 = \mathbf{\sigma _y} \cdot \mathbf{W} - \mathbf{M} \]

(2)

def example_function(x, none_variable):
    """Beck example
    """

    # random variables statement g_0
    r_d = x[0]
    d = x[1]
    l = x[2]

    # random variables statement g_1
    sigma_y = x[3]
    w = x[4]
    m = x[5]

    # state limite function g_0
    r_0 = r_d
    s_0 = d + l
    g_0 = r_0 - s_0

    # state limite function g_1
    r_1 = sigma_y * w
    s_1 = m
    g_1 = r_1 - s_1


    return [r_0, r_1], [s_0, s_1], [g_0, g_1]

Reference list


Table of contents