Skip to content

Response

APIStatus

Bases: AutoName

API Status.

PENDING shows that the request has been sent but not caught by solvers.

RUNNING shows that the request has been sent and caught by solvers.

SUCCESS shows that solver returns the solution successfully.

FAILED shows that solver fails to return solutions with some errors.

UNKNOWNERROR and VALIDATIONERROR shows that solver fails to return solutions with some errors that is not expected. Please contact to Jij development team if you find this error.

AutoName

Bases: Enum

Enumerate class for auto-generating the next enumerated value.

BaseResponse

Abstract base class representing the response from the API.

error_message property

Get the error message of the response.

status property

Get the status of the response.

__repr__()

Return the string representation of the object.

__str__()

Return the string representation of the object.

empty_data() abstractmethod classmethod

Abstract method for generating empty data.

empty_response(status, client, solution_id, err_dict={}) classmethod

Generate empty_response.

Parameters:

Name Type Description Default
status APIStatus

status

required
client JijZeptClient

client

required
solution_id str

solution_id

required
err_dict

error dictionary

{}

from_json_obj(json_obj) abstractmethod classmethod

Abstract method for initializing object from JSON data.

Parameters:

Name Type Description Default
json_obj

JSON data

required

get_result(solution_id=None)

Get result from cloud.

If solution_id is specified. use this id. Otherwise, use self.solution_id

If status is updated. update self data

Parameters:

Name Type Description Default
solution_id Optional[str]

specified solution id. Defaults to None.

None

Returns:

Name Type Description
_TBaseResponse _TBaseResponse

description

set_err_dict(err_dict)

Set the error dictionary of the response.

set_status(status)

Set the status of the response.

JijModelingResponse

Bases: BaseResponse

Return object from JijZept.

variable_labels: dict[int, str] property

Return variable labels.

Returns:

Type Description
dict[int, str]

dict[int, str]: Dictionary of variable labels.

__repr__()

Return the representation of the object.

__str__()

Return the string representation of the object.

empty_data() classmethod

Create an empty object.

Returns:

Name Type Description
Any Any

Empty object.

feasible(rtol=1e-05, atol=1e-08)

Return a Sampleset with only feasible solutions. If there is no feasible solution, the record and evaluation are empty.

Parameters:

Name Type Description Default
rtol float

The relative tolerance parameter. Defaults to 1e-5.

1e-05
atol float

The absolute tolerance parameter. Defaults to 1e-8.

1e-08

Returns:

Name Type Description
SampleSet SampleSet

A SampleSet object with only feasible solutions or empty.

Note

The feasible solutions are determined by the following condition: $$ |0 - v| \leq \mathrm{atol} + \mathrm{rtol} \cdot |v| $$

from_json_obj(json_obj) classmethod

Generate object from JSON object.

Parameters:

Name Type Description Default
json_obj str

JSON object

required

Returns:

Name Type Description
Any Any

object

get_sampleset()

Return a row oriented SampleSet object.

Returns:

Type Description
SampleSet

jm.experimental.SampleSet: A row oriented SampleSet object.

infeasible(rtol=1e-05, atol=1e-08)

Return a Sampleset with only infeasible solutions. If there is no infeasible solution, the record and evaluation are empty.

Parameters:

Name Type Description Default
rtol float

The relative tolerance parameter. Defaults to 1e-5.

1e-05
atol float

The absolute tolerance parameter. Defaults to 1e-8.

1e-08

Returns:

Name Type Description
SampleSet SampleSet

A SampleSet object with only infeasible solutions or empty.

Note

The feasible solutions are determined by the following condition: $$ |0 - v| > \mathrm{atol} + \mathrm{rtol} \cdot |v| $$

is_dense()

Return true if the solution is dense.

Returns:

Name Type Description
bool SampleSet

True if the solution is dense.

is_sparse()

Return true if the solution is sparse.

Returns:

Name Type Description
bool SampleSet

True if the solution is sparse.

lowest(rtol=1e-05, atol=1e-08)

Return a Sampleset with feasible solutions which has the lowest objective. If there is no feasible solution, the record and evaluation are empty.

Parameters:

Name Type Description Default
rtol float

The relative tolerance parameter. Defaults to 1e-5.

1e-05
atol float

The absolute tolerance parameter. Defaults to 1e-8.

1e-08

Returns:

Name Type Description
SampleSet SampleSet

A SampleSet object with feasible solutions or empty.

Note

The feasible solutions are determined by the following condition: $$ |0 - v| ¥leq ¥mathrm{atol} + ¥mathrm{rtol} ¥cdot |v| $$

set_variable_labels(var_labels)

Set variable labels.

Parameters:

Name Type Description Default
var_labels dict[int, str]

Dictionary of variable labels.

required

to_dense()

Return a Sampleset whose record is converted into a dense solution format. If the record is already a dense solution format, return itself.

Returns:

Name Type Description
SampleSet SampleSet

A SampleSet object.

to_json()

Serialize the SampleSet object into a JSON string.

Returns:

Name Type Description
str str

A JSON string.

Note

A numpy array is converted into a list.

to_pandas()

Convert into a pandas DataFrame.

Returns:

Type Description

pandas.DataFrame: A pandas DataFrame.