Initializing help system before first use

XPRBsol

XPRBsol


Description
Methods for defining, modifying and accessing solutions. Note that all variables in a solution must belong to the same problem as the solution itself.
Constructors
Methods
Delete a variable from a solution.
Get the size of a solution.
Get the value assigned to a variable in a solution.
Test the validity of the solution object.
Print out a solution
Reset the solution object.
Set a variable to the given value in a solution.

Constructor detail

XPRBsol
Synopsis
XPRBsol();
XPRBsos(xbsol *s);
Argument
A solution in BCL C.
Description
Create a new solution object.

Method detail

delVar
Synopsis
int delVar(XPRBvar& var);
Argument
var 
A BCL variable.
Return value
0 if method executed successfully, 1 otherwise.
Description
This function deletes a variable (assigned to a value) from the given solution.
Example
Related topics

getSize
Synopsis
int getSize();
Return value
Size (= number of variables assigned to a value) of the solution, or -1 in case of an error.
Description
This method returns the size of a solution (or -1 in case of an error).
Example
Related topics

getVar
Synopsis
int getVar(XPRBvar& var, double *val);
Arguments
var 
A BCL variable.
val 
Pointer to a double where the value will be returned.
Return value
variable var is assigned a value in the solution and the value is returned in val;
-1 
variable var is not assigned any value in the solution ( val is left unmodified);
an error has occurred.
Description
This method retrieves the value assigned to the given variable in a solution.
Example
Related topics

isValid
Synopsis
bool isValid();
Return value
true if object is valid, false otherwise.
Description
This method checks whether the solution object is correctly defined.

print
Synopsis
int print();
Return value
0 if function executed successfully, 1 otherwise.
Description
This method prints out a solution (note that XPRBsol solutions represent user-defined solutions to be passed to the Optimizer, not solutions coming from the Optimizer). A solution is printed as a sequence like " varname = value, ... ". If the solution doesn't contain any variable, only an empty line is printed.. It is not available in the student version.
Example
Related topics
Calls XPRBprintsol

reset
Synopsis
void reset();
Description
This method clears the definition of the solution object; includes deletion of the underlying C object. This may be useful to free the memory used for storing the solution (note that this would be freed in any case when the problem is destroyed).
Example
Related topics
Calls XPRBdelsol

setVar
Synopsis
int setVar(XPRBvar& var, double val);
Arguments
var 
A BCL variable.
val 
Value assigned to variable var in this solution.
Return value
0 if method executed successfully, 1 otherwise.
Description
This function sets a variable to the given value in a solution. If the variable was already assigned a value, the value is overwritten.
Example
This example sets variable x and y in solution sol1 and then changes them.
XPRBvar x, y;
XPRBsol sol1;
XPRBprob prob("myprob");
double d;

x = prob.newVar("x", XPRB_PL, 0, 200);
y = prob.newVar("y", XPRB_PL, 0, 200);
sol1 = prob.newSol();
sol1.setVar(x, 7.0);
sol1.setVar(y, 15.0);
cout << "Sol1: ";
sol1.print();                         // Sol1: x = 7, y = 15
sol1.setVar(x, 10.0);
sol1.getVar(x, &d);
cout << "In sol1, x = " << d << endl; // In sol1, x = 10
sol1.delVar(y);
cout << "Sol1: ";
sol1.print();                         // Sol1: x = 10
sol1.reset();
Related topics


© 2001-2019 Fair Isaac Corporation. All rights reserved. This documentation is the property of Fair Isaac Corporation (“FICO”). Receipt or possession of this documentation does not convey rights to disclose, reproduce, make derivative works, use, or allow others to use it except solely for internal evaluation purposes to determine whether to purchase a license to the software described in this documentation, or as otherwise set forth in a written software license agreement between you and FICO (or a FICO affiliate). Use of this documentation and the software described in it must conform strictly to the foregoing permitted uses, and no other use is permitted.