Oppure

Loading
06/02/13 10:08
Alberto19890
Buongiorno a tutti, sono Alberto e sono nuovo del forum, scusate perchè probabilmente la domanda per voi è banale e magari è già stata posta da qualche altro utente ma sono veramente disperato.

Sto finendo gli studi in ingegneria meccanica al Polimi e sto facendo la tesi.
La mia tesi si riferisce precisamente allo scheduling della produzione industriale che può essere espresso come un grafo orientato (AoA) per poi, dopo opportune semplificazioni con serie e parallelo, arrivare ad avere una stima del tempo di completamento del prodotto.

Arriviamo alla parte per me ostica: abbiamo fatto un solo esame di programmazione C al primo anno, ma niente di accessivamente complesso. il mio professore pretende un programma in C++, scritto su Visual Studio 2008, in cui leggo il grafo, semplifico e vedo il risultato a schermo.

Visto che l'ambito non è propriamente il mio, ho letto parecchio materiale su Boost Graph Library e sto tentando (invano) di far girare un programma GIA' FATTO.

Il problema probabilmente, sta nel fatto che non riesco a far leggere gli header al compilatore e mi visualizza "fatal error".

voi sapete come aiutarmi? come faccio a far leggere gli header?

grazie mille delle risposte!
aaa
07/02/13 11:04
come non legge gli headers? Hai fatto un nuovo progetto e importato i file che ti servono?
07/02/13 17:41
pierotofy
Posta l'output completo degli errori...
Il mio blog: piero.dev
12/02/13 8:57
Alberto19890
#include <boost/config.hpp>
#include <iostream>
#include <vector>
#include <string>
#include <boost/graph/adjacency_list.hpp>
#include <boost/graph/depth_first_search.hpp>
#include <boost/graph/breadth_first_search.hpp>
#include <boost/property_map/property_map.hpp>
#include <boost/graph/graph_utility.hpp> // for boost::make_list


/*
  Example of using a visitor with the depth first search 
    and breadth first search algorithm

  Sacramento ---- Reno ---- Salt Lake City
     |
  San Francisco
     |
  San Jose ---- Fresno
     |
  Los Angeles ---- Las Vegas ---- Phoenix
     |
  San Diego  


  The visitor has three main functions: 
  
  discover_vertex(u,g) is invoked when the algorithm first arrives at the
    vertex u. This will happen in the depth first or breadth first
    order depending on which algorithm you use.

  examine_edge(e,g) is invoked when the algorithm first checks an edge to see
    whether it has already been there. Whether using BFS or DFS, all
    the edges of vertex u are examined immediately after the call to
    visit(u).

  finish_vertex(u,g) is called when after all the vertices reachable from vertex
    u have already been visited.    

 */

using namespace std;
using namespace boost;


struct city_arrival : public base_visitor<city_arrival>
{
  city_arrival(string* n) : names(n) { }
  typedef on_discover_vertex event_filter;
  template <class Vertex, class Graph>
  inline void operator()(Vertex u, Graph&) {
    cout << endl << "arriving at " << names[u] << endl
         << "  neighboring cities are: ";
  }
  string* names;
};

struct neighbor_cities : public base_visitor<neighbor_cities>
{
  neighbor_cities(string* n) : names(n) { }
  typedef on_examine_edge event_filter;
  template <class Edge, class Graph>
  inline void operator()(Edge e, Graph& g) {
    cout << names[ target(e, g) ] << ", ";
  }
  string* names;
};

struct finish_city : public base_visitor<finish_city>
{
  finish_city(string* n) : names(n) { }
  typedef on_finish_vertex event_filter;
  template <class Vertex, class Graph>
  inline void operator()(Vertex u, Graph&) {
    cout << endl << "finished with " << names[u] << endl;
  }
  string* names;
};

int main(int, char*[]) 
{

  enum { SanJose, SanFran, LA, SanDiego, Fresno, LasVegas, Reno,
         Sacramento, SaltLake, Phoenix, N };

  string names[] = { "San Jose", "San Francisco", "Los Angeles", "San Diego", 
                     "Fresno", "Las Vegas", "Reno", "Sacramento",
                     "Salt Lake City", "Phoenix" };

  typedef std::pair<int,int> E;
  E edge_array[] = { E(Sacramento, Reno), E(Sacramento, SanFran),
                     E(Reno, SaltLake),
                     E(SanFran, SanJose),
                     E(SanJose, Fresno), E(SanJose, LA),
                     E(LA, LasVegas), E(LA, SanDiego),
                     E(LasVegas, Phoenix) };

  /* Create the graph type we want. */
  typedef adjacency_list<vecS, vecS, undirectedS> Graph;
#if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
  // VC++ has trouble with the edge iterator constructor
  Graph G(N);
  for (std::size_t j = 0; j < sizeof(edge_array)/sizeof(E); ++j)
    add_edge(edge_array[j].first, edge_array[j].second, G);
#else
  Graph G(edge_array, edge_array + sizeof(edge_array)/sizeof(E), N);
#endif

  cout << "*** Depth First ***" << endl;
  depth_first_search
    (G, 
     visitor(make_dfs_visitor(boost::make_list(city_arrival(names),
                                               neighbor_cities(names),
                                               finish_city(names)))));
  cout << endl;

  /* Get the source vertex */
  boost::graph_traits<Graph>::vertex_descriptor 
    s = vertex(SanJose,G);

  cout << "*** Breadth First ***" << endl;
  breadth_first_search
    (G, s, visitor(make_bfs_visitor(boost::make_list(city_arrival(names), 
                                                     neighbor_cities(names), 
                                                     finish_city(names)))));
  
  return 0;
}
Ultima modifica effettuata da pierotofy 12/02/13 15:07
aaa
12/02/13 9:09
Alberto19890
Allora ragazzi il programma che devo far girare è questo che ho scritto nel post precedente.

adesso vi mostro passo dopo passo quello che ho fatto (scusate se è scritto in Inglese, ma la tesi la sto scrivendo così;):

•    From Visual Studio's File menu, select New > Project…
•    In the left-hand pane of the resulting New Project dialog, select Visual C++ > Win32.
•    In the right-hand pane, select Win32 Console Application (VS8.0) or Win32 Console Project (VS7.1).
•    In the name field, enter “example”
•    Right-click example in the Solution Explorer pane and select Properties from the resulting pop-up menu
•    In Configuration Properties > C/C++ > General > Additional Include Directories, enter the path to the Boost root directory, for example
C:\Program Files\boost\boost_1_52_0
•    In Configuration Properties > C/C++ > Precompiled Headers, change Use Precompiled Header (/Yu) to Not Using Precompiled Headers.3
•    Replace the contents of the example.cpp generated by the IDE with the example code above.
•    From the Build menu, select Build Solution.
To test your application, hit the F5 key and type the following into the resulting window, followed by the Return key.

Teoricamente, premendo F5 dovrebbe visualizzare a schermo i nomi delle città, ma mi visualizza questo... dove sbaglio?? il problema è che, lavorando, non posso neanche starci dietro s enon per mezza giornata alla tesi.. disastro!!

aaa
12/02/13 9:13
Alberto19890
il programma che dovrei fare è il seguente:

The algorithm repeats all the following steps until no vertices are present in the unsatisfied list:
1)    Remove some vertex v from the unsatisfied list
2)    Examine edges entering v. If two edges with the form (u,v) are found, apply a parallel reduction to them. Continue examining edges entering v and applying parallel reductions until either (i) only one edge leaves v or (ii) v is found to have two distinct predecessors
3)    Examine edges leaving v. If two edges sith the form (v,w) are found, apply a parallel reduction to them. Continue examining edges leaving v and applying parallel reduction until either (i) only one edge leaves v or (ii) v is found to have two distinct successors
4)    If only one edge (u,v) now enters v and only one edge (v,w) leaves v, carry out the following steps:
a.    Apply a series reduction to delete v and replace (u,v) and (v,w) by a new edge (u,w)
b.    If u is not the source and not on the unsatisfied list, add it to the unsatisfied list
c.    If w is not the sink and not on the unsatisfied list, add it to the unsatisfied list
When the unsatisfied list is empty, we test whether any vertices other than the source and the sink remain. It so, the multidigraph is not reducible to a single edge. If not, we complete the reduction to a single edge by applying parallel reduction to the edges joining the source and sink.

a me, per uno che non ha mai fatto programmazione, non sembra facile :d
aaa
12/02/13 9:35
Alberto19890
aaa
12/02/13 10:48
Alberto19890
Buongiorno, ho provato a far girare un nuovo programma e l'errore che mi da è sempre connesso agli headers e l'output è il seguente:

aaa