| 1 |
/** |
| 2 |
* \brief Solve an instance of the "Variable Placement with Separation |
| 3 |
* Constraints" problem. |
| 4 |
* |
| 5 |
* Authors: |
| 6 |
* Tim Dwyer <[email protected]> |
| 7 |
* |
| 8 |
* Copyright (C) 2005 Authors |
| 9 |
* |
| 10 |
* This version is released under the CPL (Common Public License) with |
| 11 |
* the Graphviz distribution. |
| 12 |
* A version is also available under the LGPL as part of the Adaptagrams |
| 13 |
* project: https://github.com/mjwybrow/adaptagrams. |
| 14 |
* If you make improvements or bug fixes to this code it would be much |
| 15 |
* appreciated if you could also contribute those changes back to the |
| 16 |
* Adaptagrams repository. |
| 17 |
*/ |
| 18 |
#pragma once |
| 19 |
|
| 20 |
#include <vector> |
| 21 |
#include <vpsc/blocks.h> |
| 22 |
struct Variable; |
| 23 |
struct Constraint; |
| 24 |
class Blocks; |
| 25 |
|
| 26 |
/** |
| 27 |
* Variable Placement with Separation Constraints problem instance |
| 28 |
*/ |
| 29 |
struct VPSC { |
| 30 |
public: |
| 31 |
virtual void satisfy(); |
| 32 |
virtual void solve(); |
| 33 |
|
| 34 |
VPSC(const unsigned n, Variable *vs[], const unsigned m, Constraint *cs[]); |
| 35 |
virtual ~VPSC() = default; |
| 36 |
protected: |
| 37 |
Blocks bs; |
| 38 |
Constraint **cs; |
| 39 |
unsigned m; |
| 40 |
void printBlocks(); |
| 41 |
private: |
| 42 |
void refine(); |
| 43 |
bool constraintGraphIsCyclic(const unsigned n, Variable *vs[]); |
| 44 |
bool blockGraphIsCyclic(); |
| 45 |
}; |
| 46 |
|
| 47 |
struct IncVPSC : VPSC { |
| 48 |
public: |
| 49 |
unsigned splitCnt; |
| 50 |
void satisfy(); |
| 51 |
void solve(); |
| 52 |
void moveBlocks(); |
| 53 |
void splitBlocks(); |
| 54 |
IncVPSC(const unsigned n, Variable *vs[], const unsigned m, Constraint *cs[]); |
| 55 |
private: |
| 56 |
typedef std::vector<Constraint*> ConstraintList; |
| 57 |
ConstraintList inactive; |
| 58 |
double mostViolated(ConstraintList &l,Constraint* &v); |
| 59 |
}; |