Verteego Doc
  • Getting started
    • About Verteego
    • Sample Use Cases
    • Concepts
  • Data
    • Introduction
    • Datasources
      • URL connector specification
    • Datasets
  • Pipelines
    • Forecasting Pipelines
      • Getting started
      • Configuration
        • Identifying and preparing data
          • calculated_cols
          • cols_type
          • date_col
          • normalize
          • preprocessing
          • prediction_resolution
        • Configuring the Forecasting Algorithm
          • algo_name
          • algo_type
          • algorithm_parameters
          • fit_parameters
          • conditional_algorithm_parameters
        • Building the Training and Prediction Set
          • column_to_predict
          • features
          • input_prediction_columns
        • Using Hyperparameter Tuning for the Model
          • tuning_search_params
          • hyperparameter_tuning_parameters
        • Evaluating the Results of the Forecast
          • scores
        • Modifying the results of the forecast
          • postprocessing
      • Calculators
        • External source
          • get_from_dataset
          • weather
        • Mathematic
          • aggregate_val_group_by_key
          • binary_operation
          • count_rows_by_keys
          • hierarchical_aggregate
          • mathematical_expression
          • unary_operation
          • Moving Average (EWM)
        • Machine Learning
          • pca
          • clustering
          • glmm_encoder
          • one_hot_encode
          • words_similarity
        • Transformation
          • fillna
          • fill_series
          • case_na
          • interval_index
          • constant
          • cyclic
          • replace
        • Temporal
          • bank_holidays_countdown
          • bankholidays
          • date_attributes
          • date_weight
          • day_count
          • duration
          • events_countdown
          • seasonality
          • tsfresh
    • Optimization Pipelines
      • Getting started
      • Configuration
      • Constraints
        • Unary Constraint
        • Binary Constraint
        • Aggregation Constraint
        • Order Constraint
        • Multiplicative Equality Constraint
        • Generate constraints from a Dataset
  • Apps
    • About Apps
    • Recipes
      • Pipelines
      • Datasets
  • Users
    • User roles
  • Best practices
    • Performance analysis and ML model improvement
  • Developers
    • API
    • Change logs
Powered by GitBook
On this page
  • Overview
  • 1. Optimisation of a variable
  • v1 - Launching our first pipeline run
  • v2 - Adding more constraints
  • 2. Scenario selection
  • v1 - Launching our first pipeline run
  • v2 - Adding more constraints
  1. Pipelines
  2. Optimization Pipelines

Getting started

My first Optimization

PreviousOptimization PipelinesNextConfiguration

Last updated 1 year ago

Overview

In order to generate optimisations with Verteego, you will need to:

  • Create datasets

  • Create a configuration file

  • Create a pipeline run.

See the for a description of the general concepts used below (Datasource, Dataset, Pipeline, etc.).

Here, we will look at three examples of optimization, which represent the three main categories of optimization addressed by the Verteego platform:

  1. Optimisation of a variable

  2. Scenario selection

  3. Optimisation of a variable and selection of scenarios

For each of these 3 cases, you will need to :

  • Create the pipeline :

    In Pipelines Tab, click on “New” in order to create a pipeline of type optimisation :

  • Add the relevant datasets :

  • Set up the configuration file

  • Launch a pipeline_run

1. Optimisation of a variable

First, you need to create a pipeline on the platform. In the Pipelines section, create a new Optimization pipeline.

Let's say we want to optimise daily car rental prices for different rental periods.

Data overview:

In our example, we have 3 vehicles (vehicle A, vehicle B and vehicle C), 3 rental periods (1D, 7D, 14D), the price of the competition and the price of the competition plus 30%.

Vehicle
Duration
Competition_price
Competition_upper_bound_price

Vehicle A

1J

38

49

Vehicle A

7J

37

48

Vehicle A

14J

34

44

Vehicle B

1J

39

51

Vehicle B

7J

36

47

Vehicle B

14J

33

43

Vehicle C

1J

41

53

Vehicle C

7J

38

49

Vehicle C

14J

37

48

Then, you need to create the system. The system contains the keys that uniquely identify the variables (Vehicle, Duration) and the columns that are useful for optimisation (Competition_price, Competition_upper_bound_price).

You need to upload your system dataset on the platform:

Once your system dataset has been uploaded and validated on the platform, you need to create the configuration file.

Configuration:

v1 - Launching our first pipeline run

Creating the first configuration

You need to set up the initial configuration of your optimisation pipeline.

Goal:

In our example, we want to maximise the price of the vehicles, and ensure that these prices are higher than the competition's prices and lower than the competition's prices plus 30%.

Variables:

First of all, you need to fill in everything relating to the variables :

  • variables : the name of the variable to optimise. In this example, we want to optimize the price.

  • variable_types : type of the variable to optimise. Could be int, float, bool. In this example, we want integer prices.

  • variable_keys : keys that uniquely identify the variables. In this example, the price is indexed by a vehicle and a duration.

Then you need to determine the objective of the optimisation. There are two ways of computing the objective: the sum of a column or the weighted sum of two columns. You need to specify :

  • objective_method : max or min, whether you want to maximize or minimize the objective. In this example, we want to maximize the price.

  • weighted_objective_columns : column(s) used as the optimisation objective. In this example, it is the price.

Constraints:

Afterwards, you need to define the set of constraints :

  • lower_bound_on_price : This constraint means that our price variable must be greater than 0.

  • competition_lower_bound : This constraint means that our price variable must be greater than the competition price. Here we use a binary constraint, because we are constraining our variable (price) against another column (Competition_price).

  • competition_upper_bound : This constraint means that our price variable must be lesser than the competition price plus 30% (Competition_upper_bound_price).

For example, a very simple initial configuration might be as follows:

variables:
- name: price
variable_types: int
variable_keys:
- Vehicle
- Duration
objective_method: max
weighted_objective_columns:
- price

constraints:

  lower_bound_on_price:
    constraint_type: unary
    column: price
    operator: greater
    bound: 0
    
  competition_lower_bound:
    constraint_type: binary
    left_column: price
    operator: greater
    right_column: Competition_price
    delta: 0
    relax: false

  competition_upper_bound:
    constraint_type: binary
    left_column: price
    operator: lesser
    right_column: Competition_upper_bound_price
    delta: 0
    relax: false

You are now ready to launch a pipeline run.

Then, click on the pipeline you have just created. This redirects you to the pipeline runs page. You can create a new run by clicking on "New", and specifying which dataset is used as input to the optimisation.

Analyzing the results

You can click on Pipeline>Predictions, then on the prediction of your pipeline. In the top-right, you can then choose to download the prediction file (as a CSV), or export it to an existing DataSource.

In our example, we obtain the following results:

Vehicle
Duration
Competition_price
Competition_upper_bound_price
price

Vehicle A

1J

38

49

49

Vehicle A

7J

37

48

48

Vehicle A

14J

34

44

44

Vehicle B

1J

39

51

51

Vehicle B

7J

36

47

47

Vehicle B

14J

33

43

43

Vehicle C

1J

41

53

53

Vehicle C

7J

38

49

49

Vehicle C

14J

37

48

48

The results are consistent with our configuration: the price of vehicles is maximised, while respecting the min and max bounds.

However, for 7J duration, vehicle A is more expensive than vehicle B. This is not possible in our case, as we want the prices of the vehicles to increase (the price of vehicle A must be lower than the price of vehicle B, which must be lower than the price of vehicle C).

Let’s add a new constraint in the following section.

v2 - Adding more constraints

Adding a new constraint

We want to add an additional constraint to our example, to order the prices of vehicles A, B and C for each rental period (Duration). We want that the car prices must be at least €1 apart in the following order: Vehicle A, B, C.

To do this, we define the category_constraint :

For each rental period :

Price(VehicleA)≤Price(VehicleB)−1≤Price(VehicleC)−1Price(VehicleA) \leq Price(Vehicle B) - 1 \leq Price(Vehicle C) - 1Price(VehicleA)≤Price(VehicleB)−1≤Price(VehicleC)−1

Indeed, order constraints can be written mathematically as follows:$variable(lesserorder) <= variable(greaterorder) * factor + delta$

variable(lesser_order)≤variable(greater_order)×factor+deltavariable(lesser\_order) \leq variable(greater\_order) \times factor + deltavariable(lesser_order)≤variable(greater_order)×factor+delta

The configuration then looks like this:

variables:
- name: price
variable_types: int
variable_keys:
- Vehicle
- Duration
objective_method: max
weighted_objective_columns:
- price

constraints:

  lower_bound_on_price:
    constraint_type: unary
    column: price
    operator: greater
    bound: 0
    
  competition_lower_bound:
    constraint_type: binary
    left_column: price
    operator: greater
    right_column: Competition_price
    delta: 0
    relax: false

  competition_upper_bound:
    constraint_type: binary
    left_column: price
    operator: lesser
    right_column: Competition_upper_bound_price
    delta: 0
    relax: false

  category_constraint:
    constraint_type: order
    variable_column: price
    order_by: Vehicle
    ordering:
    - Vehicle A
    - Vehicle B
    - Vehicle C
    operator: asc
    delta: -1
    relax: false
    factor: 1
    group_by:
    - Duration

Analyzing the results

We obtain the following results :

Vehicle
Duration
Competition_price
Competition_upper_bound_price
price

Vehicle A

1J

38

49

49

Vehicle A

7J

37

48

46

Vehicle A

14J

34

44

42

Vehicle B

1J

39

51

51

Vehicle B

7J

36

47

47

Vehicle B

14J

33

43

43

Vehicle C

1J

41

53

53

Vehicle C

7J

38

49

49

Vehicle C

14J

37

48

48

The results here are more consistent : Depending on the rental period, the prices of vehicles A, B and C increase in this order.

2. Scenario selection

First, you need to create a pipeline on the platform. In the Pipelines section, create a new Optimization pipeline.

Let's say we want to optimise the promotions applied to a shop's products. We need to determine the optimal discount percentage for each of our products, between 10% and 50% off.

First, the Verteego platform simulated all possible scenarios: for each of our products and each percentage reduction, the platform predicted the quantities sold (Forecasting module).

item_id
item_level_1
item_level_2
item_level_3
promo_meca
reduction_percent
item_reduced_price
item_cost
quantity_sold
revenue
margin

5 901 234 124 021

Alimentation

Lait et produits laitiers

MIKO

MECA_01

0.1

5.49

3.66

1537

8438.13

2812.71

5 901 234 124 021

Alimentation

Lait et produits laitiers

MIKO

MECA_02

0.2

4.88

3.66

2714

13244.32

3311.08

5 901 234 124 021

Alimentation

Lait et produits laitiers

MIKO

MECA_03

0.3

4.27

3.66

3095

13215.65

1887.95

Now we can use these scenarios to choose the best promotion mechanics to apply to our products (Optimization module).

In our example, we have 12 products and 5 promotion mechanisms, so the system has 60 rows.

You need to upload your system dataset on the platform :

Once your system dataset has been uploaded and validated on the platform, you need to create the configuration file.

v1 - Launching our first pipeline run

Creating the first configuration

You need to set up the initial configuration of your optimisation pipeline.

As explained in the previous section, you need to fill in everything relating to the variables :

  • variables : In this example, we want to optimize the variable select_best_promo_meca. We want this variable to be equal to 0 or 1, in order to select the right scenarios. The rows where the variable is equal to 1 will be the rows selected by the optimisation.

  • variable_types : In this example, we want integer or bool.

  • variable_keys : In this example, the variable best_promo_meca is indexed by a product and a promotional mechanism.

Then you need to determine the objective of the optimisation :

  • objective_method : In this example, we want to maximize the margin.

  • weighted_objective_columns : column(s) used as the optimisation objective. In this example, it is the margin and the variable select_best_promo_meca. Indeed, the objective can be written as :

max∑select_best_promo_meca×marginmax \sum select\_best\_promo\_meca \times marginmax∑select_best_promo_meca×margin

Afterwards, you need to define the set of constraints :

  • unique: This constraint means that a product can only have one promotional mechanism. For each product, the sum of the variable best_promo_meca must be equal to 1. Given that the type of this variable is int or bool, this means that select_best_promo_meca can be equal to 0 or 1.

For example, a very simple initial configuration might be as follows:

variables:
- name: select_best_promo_meca
variable_keys:
- item_id
- promo_meca
variable_types: int
objective_method: max
weighted_objective_columns:
- select_best_promo_meca
- margin
constraints:
  unique:
    constraint_type: aggregation
    keys:
    - item_id
    left_column: select_best_promo_meca
    left_method: sum
    operator: equal
    right_column: 1
    right_method: min

You are now ready to launch a pipeline run.

Analyzing the results

In our example, we obtain the following results:

item_id
item_level_1
item_level_2
item_level_3
promo_meca
reduction_percent
item_reduced_price
item_cost
quantity_sold
revenue
margin
select_best_promo_meca

5 901 234 124 021

Alimentation

Lait et produits laitiers

MIKO

MECA_02

0.2

4.88

3.66

2714

13244.32

3311.08

1

5 901 234 124 022

Alimentation

Lait et produits laitiers

LA FROMAGERIE DU QUERCY

MECA_01

0.1

14.94

11.2

1393

20811.42

5209.82

1

5 901 234 124 028

Alimentation

Lait et produits laitiers

ARGEL

MECA_01

0.1

10.35

10.18

786

8135.1

133.62

1

5 901 234 124 043

Alimentation

Lait et produits laitiers

MONOPRIX GOURMET

MECA_01

0.1

10.35

8.1

2424

25088.4

5454.0

1

5 901 234 124 047

Alimentation

Lait et produits laitiers

PILPA

MECA_02

0.2

15.12

7.57

2508

37920.96

18935.4

1

5 901 234 124 053

Alimentation

Lait et produits laitiers

CARRE DES PINS

MECA_01

0.1

17.28

12.3

2465

42595.2

12275.7

1

5 901 234 124 020

Alimentation

Fruits et légumes

NOTRE JARDIN

MECA_02

0.2

9.28

8.6

4616

42836.48

3138.88

1

5 901 234 124 040

Alimentation

Fruits et légumes

MONOPRIX BIO

MECA_01

0.1

14.31

12.09

4578

65511.18

10163.16

1

5 901 234 124 042

Alimentation

Fruits et légumes

SANS MARQUE

MECA_01

0.1

13.32

9.78

4677

62297.64

16556.58

1

5 901 234 124 066

Alimentation

Fruits et légumes

BINS DE FRAICHEUR

MECA_02

0.2

4.08

2.8

4635

18910.8

5932.8

1

5 901 234 124 153

Alimentation

Fruits et légumes

LES HERBES DE MON PERE

MECA_01

0.1

9.81

5.5

4675

45861.75

20149.25

1

5 901 234 124 191

Alimentation

Fruits et légumes

BIO VILLAGE

MECA_02

0.2

13.6

8.9

5741

78077.6

26982.7

1

In this case, the optimization has selected the right promotional mechanism to maximise the margin. The output is 12 rows, 1 for each product, with the associated promotional mechanism.

Now let's add some constraints.

v2 - Adding more constraints

Adding a new constraint

Let’s say we want to have at least 2 promotional mechanics at 40% off.

To do so, we add an aggregation constraint nb_meca_04.

variables:
- name: select_best_promo_meca
variable_keys:
- item_id
- promo_meca
variable_types: int
objective_method: max
weighted_objective_columns:
- select_best_promo_meca
- margin
constraints:
  unique:
    constraint_type: aggregation
    keys:
    - item_id
    left_column: select_best_promo_meca
    left_method: sum
    operator: equal
    right_column: 1
    right_method: min
    
  nb_meca_04:
    constraint_type: aggregation
    left_column: select_best_promo_meca
    left_method: sum
    left_where:
      promo_meca:
      - MECA_04
    operator: greater
    right_column: 2
    right_method: min

Analyzing the results

We obtain the following results:

item_id
item_level_1
item_level_2
item_level_3
promo_meca
reduction_percent
item_reduced_price
item_cost
quantity_sold
revenue
margin
select_best_promo_meca

5 901 234 124 021

Alimentation

Lait et produits laitiers

MIKO

MECA_04

0.4

3.66

3.66

3200

11712.0

-3.2685e-11

1

5 901 234 124 022

Alimentation

Lait et produits laitiers

LA FROMAGERIE DU QUERCY

MECA_01

0.1

14.94

11.2

1393

20811.42

5209.82

1

5 901 234 124 028

Alimentation

Lait et produits laitiers

ARGEL

MECA_01

0.1

10.35

10.18

786

8135.1

133.62

1

5 901 234 124 043

Alimentation

Lait et produits laitiers

MONOPRIX GOURMET

MECA_01

0.1

10.35

8.1

2424

25088.4

5454.0

1

5 901 234 124 047

Alimentation

Lait et produits laitiers

PILPA

MECA_02

0.2

15.12

7.57

2508

37920.96

18935.4

1

5 901 234 124 053

Alimentation

Lait et produits laitiers

CARRE DES PINS

MECA_01

0.1

17.28

12.3

2465

42595.2

12275.7

1

5 901 234 124 020

Alimentation

Fruits et légumes

NOTRE JARDIN

MECA_02

0.2

9.28

8.6

4616

42836.48

3138.88

1

5 901 234 124 040

Alimentation

Fruits et légumes

MONOPRIX BIO

MECA_01

0.1

14.31

12.09

4578

65511.18

10163.16

1

5 901 234 124 042

Alimentation

Fruits et légumes

SANS MARQUE

MECA_01

0.1

13.32

9.78

4677

62297.64

16556.58

1

5 901 234 124 066

Alimentation

Fruits et légumes

BINS DE FRAICHEUR

MECA_04

0.4

3.06

2.8

6315

19323.9

1641.9

1

5 901 234 124 153

Alimentation

Fruits et légumes

LES HERBES DE MON PERE

MECA_01

0.1

9.81

5.5

4675

45861.75

20149.25

1

5 901 234 124 191

Alimentation

Fruits et légumes

BIO VILLAGE

MECA_02

0.2

13.6

8.9

5741

78077.6

26982.7

1

In Data Tab → Datasets, click on New to create a dataset. If your datasets are CSV files of less than 50 MB, you can go directly to the Data>Datasets section and add a dataset (select the 'Upload File' data source, and click on 'Choose file' to upload your file). If however your dataset is in the Cloud, we support a number of which you can use to create a datasource (Data>Datasources), and then create datasets from this source.

Connectors
Concepts page
252B
system_price_optim.csv
7KB
system_optim_promo.csv