Questo sito utilizza cookies solo per scopi di autenticazione sul sito e nient'altro. Nessuna informazione personale viene tracciata. Leggi l'informativa sui cookies.
Username: Password: oppure
C/C++ - AIUTO PER TESI sui grafi, IMPORTANTE. Visual Studio express 2008
Forum - C/C++ - AIUTO PER TESI sui grafi, IMPORTANTE. Visual Studio express 2008

Pagine: [ 1 2 ] Precedente | Prossimo
Avatar
Alberto19890 (Normal User)
Newbie


Messaggi: 8
Iscritto: 06/02/2013

Segnala al moderatore
Postato alle 11:08
Mercoledì, 06/02/2013
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!

PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 12:04
Giovedì, 07/02/2013
come non legge gli headers? Hai fatto un nuovo progetto e importato i file che ti servono?

PM Quote
Avatar
pierotofy (Admin)
Guru^2


Messaggi: 6230
Iscritto: 04/12/2003

Segnala al moderatore
Postato alle 18:41
Giovedì, 07/02/2013
Posta l'output completo degli errori...


Il mio blog: https://piero.dev
PM Quote
Avatar
Alberto19890 (Normal User)
Newbie


Messaggi: 8
Iscritto: 06/02/2013

Segnala al moderatore
Postato alle 9:57
Martedì, 12/02/2013
Codice sorgente - presumibilmente C++

  1. #include <boost/config.hpp>
  2. #include <iostream>
  3. #include <vector>
  4. #include <string>
  5. #include <boost/graph/adjacency_list.hpp>
  6. #include <boost/graph/depth_first_search.hpp>
  7. #include <boost/graph/breadth_first_search.hpp>
  8. #include <boost/property_map/property_map.hpp>
  9. #include <boost/graph/graph_utility.hpp> // for boost::make_list
  10.  
  11.  
  12. /*
  13.   Example of using a visitor with the depth first search
  14.     and breadth first search algorithm
  15.  
  16.   Sacramento ---- Reno ---- Salt Lake City
  17.      |
  18.   San Francisco
  19.      |
  20.   San Jose ---- Fresno
  21.      |
  22.   Los Angeles ---- Las Vegas ---- Phoenix
  23.      |
  24.   San Diego  
  25.  
  26.  
  27.   The visitor has three main functions:
  28.  
  29.   discover_vertex(u,g) is invoked when the algorithm first arrives at the
  30.     vertex u. This will happen in the depth first or breadth first
  31.     order depending on which algorithm you use.
  32.  
  33.   examine_edge(e,g) is invoked when the algorithm first checks an edge to see
  34.     whether it has already been there. Whether using BFS or DFS, all
  35.     the edges of vertex u are examined immediately after the call to
  36.     visit(u).
  37.  
  38.   finish_vertex(u,g) is called when after all the vertices reachable from vertex
  39.     u have already been visited.    
  40.  
  41.  */
  42.  
  43. using namespace std;
  44. using namespace boost;
  45.  
  46.  
  47. struct city_arrival : public base_visitor<city_arrival>
  48. {
  49.   city_arrival(string* n) : names(n) { }
  50.   typedef on_discover_vertex event_filter;
  51.   template <class Vertex, class Graph>
  52.   inline void operator()(Vertex u, Graph&) {
  53.     cout << endl << "arriving at " << names[u] << endl
  54.          << "  neighboring cities are: ";
  55.   }
  56.   string* names;
  57. };
  58.  
  59. struct neighbor_cities : public base_visitor<neighbor_cities>
  60. {
  61.   neighbor_cities(string* n) : names(n) { }
  62.   typedef on_examine_edge event_filter;
  63.   template <class Edge, class Graph>
  64.   inline void operator()(Edge e, Graph& g) {
  65.     cout << names[ target(e, g) ] << ", ";
  66.   }
  67.   string* names;
  68. };
  69.  
  70. struct finish_city : public base_visitor<finish_city>
  71. {
  72.   finish_city(string* n) : names(n) { }
  73.   typedef on_finish_vertex event_filter;
  74.   template <class Vertex, class Graph>
  75.   inline void operator()(Vertex u, Graph&) {
  76.     cout << endl << "finished with " << names[u] << endl;
  77.   }
  78.   string* names;
  79. };
  80.  
  81. int main(int, char*[])
  82. {
  83.  
  84.   enum { SanJose, SanFran, LA, SanDiego, Fresno, LasVegas, Reno,
  85.          Sacramento, SaltLake, Phoenix, N };
  86.  
  87.   string names[] = { "San Jose", "San Francisco", "Los Angeles", "San Diego",
  88.                      "Fresno", "Las Vegas", "Reno", "Sacramento",
  89.                      "Salt Lake City", "Phoenix" };
  90.  
  91.   typedef std::pair<int,int> E;
  92.   E edge_array[] = { E(Sacramento, Reno), E(Sacramento, SanFran),
  93.                      E(Reno, SaltLake),
  94.                      E(SanFran, SanJose),
  95.                      E(SanJose, Fresno), E(SanJose, LA),
  96.                      E(LA, LasVegas), E(LA, SanDiego),
  97.                      E(LasVegas, Phoenix) };
  98.  
  99.   /* Create the graph type we want. */
  100.   typedef adjacency_list<vecS, vecS, undirectedS> Graph;
  101. #if defined(BOOST_MSVC) && BOOST_MSVC <= 1300
  102.   // VC++ has trouble with the edge iterator constructor
  103.   Graph G(N);
  104.   for (std::size_t j = 0; j < sizeof(edge_array)/sizeof(E); ++j)
  105.     add_edge(edge_array[j].first, edge_array[j].second, G);
  106. #else
  107.   Graph G(edge_array, edge_array + sizeof(edge_array)/sizeof(E), N);
  108. #endif
  109.  
  110.   cout << "*** Depth First ***" << endl;
  111.   depth_first_search
  112.     (G,
  113.      visitor(make_dfs_visitor(boost::make_list(city_arrival(names),
  114.                                                neighbor_cities(names),
  115.                                                finish_city(names)))));
  116.   cout << endl;
  117.  
  118.   /* Get the source vertex */
  119.   boost::graph_traits<Graph>::vertex_descriptor
  120.     s = vertex(SanJose,G);
  121.  
  122.   cout << "*** Breadth First ***" << endl;
  123.   breadth_first_search
  124.     (G, s, visitor(make_bfs_visitor(boost::make_list(city_arrival(names),
  125.                                                      neighbor_cities(names),
  126.                                                      finish_city(names)))));
  127.  
  128.   return 0;
  129. }


Ultima modifica effettuata da pierotofy il 12/02/2013 alle 16:07
PM Quote
Avatar
Alberto19890 (Normal User)
Newbie


Messaggi: 8
Iscritto: 06/02/2013

Segnala al moderatore
Postato alle 10:09
Martedì, 12/02/2013
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!!


PM Quote
Avatar
Alberto19890 (Normal User)
Newbie


Messaggi: 8
Iscritto: 06/02/2013

Segnala al moderatore
Postato alle 10:13
Martedì, 12/02/2013
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

PM Quote
Avatar
Alberto19890 (Normal User)
Newbie


Messaggi: 8
Iscritto: 06/02/2013

Segnala al moderatore
Postato alle 10:35
Martedì, 12/02/2013


Alberto19890 ha allegato un file: Immagine.JPG (165980 bytes)
Clicca qui per guardare l'immagine
PM Quote
Avatar
Alberto19890 (Normal User)
Newbie


Messaggi: 8
Iscritto: 06/02/2013

Segnala al moderatore
Postato alle 11:48
Martedì, 12/02/2013
Buongiorno, ho provato a far girare un nuovo programma e l'errore che mi da è sempre connesso agli headers e l'output è il seguente:



Alberto19890 ha allegato un file: Immagine.JPG (158735 bytes)
Clicca qui per guardare l'immagine
PM Quote
Avatar
()
Newbie


Messaggi:
Iscritto:

Segnala al moderatore
Postato alle 12:43
Martedì, 12/02/2013
Nel secondo programma ti dice chiaramente che ti sei dimenticato #include "stdafx.h"

PM Quote
Pagine: [ 1 2 ] Precedente | Prossimo