Problem creating and modifying routines

Problem.set_prob_name(str name)

Assign (change) problem name

Parameters:name (str) – the name of the problem, it may not exceed 255 bytes encoded as UTF-8
Problem.set_obj_name(str name)

Assign (change) objective function name

Parameters:name (str) – the name of the objective, it may not exceed 255 bytes encoded as UTF-8
Problem.set_obj_dir(str direction)

Set (change) optimization direction flag

Parameters:direction (str) – the objective direction, either 'minimize' or 'maximize'
Problem.add_rows(int number)

Add new rows to problem object

Parameters:number (int) – the number of rows to add
Returns:the index of the first row added
Return type:int
Problem.add_named_rows(*names)

Add new rows to problem object

Parameters:names (tuple of str) – the names of the rows to add, none may exceed 255 bytes encoded as UTF-8
Problem.add_cols(int number)

Add new columns to problem object

Parameters:number (int) – the number of columns to add
Returns:the index of the first column added
Return type:int
Problem.add_named_cols(*names)

Add new columns to problem object

Parameters:names (tuple of str) – the names of the columns to add, none may exceed 255 bytes encoded as UTF-8
Problem.set_row_name(row, str name)

Change row name

Parameters:
  • row (int or str) – the index or name of the row
  • name (str) – the name of the row, it may not exceed 255 bytes encoded as UTF-8
Problem.set_col_name(col, str name)

Change column name

Parameters:
  • col (int or str) – the index or name of the column
  • name (str) – the name of the column, it may not exceed 255 bytes encoded as UTF-8
Problem.set_row_bnds(row, lower, upper)

Set (change) row bounds

Parameters:
  • row (int or str) – the index or name of the row
  • lower (Real or NoneType) – lower bound (None if unbounded from below)
  • upper (Real or NoneType) – upper bound (None if unbounded from above)
Problem.set_col_bnds(col, lower, upper)

Set (change) column bounds

Parameters:
  • col (int or str) – the index or name of the column
  • lower (Real or NoneType) – lower bound (None if unbounded from below)
  • upper (Real or NoneType) – upper bound (None if unbounded from above)
Problem.set_obj_coef(col, double coeff)

Set (change) obj. coefficient

Parameters:
  • col (int or str) – the index or name of the column
  • coeff (Real) – the coefficient value
Problem.set_obj_const(double coeff)

Set (change) obj. constant term

Parameters:coeff (Real) – the coefficient value
Problem.set_mat_row(row, coeffs)

Set (replace) row of the constraint matrix

Parameters:
  • row (int or str) – the index or name of the row
  • coeffsMapping from column names (str strings) to coefficient values (Real)
Problem.clear_mat_row(row)

Clear row of the constraint matrix

Parameters:row (int or str) – the index or name of the row
Problem.set_mat_col(col, coeffs)

Set (replace) column of the constraint matrix

Parameters:
  • col (int or str) – the index or name of the column
  • coeffsMapping from row names (str strings) to coefficient values (Real)
Problem.clear_mat_col(col)

Clear column of the constraint matrix

Parameters:col (int or str) – the index or name of the column
Problem.load_matrix(coeffs)

Load (replace) the whole constraint matrix

Parameters:coeffsMapping from row and column name (str string) pairs (length-2 tuple) to coefficient values (Real)
Problem.clear_matrix()

Clear the whole constraint matrix

Problem.sort_matrix()

Sort elements of the constraint matrix

Problem.del_rows(*rows)

Delete specified rows from problem object

Parameters:rows (tuple of int or str) – the indices or names of the rows
Problem.del_cols(*cols)

Delete specified columns from problem object

Parameters:cols (tuple of int or str) – the indices or the names of the columns
Problem.copy_prob(Problem source, bool copy_names)

Copy problem object content

Parameters:
  • source (Problem) – the problem to copy
  • copy_names (bool) – whether to copy problem component names or not
Returns:

the copied problem

Return type:

Problem

Problem.erase_prob()

Erase problem object content