-
Notifications
You must be signed in to change notification settings - Fork 3
Open
Description
Hello I am using a MAC OS Big Sur Version 11.3.1
When I run the solver multiple times SOMETIMES it segmentation faults, I dont know if this is because of qsopt_ex or because of the cython library. Just copy the code below into a file called reproducing_seg_fault.py and run the program like 20 or so times consecutively. One of the times will result in a segfault (see here)

Code here:
import qsoptex
import faulthandler
faulthandler.enable()
#import logging
#logging.basicConfig(level=logging.NOTSET)
class Polytope:
def __init__(self, A, b):
self.A = A
self.b = b
self.status = None
"""
The status variable carries the status of a most recent solve, if it is set to None then an LP run has not occurred yet
"""
self.p = None
def dimension(self):
return len(self.A[0])
def inequality_count(self):
return len(self.A)
#given an objective array c we attempt to maximize it and return the status, surprising the "c" tells us what the dimension of the problem is
def maximize(self, c, flag_integers=True):
self.p = qsoptex.ExactProblem()
for var_number in range(len(c)):
self.p.add_variable(name='x' + str(var_number),
objective=c[var_number],
lower=0, upper=1)
for constraint_number in range(self.inequality_count()):
self.p.add_linear_constraint(qsoptex.ConstraintSense.LESS,
dict(('x' + str(var_number), self.A[constraint_number][var_number]) for var_number in range(len(c))),
rhs = self.b[constraint_number],
name='c' + str(constraint_number))
self.p.set_objective_sense(qsoptex.ObjectiveSense.MAXIMIZE)
self.p.set_param(qsoptex.Parameter.SIMPLEX_DISPLAY, 1)
print("before seg fault: ")
self.status = self.p.solve()
print("after seg fault: ")
if __name__ == '__main__':
#running one at a time never results in a segfault
#running both of these repeatedly results in a segfault
A_matrix = [[1037066, 2074132, 1648264, 796528, 1593056, 686112, 1372224, 244448, 488896, 977792, 1955584, 1411168, 322336, 644672, 1289344, 78688, 157376, 314752, 629504, 1259008], [-1037066, -2074132, -1648264, -796528, -1593056, -686112, -1372224, -244448, -488896, -977792, -1955584, -1411168, -322336, -644672, -1289344, -78688, -157376, -314752, -629504, -1259008]]
b_matrix = [2463098, -2463098]
c_matrix = [0, -1, 1, -1, 1, -1, 0, 0, 0, 0, -1, 0, -1, -1, 0, 1, 0, 1, 1, -1]
test_polyhedron = Polytope(A_matrix, b_matrix)
test_polyhedron.maximize( c_matrix)
A_matrix = [[1037066, 2074132, 1648264, 796528, 1593056, 686112, 1372224, 244448, 488896, 977792, 1955584, 1411168, 322336, 644672, 1289344, 78688, 157376, 314752, 629504, 1259008], [-1037066, -2074132, -1648264, -796528, -1593056, -686112, -1372224, -244448, -488896, -977792, -1955584, -1411168, -322336, -644672, -1289344, -78688, -157376, -314752, -629504, -1259008]]
b_matrix = [2463098, -2463098]
c_matrix = [0, -1, 1, -1, 1, -1, 0, 0, 0, 0, -1, 0, -1, -1, 0, 1, 0, 1, 1, -1]
test_polyhedron = Polytope(A_matrix, b_matrix)
test_polyhedron.maximize( c_matrix)
Metadata
Metadata
Assignees
Labels
No labels