@@ -215,7 +215,7 @@ def flatten(self) -> list:
215215 )
216216 )
217217
218- def to_polyhedron (self , active : bool = False ) -> pnd .ge_polyhedron :
218+ def to_polyhedron (self , active : bool = False , reduced : bool = False ) -> pnd .ge_polyhedron :
219219
220220 """
221221 Converts into a polyhedron.
@@ -244,7 +244,7 @@ def to_polyhedron(self, active: bool = False) -> pnd.ge_polyhedron:
244244 )
245245 )
246246 )
247- lineqs = pst .TheoryPy (
247+ polyhedron_rs = pst .TheoryPy (
248248 list (
249249 map (
250250 lambda x : pst .StatementPy (
@@ -263,47 +263,28 @@ def to_polyhedron(self, active: bool = False) -> pnd.ge_polyhedron:
263263 flatten_dict .values ()
264264 )
265265 )
266- ).to_lineqs ()
267- M = np .zeros ((len (lineqs ), 1 + len (variable_id_map )))
268- for i , lineq in enumerate (lineqs ):
269- M [i , list (map (lambda x : x + 1 , lineq .indices ))] = lineq .coeffs
270- M [i , 0 ] = - 1 * lineq .bias
271-
272- polyhedron = pnd .ge_polyhedron (
273- M ,
266+ ).to_polyhedron (active , reduced )
267+
268+ id_variable_map = dict (variable_id_map .values ())
269+ polyedron_array = np .hstack (
270+ (
271+ np .array (polyhedron_rs .b ).reshape (- 1 ,1 ),
272+ np .array (np .array_split (polyhedron_rs .a .val , polyhedron_rs .a .nrows ))
273+ )
274+ )
275+ return pnd .ge_polyhedron (
276+ polyedron_array ,
274277 variables = [puan .variable .support_vector_variable ()]+ list (
275- itertools .chain (
276- map (
277- lambda x : x [1 ].variable if hasattr (x [1 ], "variable" ) else x [1 ],
278- variable_id_map .values ()
279- )
280- )
281- ),
282- index = list (
283278 map (
284- lambda x : x [ 1 ]. variable ,
285- filter (
286- lambda x : type ( x [ 1 ]) != puan . variable ,
287- variable_id_map . values ()
288- )
279+ maz . compose (
280+ id_variable_map . get ,
281+ operator . attrgetter ( "id" )
282+ ),
283+ polyhedron_rs . variables
289284 )
290- )
285+ ),
291286 )
292287
293- # assume top node for now until
294- # this is default in puan-rspy
295- if self .variable in polyhedron .variables and active :
296-
297- polyhedron = polyhedron .reduce_columns (
298- polyhedron .A .construct (
299- * {self .variable .id : 1 }.items (),
300- default_value = np .nan ,
301- dtype = float ,
302- )
303- )
304-
305- return polyhedron
306-
307288 def negate (self ) -> "AtLeast" :
308289
309290 """
0 commit comments