Calc/Drafts/Solver Infrastructure

From Apache OpenOffice Wiki
< Calc‎ | Drafts
Jump to: navigation, search

This page is about the UNO API and the user interface which together serve as the basis for optimization solver components in Calc.

Specification

The UI specification is at http://specs.openoffice.org/calc/features/Solver.odt.

API

Here's a rough sketch of the planned API (service com.sun.star.sheet.Solver):

enum SolverConstraintOperator
{
    LESS_EQUAL,
    EQUAL,
    GREATER_EQUAL,
    INTEGER,
    BINARY
};

struct SolverConstraint
{
    com::sun::star::table::CellAddress Left;
    SolverConstraintOperator Operator;
    any Right;
};

interface XSolver: com::sun::star::uno::XInterface
{
    [attribute] XSpreadsheetDocument Document;
    [attribute] com::sun::star::table::CellAddress Objective;
    [attribute] sequence< com::sun::star::table::CellAddress > Variables;
    [attribute] sequence< SolverConstraint > Constraints;
    [attribute] boolean Maximize;
    void solve();
    [attribute, readonly] boolean Success;
    [attribute, readonly] double ResultValue;
    [attribute, readonly] sequence< double > Solution;
};

service Solver: XSolver;

The dialog allows selection of cell ranges, and splits them into individual cells (for simplicity of the API). The order of values in the “Solution” sequence matches the order of cells in “Variables”.

Personal tools