Problems — ecyglpki 0.2.0 documentation

### Navigation

- index
- modules |
- next |
- previous |
- ecyglpki 0.2.0 documentation »

# Problems

class `ecyglpki.` `Problem`

  A GLPK 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`

  `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

  `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

  `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`

  `adv_basis`()

    Construct advanced initial LP basis

  `analyze_bound`(ind, names_preferred=False)

    Analyze active bound of non-basic variable

    Parameters: | names_preferred (`bool`) – whether to return row and column names or indices

  `analyze_coef`(ind, names_preferred=False)

    Analyze objective coefficient at basic variable

    Parameters: | names_preferred (`bool`) – whether to return row and column names or indices

  `bf_exists`()

    Check if LP basis factorization exists

    Return type: | `bool`

  `bf_updated`()

    Check if LP basis factorization has been updated

    Return type: | `bool`

  `btran`(tuple rhs)

    Perform backward transformation (solve system B’x = b)

  `check_cnfsat`()

    Check for CNF-SAT problem instance

    Return type: | `bool`

  `check_kkt`(str solver, str condition, bool dual=False, names_preferred=False)

    Check feasibility/optimality conditions

    Parameters: | names_preferred (`bool`) – whether to return the row or column name or index

  `clear_mat_col`(col)

    Clear column of the constraint matrix

    Parameters: | col (`int` or `str`) – the index or name of the column

  `clear_mat_row`(row)

    Clear row of the constraint matrix

    Parameters: | row (`int` or `str`) – the index or name of the row

  `clear_matrix`()

    Clear the whole constraint matrix

  `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`

  `cpx_basis`()

    Construct Bixby’s initial LP basis

  `del_cols`(*cols)

    Delete specified columns from problem object

    Parameters: | cols (`tuple` of `int` or `str`) – the indices or the names of the columns

  `del_rows`(*rows)

    Delete specified rows from problem object

    Parameters: | rows (`tuple` of `int` or `str`) – the indices or names of the rows

  `dual_rtest`(coeffs, int direction, double eps, names_preferred=False)

    Perform dual ratio test

    Parameters: | names_preferred (`bool`) – whether to return row and column names or indices

  `erase_prob`()

    Erase problem object content

  `eval_tab_col`(ind, names_preferred=False)

    Compute column of the simplex tableau

    Parameters: | names_preferred (`bool`) – whether to return row and column names or indices

  `eval_tab_row`(ind, names_preferred=False)

    Compute row of the simplex tableau

    Parameters: | names_preferred (`bool`) – whether to return row and column names or indices

  `exact`(SimplexControls controls)

    Solve LP problem in exact arithmetic

  `factorize`()

    Compute LP basis factorization

  `find_col`(str name)

    Find column by its name

    Parameters: | name (`str`) – the name of the column
    Returns: | the column index
    Return type: | `int`

  `find_col_as_needed`(col)

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the column index
    Return type: | `int`

  `find_row`(str name)

    Find row by its name

    Parameters: | name (`str`) – the name of the row
    Returns: | the row index
    Return type: | `int`

  `find_row_as_needed`(row)

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the row index
    Return type: | `int`

  `find_row_or_col_as_needed`(ind)
  `ftran`(tuple rhs)

    Perform forward transformation (solve system B*x = b)

  `get_bfcp`()

    Retrieve LP basis factorization control parameters

    Returns: | basis factorization control parameter object
    Return type: | `FactorizationControls`

  `get_bhead`(int k, names_preferred=False)

    Retrieve LP basis header information

    Parameters: | names_preferred (`bool`) – whether to return the row or column name or index

  `get_col_bind`(col)

    Retrieve column index in the basis header

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | basis header index
    Return type: | `int`

  `get_col_dual`(col)

    retrieve column dual value (basic solution)

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the solution value
    Return type: | `float`

  `get_col_kind`(col)

    Retrieve column kind

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the column kind, either `'continuous'`, `'integer'`, or `'binary'`
    Return type: | `str`

  `get_col_lb`(col)

    Retrieve column lower bound

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the lower bound
    Return type: | `float`

  `get_col_name`(int col)

    Retrieve column name

    Parameters: | col (`int`) – the index of the column
    Returns: | the problem name
    Return type: | `str`

  `get_col_name_if`(int col, names_preferred=False)

    Parameters: | col (`int`) – the index of the column names_preferred (`bool`) – whether to return the column name or index
    Returns: | the column name or index
    Return type: | `str` or `int`

  `get_col_prim`(col)

    Retrieve column primal value (basic solution)

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the solution value
    Return type: | `float`

  `get_col_stat`(col)

    Retrieve column status

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the column status, either `'basic'`, `'lower'`, `'upper'`, `'free'`, or `'fixed'`
    Return type: | `str`

  `get_col_type`(col)

    Retrieve column type

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the column type, either `'free'`, `'dominating'`, `'dominated'`, `'bounded'`, or `'fixed'`
    Return type: | `str`

  `get_col_ub`(col)

    Retrieve column upper bound

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the upper bound
    Return type: | `float`

  `get_dual_stat`()

    Retrieve status of dual basic solution

  `get_mat_col`(col, names_preferred=False)

    Retrieve column of the constraint matrix

    Parameters: | col (`int` or `str`) – the index or name of the column names_preferred (`bool`) – whether to return row and column names or indices
    Returns: | the column
    Rtype coeffs: | `Mapping` from row names (`str` strings) to coefficient values (`Real`)

  `get_mat_row`(row, names_preferred=False)

    Retrieve row of the constraint matrix

    Parameters: | row (`int` or `str`) – the index or name of the row names_preferred (`bool`) – whether to return row and column names or indices
    Returns: | the row
    Rtype coeffs: | `Mapping` from column names (`str` strings) to coefficient values (`Real`)

  `get_num_bin`()

    Retrieve number of binary columns

    Returns: | the number of binary columns
    Return type: | `int`

  `get_num_cols`()

    Retrieve number of columns

    Returns: | the number of columns
    Return type: | `int`

  `get_num_int`()

    Retrieve number of integer columns

    Returns: | the number of integer columns
    Return type: | `int`

  `get_num_nz`()

    Retrieve number of constraint coefficients

    Returns: | the number of (non-zero) constraint coefficients
    Return type: | `int`

  `get_num_rows`()

    Retrieve number of rows

    Returns: | the number of rows
    Return type: | `int`

  `get_obj_coef`(col)

    Retrieve obj. coefficient

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the coefficient value
    Return type: | `float`

  `get_obj_const`()

    Retrieve obj. constant term

    Returns: | the constant value
    Return type: | `float`

  `get_obj_dir`()

    Retrieve optimization direction flag

    Returns: | the objective direction, either `'minimize'` or `'maximize'`
    Return type: | `str`

  `get_obj_name`()

    Retrieve objective function name

    Returns: | the objective name
    Return type: | `str`

  `get_obj_val`()

    Retrieve objective value (basic solution)

    Returns: | the objective value of the basic solution
    Return type: | `float`

  `get_prim_stat`()

    Retrieve status of primal basic solution

  `get_prob_name`()

    Retrieve problem name

    Returns: | the problem name
    Return type: | `str`

  `get_rii`(row)

    Retrieve row scale factor

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the scale factor
    Return type: | `float`

  `get_row_bind`(row)

    Retrieve row index in the basis header

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | basis header index
    Return type: | `int`

  `get_row_dual`(row)

    Retrieve row dual value (basic solution)

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the solution value
    Return type: | `float`

  `get_row_lb`(row)

    Retrieve row lower bound

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the lower bound
    Return type: | `float`

  `get_row_name`(int row)

    Retrieve row name

    Parameters: | row (`int`) – the index of the row
    Returns: | the row name
    Return type: | `str`

  `get_row_name_if`(int row, names_preferred=False)

    Parameters: | row (`int`) – the index of the row names_preferred (`bool`) – whether to return the row name or index
    Returns: | the row name or index
    Return type: | `str` or `int`

  `get_row_or_col_name`(int ind)

    Retrieve row or column name

    Parameters: | ind (`int`) – the row/column index
    Returns: | a pair, either `'row'` or `'col'` and the row or column name
    Return type: | (`str`, `str`)

  `get_row_or_col_name_if`(int ind, names_preferred=False)

    Parameters: | ind (`int`) – the row/column index names_preferred (`bool`) – whether to return the row or column name or index
    Returns: | a pair, either `'row'` or `'col'` and the row or column name
    Return type: | (`str`, `str`)

  `get_row_prim`(row)

    Retrieve row primal value (basic solution)

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the solution value
    Return type: | `float`

  `get_row_stat`(row)

    Retrieve row status

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the row status, either `'basic'`, `'lower'`, `'upper'`, `'free'`, or `'fixed'`
    Return type: | `str`

  `get_row_type`(row)

    Retrieve row type

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the row type, either `'free'`, `'dominating'`, `'dominated'`, `'bounded'`, or `'fixed'`
    Return type: | `str`

  `get_row_ub`(row)

    Retrieve row upper bound

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the upper bound
    Return type: | `float`

  `get_sjj`(col)

    Retrieve column scale factor

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the scale factor
    Return type: | `float`

  `get_status`()

    Retrieve generic status of basic solution

  `get_unbnd_ray`(names_preferred=False)

    Determine variable causing unboundedness

    Parameters: | names_preferred (`bool`) – whether to return the row or column name or index

  `interior`(IPointControls controls)

    Solve LP problem with the interior-point method

  `intfeas1`(bool use_bound, int obj_bound)

    Solve integer feasibility problem

  `intopt`(IntOptControls controls)

    Solve MIP problem with the branch-and-bound method

  `ipt_col_dual`(col)

    Retrieve column dual value (interior point)

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the solution value
    Return type: | `float`

  `ipt_col_prim`(col)

    Retrieve column primal value (interior point)

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the solution value
    Return type: | `float`

  `ipt_obj_val`()

    Retrieve objective value (interior point)

    Returns: | the objective value of the interior point solution
    Return type: | `float`

  `ipt_row_dual`(row)

    Retrieve row dual value (interior point)

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the solution value
    Return type: | `float`

  `ipt_row_prim`(row)

    Retrieve row primal value (interior point)

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the solution value
    Return type: | `float`

  `ipt_status`()

    Retrieve status of interior-point solution

  `load_matrix`(coeffs)

    Load (replace) the whole constraint matrix

    Parameters: | coeffs – `Mapping` from row and column name (str string) pairs (length-2 `tuple`) to coefficient values (`Real`)

  `minisat1`()

    Solve CNF-SAT problem with MiniSat solver

  `mip_col_val`(col)

    Retrieve column value (MIP solution)

    Parameters: | col (`int` or `str`) – the index or name of the column
    Returns: | the solution value
    Return type: | `float`

  `mip_obj_val`()

    Retrieve objective value (MIP solution)

    Returns: | the objective value of the MIP solution
    Return type: | `float`

  `mip_row_val`(row)

    Retrieve row value (MIP solution)

    Parameters: | row (`int` or `str`) – the index or name of the row
    Returns: | the solution value
    Return type: | `float`

  `mip_status`()

    Retrieve status of MIP solution

  `prim_rtest`(coeffs, int direction, double eps, names_preferred=False)

    Perform primal ratio test

    Parameters: | names_preferred (`bool`) – whether to return row and column names or indices

  `print_ipt`(str fname)

    Write interior-point solution in printable format

    Parameters: | fname (`str`) – file name

  `print_mip`(str fname)

    Write MIP solution in printable format

    Parameters: | fname (`str`) – file name

  `print_ranges`(row_or_cols, str fname)

    Print sensitivity analysis report

    Parameters: | fname (`str`) – file name

  `print_sol`(str fname)

    Write basic solution in printable format

    Parameters: | fname (`str`) – file name

  `read_cnfsat`(str fname)

    Read CNF-SAT problem data in DIMACS format

    Parameters: | fname (`str`) – file name
    Returns: | the problem read
    Return type: | `Problem`

  `read_ipt`(str fname)

    Read interior-point solution from text file

    Parameters: | fname (`str`) – file name

  `read_lp`(str fname)

    Read problem data in CPLEX LP format

    Parameters: | fname (`str`) – file name
    Returns: | the problem read
    Return type: | `Problem`

  `read_mip`(str fname)

    Read MIP solution from text file

    Parameters: | fname (`str`) – file name

  `read_mps`(str format, str fname)

    Read problem data in MPS format

    Parameters: | format (`str`) – the MPS file format, either `'fixed'` or `'free'` fname (`str`) – file name
    Returns: | the problem read
    Return type: | `Problem`

  `read_prob`(str fname)

    Read problem data in GLPK format

    Parameters: | fname (`str`) – file name
    Returns: | the problem read
    Return type: | `Problem`

  `read_sol`(str fname)

    Read basic solution from text file

    Parameters: | fname (`str`) – file name

  `scale_prob`(*algorithms)

    Scale problem data

    Parameters: | algorithms – the algorithms to apply, one or more from `'auto'`, `'skip'`, `'geometric'`, `'equilibration'`, `'round'`

  `set_bfcp`(FactorizationControls controls)

    Change LP basis factorization control parameters

  `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)

  `set_col_kind`(col, str kind)

    Set (change) column kind

    Parameters: | col (`int` or `str`) – the index or name of the column kind (`str`) – the column kind, either `'continuous'`, `'integer'`, or `'binary'`

  `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

  `set_col_stat`(col, str status)

    Set (change) column status

    Parameters: | col (`int` or `str`) – the index or name of the column

  `set_mat_col`(col, coeffs)

    Set (replace) column of the constraint matrix

    Parameters: | col (`int` or `str`) – the index or name of the column coeffs – `Mapping` from row names (`str` strings) to coefficient values (`Real`)

  `set_mat_row`(row, coeffs)

    Set (replace) row of the constraint matrix

    Parameters: | row (`int` or `str`) – the index or name of the row coeffs – `Mapping` from column names (`str` strings) to coefficient values (`Real`)

  `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

  `set_obj_const`(double coeff)

    Set (change) obj. constant term

    Parameters: | coeff (`Real`) – the coefficient value

  `set_obj_dir`(str direction)

    Set (change) optimization direction flag

    Parameters: | direction (`str`) – the objective direction, either `'minimize'` or `'maximize'`

  `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

  `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

  `set_rii`(row, double sf)

    Set (change) row scale factor

    Parameters: | row (`int` or `str`) – the index or name of the row sf (`Real`) – the scale factor

  `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)

  `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

  `set_row_stat`(row, str status)

    Set (change) row status

    Parameters: | row (`int` or `str`) – the index or name of the row

  `set_sjj`(col, double sf)

    Set (change) column scale factor

    Parameters: | col (`int` or `str`) – the index or name of the column sf (`Real`) – the scale factor

  `simplex`(SimplexControls controls)

    Solve LP problem with the simplex method

  `sort_matrix`()

    Sort elements of the constraint matrix

  `std_basis`()

    Construct standard initial LP basis

  `transform_col`(coeffs, names_preferred=False)

    Transform explicitly specified column

    Parameters: | coeffs – `Mapping` from row names (`str` strings) to coefficient values (`Real`) names_preferred (`bool`) – whether to return row and column names or indices
    Returns: | transformed column
    Return type: | `Mapping` from row and column names (`str` strings) to coefficient values (`Real`)

  `transform_row`(coeffs, names_preferred=False)

    Transform explicitly specified row

    Parameters: | coeffs – `Mapping` from column names (`str` strings) to coefficient values (`Real`) names_preferred (`bool`) – whether to return row and column names or indices
    Returns: | transformed row
    Return type: | `Mapping` from row and column names (`str` strings) to coefficient values (`Real`)

  `unscale_prob`()

    Unscale problem data

  `warm_up`()

    “Warm up” LP basis

  `write_cnfsat`(str fname)

    Write CNF-SAT problem data in DIMACS format

    Parameters: | fname (`str`) – file name

  `write_ipt`(str fname)

    Write interior-point solution to text file

    Parameters: | fname (`str`) – file name

  `write_lp`(str fname)

    Write problem data in CPLEX LP format

    Parameters: | fname (`str`) – file name

  `write_mip`(str fname)

    Write MIP solution to text file

    Parameters: | fname (`str`) – file name

  `write_mps`(str format, str fname)

    Write problem data in MPS format

    Parameters: | format (`str`) – the MPS file format, either `'fixed'` or `'free'` fname (`str`) – file name

  `write_prob`(str fname)

    Write problem data in GLPK format

    Parameters: | fname (`str`) – file name

  `write_sol`(str fname)

    Write basic solution to text file

    Parameters: | fname (`str`) – file name

### Navigation

- index
- modules |
- next |
- previous |
- ecyglpki 0.2.0 documentation »