Gnm.Solver

g GObject.Object GObject.Object Gnm.Solver Gnm.Solver GObject.Object->Gnm.Solver

Subclasses:

Gnm.IterSolver, Gnm.SubSolver

Methods

Inherited:

GObject.Object (37)

Structs:

GObject.ObjectClass (5)

class

db_get ()

class

db_register (factory)

class

db_unregister (factory)

class

debug ()

cell_index (cell)

check_constraints ()

check_timeout ()

compute_hessian (xs)

create_report (name)

elapsed ()

finished ()

get_target_value ()

has_analytic_gradient ()

has_analytic_hessian ()

has_solution ()

line_search (x0, dir, try_reverse, step, max_step, eps)

pick_lp_coords ()

prepare (wbc)

restore_vars (vals)

save_vars ()

saveas (wbc, fs, templ, filename)

set_reason (reason)

set_status (status)

set_var (i, x)

set_vars (xs)

start (wbc)

stop ()

store_result ()

Virtual Methods

Inherited:

GObject.Object (7)

do_prepare (wbc)

do_start (wbc)

do_stop ()

Properties

Name

Type

Flags

Short Description

endtime

float

r/w

Time the solver finished

flip-sign

bool

r/w

Flip sign of target GOffice.value

params

Gnm.SolverParameters

r/w/co

Solver parameters

reason

str

r/w

The reason behind the solver’s status

result

Gnm.SolverResult

r/w

Current best feasible result

sensitivity

Gnm.SolverSensitivity

r/w

Sensitivity results

starttime

float

r/w

Time the solver was started

status

Gnm.SolverStatus

r/w

The solver’s current status

Signals

Inherited:

GObject.Object (1)

Name

Short Description

prepare

start

stop

Fields

Inherited:

GObject.Object (1)

Name

Type

Access

Description

discrete

int

r

endtime

float

r

flip_sign

bool

r

gradient

[object]

r

gradient_status

int

r

hessian

[object]

r

hessian_status

int

r

index_from_cell

{object: object}

r

input_cells

[object]

r

max

float

r

min

float

r

params

Gnm.SolverParameters

r

parent

GObject.Object

r

reason

str

r

result

Gnm.SolverResult

r

sensitivity

Gnm.SolverSensitivity

r

starttime

float

r

status

Gnm.SolverStatus

r

target

Gnm.Cell

r

Class Details

class Gnm.Solver(**kwargs)
Bases:

GObject.Object

Abstract:

No

Structure:

Gnm.SolverClass

classmethod db_get()
Returns:

list of registered solver factories.

Return type:

[Gnm.SolverFactory]

classmethod db_register(factory)
Parameters:

factory (Gnm.SolverFactory) –

classmethod db_unregister(factory)
Parameters:

factory (Gnm.SolverFactory) –

classmethod debug()
Return type:

bool

cell_index(cell)
Parameters:

cell (Gnm.Cell) –

Return type:

int

check_constraints()
Return type:

bool

check_timeout()
Return type:

bool

compute_hessian(xs)
Parameters:

xs (float) – Point to compute Hessian at

Returns:

A matrix containing the Hessian. This function takes the flip-sign property into account.

Return type:

Gnm.Matrix

create_report(name)
Parameters:

name (str) –

elapsed()
Return type:

float

finished()
Return type:

bool

get_target_value()
Returns:

the current GOffice.value of the target cell, possibly with the sign flipped.

Return type:

float

has_analytic_gradient()
Returns:

True if the gradient can be computed analytically.

Return type:

bool

has_analytic_hessian()
Returns:

True if the Hessian can be computed analytically.

Return type:

bool

has_solution()
Return type:

bool

Parameters:
  • x0 (float) – Starting point

  • dir (float) – direction

  • try_reverse (bool) – whether to try reverse direction at all

  • step (float) – initial step size

  • max_step (float) – largest allowed step

  • eps (float) – tolerance for optimal step

Returns:

optimal step size.

py:

location to store resulting objective function GOffice.value

Return type:

(float, py: float)

pick_lp_coords()
Returns:

px1:

first coordinate GOffice.value

px2:

second coordinate GOffice.value

Return type:

(px1: float, px2: float)

Pick two good values for each coordinate. We prefer 0 and 1 when they are valid.

prepare(wbc)
Parameters:

wbc (Gnm.WorkbookControl) – control for user interaction

Raises:

GLib.Error

Returns:

True ok success, False on error.

Return type:

bool

Prepare for solving. Preparation need not do anything, but may include such tasks as checking that the model is valid for the solver and locating necessary external programs.

restore_vars(vals)
Parameters:

vals ([Gnm.Value]) – values to restore

save_vars()
Return type:

[Gnm.Value]

saveas(wbc, fs, templ, filename)
Parameters:
Raises:

GLib.Error

Return type:

bool

set_reason(reason)
Parameters:

reason (str) –

set_status(status)
Parameters:

status (Gnm.SolverStatus) –

set_var(i, x)
Parameters:
set_vars(xs)
Parameters:

xs (float) –

start(wbc)
Parameters:

wbc (Gnm.WorkbookControl) – control for user interaction

Raises:

GLib.Error

Returns:

True ok success, False on error.

Return type:

bool

Start the solving process. If needed, the solver will be prepared first.

stop()
Raises:

GLib.Error

Returns:

True ok success, False on error.

Return type:

bool

Terminate the currently-running solver.

store_result()
do_prepare(wbc) virtual
Parameters:

wbc (Gnm.WorkbookControl) – control for user interaction

Returns:

True ok success, False on error.

Return type:

bool

Prepare for solving. Preparation need not do anything, but may include such tasks as checking that the model is valid for the solver and locating necessary external programs.

do_start(wbc) virtual
Parameters:

wbc (Gnm.WorkbookControl) – control for user interaction

Returns:

True ok success, False on error.

Return type:

bool

Start the solving process. If needed, the solver will be prepared first.

do_stop() virtual
Returns:

True ok success, False on error.

Return type:

bool

Terminate the currently-running solver.

Signal Details

Gnm.Solver.signals.prepare(solver, object, p0)
Signal Name:

prepare

Flags:

RUN_LAST

Parameters:
Return type:

bool

Gnm.Solver.signals.start(solver, object, p0)
Signal Name:

start

Flags:

RUN_LAST

Parameters:
Return type:

bool

Gnm.Solver.signals.stop(solver, object)
Signal Name:

stop

Flags:

RUN_LAST

Parameters:
Return type:

bool

Property Details

Gnm.Solver.props.endtime
Name:

endtime

Type:

float

Default Value:

-1.0

Flags:

READABLE, WRITABLE

Time the solver finished

Gnm.Solver.props.flip_sign
Name:

flip-sign

Type:

bool

Default Value:

False

Flags:

READABLE, WRITABLE

Flip sign of target GOffice.value

Gnm.Solver.props.params
Name:

params

Type:

Gnm.SolverParameters

Default Value:

None

Flags:

READABLE, WRITABLE, CONSTRUCT_ONLY

Solver parameters

Gnm.Solver.props.reason
Name:

reason

Type:

str

Default Value:

None

Flags:

READABLE, WRITABLE

The reason behind the solver’s status

Gnm.Solver.props.result
Name:

result

Type:

Gnm.SolverResult

Default Value:

None

Flags:

READABLE, WRITABLE

Current best feasible result

Gnm.Solver.props.sensitivity
Name:

sensitivity

Type:

Gnm.SolverSensitivity

Default Value:

None

Flags:

READABLE, WRITABLE

Sensitivity results

Gnm.Solver.props.starttime
Name:

starttime

Type:

float

Default Value:

-1.0

Flags:

READABLE, WRITABLE

Time the solver was started

Gnm.Solver.props.status
Name:

status

Type:

Gnm.SolverStatus

Default Value:

Gnm.SolverStatus.READY

Flags:

READABLE, WRITABLE

The solver’s current status