OR-Tools  8.2
set_covering_data.h
Go to the documentation of this file.
1// Copyright 2010-2018 Google LLC
2// Licensed under the Apache License, Version 2.0 (the "License");
3// you may not use this file except in compliance with the License.
4// You may obtain a copy of the License at
5//
6// http://www.apache.org/licenses/LICENSE-2.0
7//
8// Unless required by applicable law or agreed to in writing, software
9// distributed under the License is distributed on an "AS IS" BASIS,
10// WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
11// See the License for the specific language governing permissions and
12// limitations under the License.
13
14#ifndef OR_TOOLS_DATA_SET_COVERING_DATA_H_
15#define OR_TOOLS_DATA_SET_COVERING_DATA_H_
16
17#include <vector>
18
20
21namespace operations_research {
22namespace scp {
23
24class ScpData {
25 public:
26 ScpData() : is_set_partitioning_(false) {}
27 // Getters.
28 int num_rows() const { return columns_per_row_.size(); }
29 int num_columns() const { return rows_per_column_.size(); }
30 // columns_per_row[i][j] returns the index of the jth column covering row i.
31 const std::vector<std::vector<int>>& columns_per_row() const {
32 return columns_per_row_;
33 }
34 // rows_per_column[i][j] returns the index of the jth row covering column i.
35 const std::vector<std::vector<int>>& rows_per_column() const {
36 return rows_per_column_;
37 }
38 const std::vector<int>& column_costs() const { return column_costs_; }
39
40 bool is_set_partitioning() const { return is_set_partitioning_; }
41 void set_is_set_partitioning(bool v) { is_set_partitioning_ = v; }
42
43 // Builders.
44 // Calling SetProblemSize() will clear all previous data.
45 void SetProblemSize(int num_rows, int num_columns);
46 void SetColumnCost(int column_id, int cost);
47 void AddRowInColumn(int row, int column);
48
49 private:
50 std::vector<std::vector<int>> columns_per_row_;
51 std::vector<std::vector<int>> rows_per_column_;
52 std::vector<int> column_costs_;
53 bool is_set_partitioning_;
54};
55
56} // namespace scp
57} // namespace operations_research
58
59#endif // OR_TOOLS_DATA_SET_COVERING_DATA_H_
const std::vector< std::vector< int > > & columns_per_row() const
const std::vector< std::vector< int > > & rows_per_column() const
void SetProblemSize(int num_rows, int num_columns)
void SetColumnCost(int column_id, int cost)
const std::vector< int > & column_costs() const
void AddRowInColumn(int row, int column)
RowIndex row
Definition: markowitz.cc:175
The vehicle routing library lets one model and solve generic vehicle routing problems ranging from th...
int64 cost