-
Notifications
You must be signed in to change notification settings - Fork 8
/
Copy pathrobj_instance.cpp
152 lines (113 loc) · 4.15 KB
/
robj_instance.cpp
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
#include "robj_instance.h"
#include "utils.h"
#include <Rcpp.h>
/*.. _secRrefObjInstance:
.. highlight:: r
ObjectiveInstance
=================
*/
/*.. class:: ObjectiveInstance
Represents an AMPL objective. Note that, in case of a scalar objective, all
the properties (corresponding to AMPL suffixes) of the objective instance
can be accessed through methods like :meth:`~.ObjectiveInstance.value`.
The methods have the same name of the corresponding AMPL suffixes.
See http://www.ampl.com/NEW/suffbuiltin.html for a list of the available
suffixes.
All these methods throw an error if called on an entity which has been deleted
in the underlying intepreter.
To gain access to all the values in an entity (for all instances and all
suffixes for that entities), see :meth:`~.Entity.getValues` and the
:class:`DataFrame` class.
*/
RObjectiveInstance::RObjectiveInstance(ampl::ObjectiveInstance impl): _impl(impl) { }
/*.. method:: ObjectiveInstance.name()
Returns the name of this instance.
:return: Name of the instance.
*/
std::string RObjectiveInstance::name() const {
return _impl.name();
}
/*.. method:: ObjectiveInstance.toString()
Returns a string representation of this instance.
:return: String representation of this instance.
*/
std::string RObjectiveInstance::toString() const {
return _impl.toString();
}
/*.. method:: ObjectiveInstance.value()
Get the value of the objective instance.
:return: Value of the objective.
*/
double RObjectiveInstance::value() const {
return _impl.value();
}
/*.. method:: ObjectiveInstance.astatus()
Return the AMPL status.
:return: The AMPL status.
*/
std::string RObjectiveInstance::astatus() const {
return _impl.astatus();
}
/*.. method:: ObjectiveInstance.sstatus()
Return the solver status.
:return: The solver status.
*/
std::string RObjectiveInstance::sstatus() const {
return _impl.sstatus();
}
/*.. method:: ObjectiveInstance.exitcode()
Exit code returned by the solver after most recent solve with this objective.
:return: The exit code returned by the solver.
*/
int RObjectiveInstance::exitcode() const {
return _impl.exitcode();
}
/*.. method:: ObjectiveInstance.message()
Result message returned by solver after most recent solve with this objective.
:return: The result message returned by the solver.
*/
std::string RObjectiveInstance::message() const {
return _impl.message();
}
/*.. method:: ObjectiveInstance.result()
Result string returned by solver after most recent solve with this objective.
:return: The result message returned by the solver.
*/
std::string RObjectiveInstance::result() const {
return _impl.result();
}
/*.. method:: ObjectiveInstance.drop()
Drop this objective.
*/
void RObjectiveInstance::drop() {
return _impl.drop();
}
/*.. method:: ObjectiveInstance.restore()
Restore this objective (if it had been dropped, no effect otherwise)
*/
void RObjectiveInstance::restore() {
return _impl.restore();
}
/*.. method:: ObjectiveInstance.message()
Get the sense of this objective
:return: ``TRUE`` if minimize, ``FALSE`` if maximize.
*/
bool RObjectiveInstance::minimization() const {
return _impl.minimization();
}
// *** RCPP_MODULE ***
RCPP_MODULE(robj_instance){
Rcpp::class_<RObjectiveInstance>("ObjectiveInstance")
.method("name", &RObjectiveInstance::name)
.method("toString", &RObjectiveInstance::toString)
.method("value", &RObjectiveInstance::value, "Get the value of the objective instance")
.method("astatus", &RObjectiveInstance::astatus, "Return the AMPL status")
.method("sstatus", &RObjectiveInstance::sstatus, "Return the solver status")
.method("exitcode", &RObjectiveInstance::exitcode, "Exit code returned by solver after most recent solve with this objective")
.method("message", &RObjectiveInstance::message, "Result message returned by the solver")
.method("result", &RObjectiveInstance::value, "Result string returned by the solver")
.method("drop", &RObjectiveInstance::drop, "Drop this objective")
.method("restore", &RObjectiveInstance::restore, "Restore this objective")
.method("minimization", &RObjectiveInstance::minimization, "Get the sense of this objective")
;
}