Files
ortools-clone/docs/cpp_algorithms/structoperations__research_1_1KnapsackItem.html
2019-06-29 18:18:08 +02:00

216 lines
12 KiB
HTML

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>
<title>OR-Tools</title>
<meta http-equiv="Content-Type" content="text/html;"/>
<meta charset="utf-8"/>
<!--<link rel='stylesheet' type='text/css' href="https://fonts.googleapis.com/css?family=Ubuntu:400,700,400italic"/>-->
<link rel="stylesheet" type="text/css" href="ortools.css" title="default" media="screen,print" />
<script type="text/javascript" src="jquery.js"></script>
<script type="text/javascript" src="dynsections.js"></script>
</head>
<body>
<div id="banner-container">
<div id="banner">
<span id="sfml">OR-Tools 7.2</span>
</div>
</div>
<link rel="icon" href="https://developers.google.com/optimization/images/orLogo.png">
<div id="content">
<!-- Generated by Doxygen 1.8.15 -->
<div id="navrow1" class="tabs">
<ul class="tablist">
<li><a href="index.html"><span>Main&#160;Page</span></a></li>
<li><a href="pages.html"><span>Related&#160;Pages</span></a></li>
<li><a href="namespaces.html"><span>Namespaces</span></a></li>
<li class="current"><a href="annotated.html"><span>Classes</span></a></li>
<li><a href="files.html"><span>Files</span></a></li>
</ul>
</div>
<div id="navrow2" class="tabs2">
<ul class="tablist">
<li><a href="annotated.html"><span>Class&#160;List</span></a></li>
<li><a href="classes.html"><span>Class&#160;Index</span></a></li>
<li><a href="inherits.html"><span>Class&#160;Hierarchy</span></a></li>
<li><a href="functions.html"><span>Class&#160;Members</span></a></li>
</ul>
</div>
<div id="nav-path" class="navpath">
<ul>
<li class="navelem"><a class="el" href="namespaceoperations__research.html">operations_research</a></li><li class="navelem"><a class="el" href="structoperations__research_1_1KnapsackItem.html">KnapsackItem</a></li> </ul>
</div>
</div><!-- top -->
<div class="header">
<div class="summary">
<a href="#pub-methods">Public Member Functions</a> &#124;
<a href="#pub-attribs">Public Attributes</a> &#124;
<a href="structoperations__research_1_1KnapsackItem-members.html">List of all members</a> </div>
<div class="headertitle">
<div class="title">operations_research::KnapsackItem Struct Reference</div> </div>
</div><!--header-->
<div class="contents">
<p>--&mdash; <a class="el" href="structoperations__research_1_1KnapsackItem.html" title="--— KnapsackItem --— KnapsackItem is a small struct to pair an item weight with its corresponding pro...">KnapsackItem</a> --&mdash; <a class="el" href="structoperations__research_1_1KnapsackItem.html" title="--— KnapsackItem --— KnapsackItem is a small struct to pair an item weight with its corresponding pro...">KnapsackItem</a> is a small struct to pair an item weight with its corresponding profit.
<a href="structoperations__research_1_1KnapsackItem.html#details">More...</a></p>
<p><code>#include &lt;<a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>&gt;</code></p>
<table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-methods"></a>
Public Member Functions</h2></td></tr>
<tr class="memitem:a5ae427adb88e21ec0f883b8bbcc4b1d4"><td class="memItemLeft" align="right" valign="top">&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structoperations__research_1_1KnapsackItem.html#a5ae427adb88e21ec0f883b8bbcc4b1d4">KnapsackItem</a> (int _id, int64 _weight, int64 _profit)</td></tr>
<tr class="separator:a5ae427adb88e21ec0f883b8bbcc4b1d4"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a99b55b42e78cab5b85c8f411d13f32e9"><td class="memItemLeft" align="right" valign="top">double&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structoperations__research_1_1KnapsackItem.html#a99b55b42e78cab5b85c8f411d13f32e9">GetEfficiency</a> (int64 profit_max) const</td></tr>
<tr class="separator:a99b55b42e78cab5b85c8f411d13f32e9"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table><table class="memberdecls">
<tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="pub-attribs"></a>
Public Attributes</h2></td></tr>
<tr class="memitem:a69aae0cb6039a8a356744648c8dfb9c1"><td class="memItemLeft" align="right" valign="top">const int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structoperations__research_1_1KnapsackItem.html#a69aae0cb6039a8a356744648c8dfb9c1">id</a></td></tr>
<tr class="memdesc:a69aae0cb6039a8a356744648c8dfb9c1"><td class="mdescLeft">&#160;</td><td class="mdescRight">The 'id' field is used to retrieve the initial item in order to communicate with other propagators and state. <a href="#a69aae0cb6039a8a356744648c8dfb9c1">More...</a><br /></td></tr>
<tr class="separator:a69aae0cb6039a8a356744648c8dfb9c1"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:ab974e9e70c585c50c96851ecb454d882"><td class="memItemLeft" align="right" valign="top">const int64&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structoperations__research_1_1KnapsackItem.html#ab974e9e70c585c50c96851ecb454d882">weight</a></td></tr>
<tr class="separator:ab974e9e70c585c50c96851ecb454d882"><td class="memSeparator" colspan="2">&#160;</td></tr>
<tr class="memitem:a057015810b94bfb1b5efac74e9d8d487"><td class="memItemLeft" align="right" valign="top">const int64&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="structoperations__research_1_1KnapsackItem.html#a057015810b94bfb1b5efac74e9d8d487">profit</a></td></tr>
<tr class="separator:a057015810b94bfb1b5efac74e9d8d487"><td class="memSeparator" colspan="2">&#160;</td></tr>
</table>
<a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
<div class="textblock"><p>--&mdash; <a class="el" href="structoperations__research_1_1KnapsackItem.html" title="--— KnapsackItem --— KnapsackItem is a small struct to pair an item weight with its corresponding pro...">KnapsackItem</a> --&mdash; <a class="el" href="structoperations__research_1_1KnapsackItem.html" title="--— KnapsackItem --— KnapsackItem is a small struct to pair an item weight with its corresponding pro...">KnapsackItem</a> is a small struct to pair an item weight with its corresponding profit. </p>
<p>The aim of the knapsack problem is to pack as many valuable items as possible. A straight forward heuristic is to take those with the greatest profit-per-unit-weight. This ratio is called efficiency in this implementation. So items will be grouped in vectors, and sorted by decreasing efficiency. </p><dl class="section note"><dt>Note</dt><dd>profits are duplicated for each dimension. This is done to simplify the code, especially the GetEfficiency method and vector sorting. As there usually are only few dimensions, the overhead should not be an issue. </dd></dl>
<p class="definition">Definition at line <a class="el" href="knapsack__solver_8h_source.html#l00234">234</a> of file <a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>.</p>
</div><h2 class="groupheader">Constructor &amp; Destructor Documentation</h2>
<a id="a5ae427adb88e21ec0f883b8bbcc4b1d4"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a5ae427adb88e21ec0f883b8bbcc4b1d4">&#9670;&nbsp;</a></span>KnapsackItem()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">operations_research::KnapsackItem::KnapsackItem </td>
<td>(</td>
<td class="paramtype">int&#160;</td>
<td class="paramname"><em>_id</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int64&#160;</td>
<td class="paramname"><em>_weight</em>, </td>
</tr>
<tr>
<td class="paramkey"></td>
<td></td>
<td class="paramtype">int64&#160;</td>
<td class="paramname"><em>_profit</em>&#160;</td>
</tr>
<tr>
<td></td>
<td>)</td>
<td></td><td></td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="knapsack__solver_8h_source.html#l00235">235</a> of file <a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Member Function Documentation</h2>
<a id="a99b55b42e78cab5b85c8f411d13f32e9"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a99b55b42e78cab5b85c8f411d13f32e9">&#9670;&nbsp;</a></span>GetEfficiency()</h2>
<div class="memitem">
<div class="memproto">
<table class="mlabels">
<tr>
<td class="mlabels-left">
<table class="memname">
<tr>
<td class="memname">double operations_research::KnapsackItem::GetEfficiency </td>
<td>(</td>
<td class="paramtype">int64&#160;</td>
<td class="paramname"><em>profit_max</em></td><td>)</td>
<td> const</td>
</tr>
</table>
</td>
<td class="mlabels-right">
<span class="mlabels"><span class="mlabel">inline</span></span> </td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="knapsack__solver_8h_source.html#l00237">237</a> of file <a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>.</p>
</div>
</div>
<h2 class="groupheader">Member Data Documentation</h2>
<a id="a69aae0cb6039a8a356744648c8dfb9c1"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a69aae0cb6039a8a356744648c8dfb9c1">&#9670;&nbsp;</a></span>id</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const int operations_research::KnapsackItem::id</td>
</tr>
</table>
</div><div class="memdoc">
<p>The 'id' field is used to retrieve the initial item in order to communicate with other propagators and state. </p>
<p class="definition">Definition at line <a class="el" href="knapsack__solver_8h_source.html#l00245">245</a> of file <a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>.</p>
</div>
</div>
<a id="a057015810b94bfb1b5efac74e9d8d487"></a>
<h2 class="memtitle"><span class="permalink"><a href="#a057015810b94bfb1b5efac74e9d8d487">&#9670;&nbsp;</a></span>profit</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const int64 operations_research::KnapsackItem::profit</td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="knapsack__solver_8h_source.html#l00247">247</a> of file <a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>.</p>
</div>
</div>
<a id="ab974e9e70c585c50c96851ecb454d882"></a>
<h2 class="memtitle"><span class="permalink"><a href="#ab974e9e70c585c50c96851ecb454d882">&#9670;&nbsp;</a></span>weight</h2>
<div class="memitem">
<div class="memproto">
<table class="memname">
<tr>
<td class="memname">const int64 operations_research::KnapsackItem::weight</td>
</tr>
</table>
</div><div class="memdoc">
<p class="definition">Definition at line <a class="el" href="knapsack__solver_8h_source.html#l00246">246</a> of file <a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a>.</p>
</div>
</div>
<hr/>The documentation for this struct was generated from the following file:<ul>
<li><a class="el" href="knapsack__solver_8h_source.html">knapsack_solver.h</a></li>
</ul>
</div><!-- contents -->
</div>
<div id="footer-container">
<div id="footer">
</div>
</div>
</body>
</html>