Send feedback
Stay organized with collections
Save and categorize content based on your preferences.
C++ Reference: class BaseKnapsackSolver
Note: This documentation is automatically generated.
----- BaseKnapsackSolver -----
This is the base class for knapsack solvers.
Method
BaseKnapsackSolver
Return type: explicit
Arguments: const std::string& solver_name
~BaseKnapsackSolver
Return type: virtual
best_solution
Return type: virtual bool
Arguments: int item_id
Returns true if the item 'item_id' is packed in the optimal knapsack.
GetLowerAndUpperBoundWhenItem
Return type: virtual void
Arguments: int item_id, bool is_item_in,
int64_t* lower_bound,
int64_t* upper_bound
Gets the lower and upper bound when the item is in or out of the knapsack.
To ensure objects are correctly initialized, this method should not be
called before ::Init.
GetName
Return type: virtual std::string
Init
Return type: virtual void
Arguments: const std::vector<int64_t>& profits,
const std::vector<std::vector<int64_t> >& weights,
const std::vector<int64_t>& capacities
Initializes the solver and enters the problem to be solved.
Solve
Return type: virtual int64_t
Arguments: TimeLimit* time_limit, bool* is_solution_optimal
Solves the problem and returns the profit of the optimal solution.
Send feedback
Except as otherwise noted, the content of this page is licensed under the Creative Commons Attribution 4.0 License , and code samples are licensed under the Apache 2.0 License . For details, see the Google Developers Site Policies . Java is a registered trademark of Oracle and/or its affiliates.
Last updated 2022-09-14 UTC.
[{
"type": "thumb-down",
"id": "missingTheInformationINeed",
"label":"Missing the information I need"
},{
"type": "thumb-down",
"id": "tooComplicatedTooManySteps",
"label":"Too complicated / too many steps"
},{
"type": "thumb-down",
"id": "outOfDate",
"label":"Out of date"
},{
"type": "thumb-down",
"id": "samplesCodeIssue",
"label":"Samples / code issue"
},{
"type": "thumb-down",
"id": "otherDown",
"label":"Other"
}]
[{
"type": "thumb-up",
"id": "easyToUnderstand",
"label":"Easy to understand"
},{
"type": "thumb-up",
"id": "solvedMyProblem",
"label":"Solved my problem"
},{
"type": "thumb-up",
"id": "otherUp",
"label":"Other"
}]
Need to tell us more?