def test_additive_QCP(self): status, namedStatus, values = choquetOptimize.getChoquetCapacities(self._ADDITIVE_TABLE, "QCP") self.assertEqual(status, -1) self.assertEqual(namedStatus, self._QCP_ERROR) for v in values: self.assertEqual(values[v], 0)
def main(args): if "-h" in args: printHelp(0) if 3 != len(args): printHelp(1, "Incorrect number of arguments") optimization, tableType = args[1:3] if tableType not in tables.TABLES: printHelp(2, ("Selected table type ({0}) is not available! " "Possible options are {1}.").format(tableType, sorted(list(tables.TABLES)))) if optimization not in choquetOptimize.OPTIMIZATIONS: printHelp(2, ("Selected optimization type ({0}) is not available! " "Possible options are {1}.").format(optimization, sorted(list(choquetOptimize.OPTIMIZATIONS)))) decisionTable = tables.getTable(tableType) statusCode, status, computed = [0] * 3 statusCode, status, computed = choquetOptimize.getChoquetCapacities(decisionTable, optimization) print "The problem is: {0}".format(status) print print "Computed values are:" for name in sorted(list(computed)): print "{0} = {1}".format(name, computed[name])
def test_additive_NLP(self): status, namedStatus, values = choquetOptimize.getChoquetCapacities(self._ADDITIVE_TABLE, "NLP") self.assertEqual(status, 0) self.assertEqual(namedStatus, "Optimization terminated successfully.")
def test_errors(self): with self.assertRaisesRegexp(Exception, self._TABLE_EXPECTED): choquetOptimize.getChoquetCapacities({}, "LP") with self.assertRaisesRegexp(Exception, self._NO_ROWS): choquetOptimize.getChoquetCapacities([], "LP") with self.assertRaisesRegexp(Exception, self._NOT_ENOUGH_ARGUMENTS): choquetOptimize.getChoquetCapacities([[]], "LP") with self.assertRaisesRegexp(Exception, self._NOT_ENOUGH_ARGUMENTS): choquetOptimize.getChoquetCapacities([[1], [2]], "LP") with self.assertRaisesRegexp(Exception, self._NOT_EQUAL_ROWS): choquetOptimize.getChoquetCapacities([[1, 1], [2, 3, 4]], "LP") with self.assertRaisesRegexp(Exception, self._UNKNOWN_PROGRAM): choquetOptimize.getChoquetCapacities([[1, 1, 2], [2, 3, 4]], "P")
def test_additive_LP(self): status, namedStatus, values = choquetOptimize.getChoquetCapacities(self._ADDITIVE_TABLE, "LP") self.assertEqual(status, 1) self.assertEqual(namedStatus, "Optimal") self.assertDictEqual(values, self._EXPECTED_VALUES)