================================= ======== POLYTOPES.h ================ /* Created by Yann Disser on 7.1.2008. */ #ifndef REDUCED_POLYTOPES_H #define REDUCED_POLYTOPES_H REDUCED_POLYTOPES_H #include #include #include "Polytope.h" #include "ReducedVertex.h" typedef std::auto_ptr pPolytope; //assumes two systems with binary outputs pPolytope createCorrelationPolytope(int n); pPolytope createCorrelationPolytope(int n, const std::vector >& S); pPolytope createCorrelationPolytopeReduced(const Vertex::System& s1, const Vertex::System& s2); pPolytope createCorrelationPolytopeReduced(const Vertex::System& s1, const Vertex::System& s2, const std::vector >& S); pPolytope createQuantumPolytope(int n); pPolytope createQuantumPolytope(int n, const std::vector >& S); pPolytope createModifiedPolytope(const Polytope* poly, double eta = 1.0); pPolytope createPolytopeCopy(const Polytope& poly, const VertexFactory& fac = ReducedVertexFactory()); template pPolytope createCorrelationPolytope(const Vertex::System& s1, const Vertex::System& s2) { return pPolytope(NULL); } template<> pPolytope createCorrelationPolytope(const Vertex::System& s1, const Vertex::System& s2) { return createCorrelationPolytopeReduced(s1, s2); } template<> pPolytope createCorrelationPolytope(const Vertex::System& s1, const Vertex::System& s2) { return createPolytopeCopy(*createCorrelationPolytopeReduced(s1, s2), FullVertexFactory()); } //return FullVertex representation pPolytope createWeakSignallingPolytopeFull(int m, int n, int a, int b); //return ReducedVertex representation pPolytope createWeakSignallingPolytopeReduced(int m, int n, int a, int b); template pPolytope createWeakSignallingPolytope(int m, int n, int a, int b) { return pPolytope(NULL); } template<> pPolytope createWeakSignallingPolytope(int m, int n, int a, int b) { return createWeakSignallingPolytopeReduced(m, n, a, b); } template<> pPolytope createWeakSignallingPolytope(int m, int n, int a, int b) { return createWeakSignallingPolytopeFull(m, n, a, b); } #endif //REDUCED_POLYTOPES_H ================================ ========== TESTER.H =============== #ifndef YANN_REDUCED_TESTER_H #define YANN_REDUCED_TESTER_H YANN_REDUCED_TESTER_H #include #include "Vertex.h" #include "polytopes.h" typedef Vertex::System System; template class Tester { public: double determineWeakSignallingEta(const System& s1, const System& s2, bool expand, double allowedDifference = 0.00001); double determineWeakSignallingEta(const System& s1, const System& s2, bool expand, double allowedDifference) { pPolytope poly = createWeakSignallingPolytope(s1.outcomes, s2.outcomes, s1.inputs, s2.inputs); m_extremeVerts.clear(); const std::vector& verts = poly->getVertices(); int size = verts.size(); for(int i = 0; i < size; ++i) m_extremeVerts.push_back(VERTEX(*verts[i])); pPolytope corrPoly = createCorrelationPolytope( System(s1.inputs, s1.outcomes + (expand ? 1 : 0)), System(s2.inputs, s2.outcomes + (expand ? 1 : 0))); std::cerr << "Setup done (" << size << " verts)" << std::endl; double upper = 1.0, lower = 0.000; while(upper - lower >= allowedDifference) { double mid = (upper + lower)/2.0; std::vector newVerts; for(unsigned int i = 0; i < verts.size(); ++i) if(!corrPoly->contains(VERTEX(ReducedVertex(verts[i], mid, 1.0, expand)))) newVerts.push_back(verts[i]); bool contained = (newVerts.size() == 0); if(contained) { lower = mid; newVerts = verts; } else upper = mid; std::cerr << mid << ": " << contained << " nVerts: " << verts.size() << std::endl; verts = newVerts; } return upper; } private: std::vector m_extremeVerts; }; #endif //YANN_REDUCED_TESTER_H