Ophidian
 All Classes Namespaces Functions
abacus.h
1 /*
2  * Copyright 2016 Ophidian
3 Licensed to the Apache Software Foundation (ASF) under one
4 or more contributor license agreements. See the NOTICE file
5 distributed with this work for additional information
6 regarding copyright ownership. The ASF licenses this file
7 to you under the Apache License, Version 2.0 (the
8 "License"); you may not use this file except in compliance
9 with the License. You may obtain a copy of the License at
10 
11  http://www.apache.org/licenses/LICENSE-2.0
12 
13 Unless required by applicable law or agreed to in writing,
14 software distributed under the License is distributed on an
15 "AS IS" BASIS, WITHOUT WARRANTIES OR CONDITIONS OF ANY
16 KIND, either express or implied. See the License for the
17 specific language governing permissions and limitations
18 under the License.
19  */
20 
21 #ifndef OPHIDIAN_ABACUS_H
22 #define OPHIDIAN_ABACUS_H
23 
24 #include "../legalization.h"
25 #include "cells.h"
26 #include "subrows.h"
27 
28 namespace ophidian {
29  namespace placement {
30  namespace legalization {
31  namespace abacus {
33  public:
34  bool operator()(const std::pair<entity_system::entity, double> & cell_pair1, const std::pair<entity_system::entity, double> & cell_pair2) {
35  return cell_pair1.second < cell_pair2.second;
36  }
37  };
38 
39  struct cluster {
40  double m_begin;
41  unsigned m_last_order_id;
42  double m_size;
43  double m_displacement;
44  double m_weight;
45 
46  cluster(double begin)
47  : m_begin(begin), m_last_order_id(0), m_size(0), m_displacement(0), m_weight(0) {
48 
49  }
50 
51  void insert_cell(unsigned order_id, double x, double width, double weight) {
52  m_last_order_id = order_id;
53  m_displacement += weight*(x - m_size);
54  m_size += width;
55  m_weight += weight;
56  }
57 
58  void insert_cluster(cluster & cluster) {
59  m_last_order_id = cluster.m_last_order_id;
60  m_displacement += cluster.m_displacement - (cluster.m_weight - m_size);
61  m_size += cluster.m_size;
62  m_weight += cluster.m_weight;
63  }
64  };
65 
66  class abacus : public legalization {
67  entity_system::entity_system m_cells_system;
68  cells m_cells;
69 
70  subrows m_abacus_subrows;
71 
72  void align_cells();
73  void align_position(point & position);
74 
75  void place_row(entity_system::entity subrow);
76 
77  void collapse(std::list<cluster> & clusters, std::list<cluster>::iterator cluster_it, double x_min, double x_max, double y);
78  public:
80  : legalization(floorplan, placement), m_cells(m_cells_system), m_abacus_subrows(m_subrows_system) {
81  create_subrows();
82  }
83 
84  void legalize_placement();
85 
86  void create_subrows();
87  };
88  }
89  }
90  }
91 }
92 class abacus {
93 
94 };
95 
96 
97 #endif //OPHIDIAN_ABACUS_H
Placement class.
Definition: placement.h:35
entity_system class.
Definition: entity_system.h:40
Definition: abacus.h:92
Floorplan class.
Definition: floorplan.h:37