Many hyperlinks are disabled.
Use anonymous login to enable hyperlinks.

Overview
Comment:cVillage::AddTrader method
Downloads: Tarball | ZIP archive | SQL archive
Timelines: family | ancestors | descendants | both | trunk
Files: files | file ages | folders
SHA1:bba070fa45ff9e1f59d7d0535345dc189184314f
User & Date: ravenspoint 2016-05-29 00:12:27
Context
2016-05-29
00:19
problem 2 check-in: 9e6ffedda7 user: ravenspoint tags: trunk
00:12
cVillage::AddTrader method check-in: bba070fa45 user: ravenspoint tags: trunk
2016-05-28
21:21
add trade,cpp main check-in: 62cd02833a user: ravenspoint tags: trunk
Changes

Changes to trade.cpp.

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
#include <boost/property_map/property_map.hpp>
#include <boost/graph/depth_first_search.hpp>

using namespace std;
using namespace boost;

#include "trade.h"









void cVillage::ConstructProblem1()
{
    static eCommodity hold = eCommodity::wood;
    static float quantity = 1;
    myTraveler.myHold = &hold;
    myTraveler.myQuantity = &quantity;
    myTraveler.myInitiallHold = hold;
    myTraveler.myInitialQuantity = quantity;

    static vector<int> path;
    myTraveler.myPath = &path;

    myGraph[ add_vertex( myGraph ) ] =  cTrader(  eCommodity::wood,  eCommodity::wood, 1);

    myGraph[ add_vertex( myGraph ) ] = cTrader( eCommodity::wood, eCommodity::sand, 2);
    myGraph[ add_vertex( myGraph ) ] = cTrader( eCommodity::sand, eCommodity::gras, 0.5);
    myGraph[ add_vertex( myGraph ) ] = cTrader( eCommodity::gras, eCommodity::sand, 1);
    myGraph[ add_vertex( myGraph ) ] = cTrader( eCommodity::sand, eCommodity::wood, 0.25);
    myGraph[ add_vertex( myGraph ) ] = cTrader( eCommodity::gras, eCommodity::wood, 0.5);

}

void cVillage::Display()
{
    int index = 0;
    graph_traits<trade_graph_t>::vertex_iterator vi, vi_end;
    for (boost::tie(vi, vi_end) = vertices(myGraph); vi != vi_end; ++vi)







>
>
>
>
>
>
>
>













|

|
|
|
|
|
<







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
#include <boost/property_map/property_map.hpp>
#include <boost/graph/depth_first_search.hpp>

using namespace std;
using namespace boost;

#include "trade.h"

void cVillage::AddTrader(
    eCommodity sell,
    eCommodity buy,
    float price )
{
    myGraph[ add_vertex( myGraph ) ] = cTrader( sell, buy, price );
}

void cVillage::ConstructProblem1()
{
    static eCommodity hold = eCommodity::wood;
    static float quantity = 1;
    myTraveler.myHold = &hold;
    myTraveler.myQuantity = &quantity;
    myTraveler.myInitiallHold = hold;
    myTraveler.myInitialQuantity = quantity;

    static vector<int> path;
    myTraveler.myPath = &path;

    AddTrader( eCommodity::wood,  eCommodity::wood, 1);

    AddTrader( eCommodity::wood, eCommodity::sand, 2 );
    AddTrader( eCommodity::sand, eCommodity::gras, 0.5 );
    AddTrader( eCommodity::gras, eCommodity::sand, 1);
    AddTrader( eCommodity::sand, eCommodity::wood, 0.25);
    AddTrader( eCommodity::gras, eCommodity::wood, 0.5);

}

void cVillage::Display()
{
    int index = 0;
    graph_traits<trade_graph_t>::vertex_iterator vi, vi_end;
    for (boost::tie(vi, vi_end) = vertices(myGraph); vi != vi_end; ++vi)

Changes to trade.h.

164
165
166
167
168
169
170





171
172
173
174
175
176
177
class cVillage
{
public:
    cTraveler myTraveler;

    trade_graph_t myGraph;






    void ConstructProblem1();

    void Display();

    void ConstructSensibleTrips();

     void Travel()







>
>
>
>
>







164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
class cVillage
{
public:
    cTraveler myTraveler;

    trade_graph_t myGraph;

    void AddTrader(
                   eCommodity sell,
                   eCommodity buy,
                   float price );

    void ConstructProblem1();

    void Display();

    void ConstructSensibleTrips();

     void Travel()