Ejemplo n.º 1
0
 def __iter__(self) -> Iterator[List[int]]:
     capi.resetResultFetching(self._task.handle)
     buf = capi.allocateResultBuffer(self._task.handle)
     try:
         while True:
             remaining = capi.getNextResultRow(self._task.handle, buf)
             if remaining == 0:
                 break
             yield list(buf)
     finally:
         capi.freeResultBuffer(buf)
Ejemplo n.º 2
0
    def test_usecase_simple(self):
        task = capi.createTask()
        model = capi.createModel()
        capi.setRootModel(task, model)
        p1 = capi.addParameter(model, 2, 2, (1, 1))  # axis-X
        p2 = capi.addParameter(model, 3, 2, (2, 1, 1))  # axis-Y
        paramCount = capi.getTotalParameterCount(task)
        self.assertEqual(2, paramCount)

        capi.addExclusion(task, ((p1, 0), (p2, 2)))
        capi.addExclusion(task, ((p1, 1), (p2, 0)))

        capi.addSeed(task, ((p1, 0), (p2, 0)))

        capi.generate(task)
        capi.resetResultFetching(task)

        row = capi.allocateResultBuffer(task)
        self.assertNotEqual(0, row)

        fullRows = ['0,0', '0,1', '0,2', '1,0', '1,1', '1,2']
        excludedRows = ['0,2', '1,0']
        expectedRows = set(fullRows) - set(excludedRows)
        actualRows = []
        rowsRemaining = len(expectedRows)
        while True:
            self.assertEqual(rowsRemaining, capi.getNextResultRow(task, row))
            if rowsRemaining == 0:
                break
            actualRows.append(','.join([str(x) for x in row]))
            rowsRemaining -= 1
        self.assertEqual(sorted(expectedRows), sorted(actualRows))

        capi.freeResultBuffer(row)
        capi.deleteTask(task)
        capi.deleteModel(model)
Ejemplo n.º 3
0
print('Model handle:', model)
capi.setRootModel(task, model)

p1 = capi.addParameter(model, 2, 2, (1, 1))
print('Param 1 handle:', p1)
p2 = capi.addParameter(model, 3, 2, (2, 1, 1))
print('Param 2 handle:', p2)
print('Parameter count:', capi.getTotalParameterCount(task))

print('Exclude [0, 2]')
capi.addExclusion(task, ((p1, 0), (p2, 2)))
print('Exclude [1, 0]')
capi.addExclusion(task, ((p1, 1), (p2, 0)))

capi.addSeed(task, ((p1, 0), (p2, 0)))
capi.generate(task)
capi.resetResultFetching(task)
row = capi.allocateResultBuffer(task)
print('Result Buffer:', row)

while True:
    remaining_rows = capi.getNextResultRow(task, row)
    if remaining_rows == 0:
        break
    print('Result Row:', list(row))

print('Cleaning up...')
capi.freeResultBuffer(row)
capi.deleteTask(task)
capi.deleteModel(model)