Loading...
Searching...
No Matches
transport14.cpp File Reference

This is the 14th model in a series of tutorial examples. More...

#include "optimizer.h"
#include <iostream>
#include <thread>

Go to the source code of this file.

Functions

void run (Optimizer optim, double bmult)
 
int main (int argc, char *argv[])
 

Detailed Description

This is the 14th model in a series of tutorial examples.

Here we show:

  • How to run multiple GAMSJobs in parallel each using different scenario data

Definition in file transport14.cpp.

Function Documentation

◆ main()

int main ( int argc,
char * argv[] )

Definition at line 43 of file transport14.cpp.

44{
45 cout << "---------- Transport 14 --------------" << endl;
46
47 try {
48 vector<double> bmultlist { 0.6, 0.7, 0.8, 0.9, 1.0, 1.1, 1.2, 1.3 };
49 const Optimizer &optim = Optimizer(argc, argv);
50
51 vector<thread> threads;
52 for (auto bmult : bmultlist)
53 threads.push_back(thread(run, optim, bmult));
54
55 for (auto& t : threads)
56 t.join();
57
58 } catch (GAMSException &ex) {
59 cout << "GAMSException occured: " << ex.what() << endl;
60 } catch (exception &ex) {
61 cout << ex.what() << endl;
62 }
63
64 return 0;
65}
void run(Optimizer optim, double bmult)

◆ run()

void run ( Optimizer optim,
double bmult )

Definition at line 33 of file transport14.cpp.

34{
35 cout << "Scenario bmult=" << bmult << ", Obj:" << optim.solve(bmult) << endl;
36}
double solve(double mult)
Create database and execute a job.
Definition optimizer.cpp:43

Referenced by main().