Skip to content

Commit bdfb437

Browse files
committed
almost done with hyper cxx module, part II
1 parent 704b217 commit bdfb437

21 files changed

+455
-251
lines changed

include/OptFrame/Heuristics.hpp

+5
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,11 @@
3939
//
4040
#include "Heuristics/EA/RK/BRKGA.hpp"
4141
//
42+
// GRASP
43+
//
44+
#include "Heuristics/GRASP/GRASPFamily.h"
45+
#include "Heuristics/GRASP/GRConstructive.hpp"
46+
//
4247
// MO
4348
//
4449
#include "Heuristics/EmptyMultiObjSearch.hpp"

include/OptFrame/Heuristics/GRASP/BasicGRASP.hpp

+23-4
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,9 @@
33

44
#ifndef OPTFRAME_HEURISTICS_GRASP_BASICGRASP_HPP_
55
#define OPTFRAME_HEURISTICS_GRASP_BASICGRASP_HPP_
6+
7+
#if (__cplusplus < 202302L) || defined(NO_CXX_MODULES)
8+
69
// C
710
// C++
811
#include <string>
@@ -16,6 +19,22 @@
1619
#include "GRASPFamily.h"
1720
#include "GRConstructive.hpp"
1821

22+
#define MOD_EXPORT
23+
#else
24+
25+
// CANNOT IMPORT HERE... Already part of optframe.core
26+
/*
27+
import std;
28+
import optframe.component;
29+
import optframe.concepts;
30+
*/
31+
32+
// do NOT export modules on .hpp... only on .cppm
33+
34+
#define MOD_EXPORT export
35+
36+
#endif
37+
1938
namespace optframe {
2039

2140
// GRASP requires S space interaction
@@ -163,7 +182,7 @@ class BasicGRASPBuilder : public GRASP, public SingleObjSearchBuilder<XES> {
163182

164183
std::string rest = scanner.rest();
165184

166-
pair<sptr<LocalSearch<XES>>, std::string> method;
185+
std::pair<sptr<LocalSearch<XES>>, std::string> method;
167186
method = hf.createLocalSearch(rest);
168187

169188
sptr<LocalSearch<XES>> h = method.first;
@@ -184,13 +203,13 @@ class BasicGRASPBuilder : public GRASP, public SingleObjSearchBuilder<XES> {
184203

185204
std::vector<std::pair<std::string, std::string>> parameters() override {
186205
std::vector<std::pair<std::string, std::string>> params;
187-
params.push_back(
188-
make_pair(GeneralEvaluator<XES>::idComponent(), "evaluation function"));
206+
params.push_back(std::make_pair(GeneralEvaluator<XES>::idComponent(),
207+
"evaluation function"));
189208
params.push_back(
190209
std::make_pair(GRConstructive<S>::idComponent(),
191210
"greedy randomized constructive heuristic"));
192211
params.push_back(
193-
make_pair(LocalSearch<XES>::idComponent(), "local search"));
212+
std::make_pair(LocalSearch<XES>::idComponent(), "local search"));
194213
params.push_back(std::make_pair("OptFrame:float", "alpha parameter [0,1]"));
195214
params.push_back(
196215
std::make_pair("OptFrame:int", "max number of iterations"));
+28-35
Original file line numberDiff line numberDiff line change
@@ -1,47 +1,40 @@
1-
// OptFrame - Optimization Framework
2-
3-
// Copyright (C) 2009, 2010, 2011
4-
// http://optframe.sourceforge.net/
5-
//
6-
// This file is part of the OptFrame optimization framework. This framework
7-
// is free software; you can redistribute it and/or modify it under the
8-
// terms of the GNU Lesser General Public License v3 as published by the
9-
// Free Software Foundation.
10-
11-
// This framework is distributed in the hope that it will be useful,
12-
// but WITHOUT ANY WARRANTY; without even the implied warranty of
13-
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14-
// GNU Lesser General Public License v3 for more details.
15-
16-
// You should have received a copy of the GNU Lesser General Public License v3
17-
// along with this library; see the file COPYING. If not, write to the Free
18-
// Software Foundation, 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301,
19-
// USA.
1+
// SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
2+
// Copyright (C) 2007-2025 - OptFrame - https://github.com/optframe/optframe
203

214
#ifndef OPTFRAME_GRASPH_H_
225
#define OPTFRAME_GRASPH_H_
236

24-
#include <string.h>
7+
#if (__cplusplus < 202302L) || defined(NO_CXX_MODULES)
258

26-
using namespace std;
27-
//GRASPH ? TODO FIX THE NAME
9+
#include <string>
2810

29-
namespace optframe
30-
{
11+
#define MOD_EXPORT
12+
#else
3113

32-
class GRASPH
33-
{
34-
public:
35-
static string family()
36-
{
37-
return "GRASPH:";
38-
}
14+
// CANNOT IMPORT HERE... Already part of optframe.core
15+
/*
16+
import std;
17+
import optframe.component;
18+
import optframe.concepts;
19+
*/
3920

40-
virtual ~GRASPH()
41-
{
42-
}
21+
// do NOT export modules on .hpp... only on .cppm
22+
23+
#define MOD_EXPORT export
24+
25+
#endif
26+
27+
// GRASPH ? TODO FIX THE NAME
28+
29+
namespace optframe {
30+
31+
class GRASPH {
32+
public:
33+
static std::string family() { return "GRASPH:"; }
34+
35+
virtual ~GRASPH() {}
4336
};
4437

45-
}
38+
} // namespace optframe
4639

4740
#endif /*OPTFRAME_GRASPH_H_*/
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,40 @@
1-
// OptFrame 4.2 - Optimization Framework
2-
// Copyright (C) 2009-2021 - MIT LICENSE
3-
// https://github.com/optframe/optframe
4-
//
5-
// Permission is hereby granted, free of charge, to any person obtaining
6-
// a copy of this software and associated documentation files (the "Software"),
7-
// to deal in the Software without restriction, including without limitation
8-
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9-
// and/or sell copies of the Software, and to permit persons to whom the
10-
// Software is furnished to do so, subject to the following conditions:
11-
//
12-
// The above copyright notice and this permission notice shall be included
13-
// in all copies or substantial portions of the Software.
14-
//
15-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18-
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
// THE SOFTWARE.
1+
// SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
2+
// Copyright (C) 2007-2025 - OptFrame - https://github.com/optframe/optframe
223

234
#ifndef OPTFRAME_GRASP_FAMILY_H_
245
#define OPTFRAME_GRASP_FAMILY_H_
256

26-
#include <string.h>
7+
#if (__cplusplus < 202302L) || defined(NO_CXX_MODULES)
278

28-
using namespace std;
29-
//GRASPH ? TODO FIX THE NAME
9+
#include <string>
10+
11+
#define MOD_EXPORT
12+
#else
13+
14+
// CANNOT IMPORT HERE... Already part of optframe.core
15+
/*
16+
import std;
17+
import optframe.component;
18+
import optframe.concepts;
19+
*/
20+
21+
// do NOT export modules on .hpp... only on .cppm
22+
23+
#define MOD_EXPORT export
24+
25+
#endif
26+
27+
// GRASPH ? TODO FIX THE NAME
3028

3129
namespace optframe {
3230

33-
class GRASP
34-
{
35-
public:
36-
static string family()
37-
{
38-
return "GRASP";
39-
}
40-
41-
virtual ~GRASP()
42-
{
43-
}
31+
MOD_EXPORT class GRASP {
32+
public:
33+
static std::string family() { return "GRASP"; }
34+
35+
virtual ~GRASP() {}
4436
};
4537

46-
}
38+
} // namespace optframe
4739

4840
#endif /*OPTFRAME_GRASP_FAMILY_H_*/

include/OptFrame/Heuristics/GRASP/GRConstructive.hpp

+21-22
Original file line numberDiff line numberDiff line change
@@ -1,37 +1,36 @@
1-
// OptFrame 4.2 - Optimization Framework
2-
// Copyright (C) 2009-2021 - MIT LICENSE
3-
// https://github.com/optframe/optframe
4-
//
5-
// Permission is hereby granted, free of charge, to any person obtaining
6-
// a copy of this software and associated documentation files (the "Software"),
7-
// to deal in the Software without restriction, including without limitation
8-
// the rights to use, copy, modify, merge, publish, distribute, sublicense,
9-
// and/or sell copies of the Software, and to permit persons to whom the
10-
// Software is furnished to do so, subject to the following conditions:
11-
//
12-
// The above copyright notice and this permission notice shall be included
13-
// in all copies or substantial portions of the Software.
14-
//
15-
// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
16-
// OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17-
// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL
18-
// THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19-
// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20-
// OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
21-
// THE SOFTWARE.
1+
// SPDX-License-Identifier: LGPL-3.0-or-later OR MIT
2+
// Copyright (C) 2007-2025 - OptFrame - https://github.com/optframe/optframe
223

234
#ifndef OPTFRAME_GREEDY_RANDOMIZED_CONSTRUCTIVE_H_
245
#define OPTFRAME_GREEDY_RANDOMIZED_CONSTRUCTIVE_H_
256

7+
#if (__cplusplus < 202302L) || defined(NO_CXX_MODULES)
8+
269
#include <OptFrame/Core/Constructive.hpp>
2710
#include <OptFrame/Helper/Solution.hpp>
2811

2912
#include "GRASPFamily.h"
3013

14+
#define MOD_EXPORT
15+
#else
16+
17+
// CANNOT IMPORT HERE... Already part of optframe.core
18+
/*
19+
import std;
20+
import optframe.component;
21+
import optframe.concepts;
22+
*/
23+
24+
// do NOT export modules on .hpp... only on .cppm
25+
26+
#define MOD_EXPORT export
27+
28+
#endif
29+
3130
namespace optframe {
3231

3332
// Greedy Randomized Constructive
34-
template <XSolution S>
33+
MOD_EXPORT template <XSolution S>
3534
class GRConstructive : public Constructive<S>, public GRASP {
3635
public:
3736
virtual ~GRConstructive() {}

include/OptFrame/Heuristics/ILS/BasicILSPerturbation.hpp

+21-3
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef OPTFRAME_HEURISTICS_ILS_BASICILSPERTURBATION_HPP_
55
#define OPTFRAME_HEURISTICS_ILS_BASICILSPERTURBATION_HPP_
66

7+
#if (__cplusplus < 202302L) || defined(NO_CXX_MODULES)
8+
79
#include <math.h>
810

911
#include <string>
@@ -16,9 +18,25 @@
1618

1719
#include "ILS.hpp"
1820

21+
#define MOD_EXPORT
22+
#else
23+
24+
// CANNOT IMPORT HERE... Already part of optframe.core
25+
/*
26+
import std;
27+
import optframe.component;
28+
import optframe.concepts;
29+
*/
30+
31+
// do NOT export modules on .hpp... only on .cppm
32+
33+
#define MOD_EXPORT export
34+
35+
#endif
36+
1937
namespace optframe {
2038

21-
template <XESolution XES, XEvaluation XEv = Evaluation<>>
39+
MOD_EXPORT template <XESolution XES, XEvaluation XEv = Evaluation<>>
2240
class BasicILSPerturbation : public ILS, public Component {
2341
using XSH = XES; // primary-based search type only (BestType)
2442

@@ -103,9 +121,9 @@ class BasicILSPerturbation : public ILS, public Component {
103121
};
104122

105123
#if defined(__cpp_concepts) && (__cpp_concepts >= 201907L)
106-
template <XESolution XES>
124+
MOD_EXPORT template <XESolution XES>
107125
#else
108-
template <typename XES>
126+
MOD_EXPORT template <typename XES>
109127
#endif
110128
class BasicILSPerturbationBuilder : public ComponentBuilder<XES> {
111129
using XSH = XES; // primary-based search type only (BestType)

include/OptFrame/Heuristics/ILS/BasicIteratedLocalSearch.hpp

+23-5
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#ifndef OPTFRAME_HEURISTICS_ILS_BASICITERATEDLOCALSEARCH_HPP_
55
#define OPTFRAME_HEURISTICS_ILS_BASICITERATEDLOCALSEARCH_HPP_
66

7+
#if (__cplusplus < 202302L) || defined(NO_CXX_MODULES)
8+
79
#include <math.h>
810

911
#include <string>
@@ -17,11 +19,27 @@
1719
#include "ILS.hpp"
1820
#include "IteratedLocalSearch.hpp"
1921

22+
#define MOD_EXPORT
23+
#else
24+
25+
// CANNOT IMPORT HERE... Already part of optframe.core
26+
/*
27+
import std;
28+
import optframe.component;
29+
import optframe.concepts;
30+
*/
31+
32+
// do NOT export modules on .hpp... only on .cppm
33+
34+
#define MOD_EXPORT export
35+
36+
#endif
37+
2038
namespace optframe {
2139

22-
typedef int BasicHistory;
40+
MOD_EXPORT using BasicHistory = int;
2341

24-
template <XESolution XES>
42+
MOD_EXPORT template <XESolution XES>
2543
class BasicIteratedLocalSearch : public IteratedLocalSearch<BasicHistory, XES> {
2644
using XEv = typename XES::second_type;
2745

@@ -112,9 +130,9 @@ class BasicIteratedLocalSearch : public IteratedLocalSearch<BasicHistory, XES> {
112130
};
113131

114132
#if defined(__cpp_concepts) && (__cpp_concepts >= 201907L)
115-
template <XESolution XES>
133+
MOD_EXPORT template <XESolution XES>
116134
#else
117-
template <typename XES>
135+
MOD_EXPORT template <typename XES>
118136
#endif
119137
class BasicIteratedLocalSearchBuilder : public ILS,
120138
public SingleObjSearchBuilder<XES> {
@@ -135,7 +153,7 @@ class BasicIteratedLocalSearchBuilder : public ILS,
135153

136154
std::string rest = scanner.rest();
137155

138-
pair<sptr<LocalSearch<XES>>, std::string> method;
156+
std::pair<sptr<LocalSearch<XES>>, std::string> method;
139157
method = hf.createLocalSearch(rest);
140158

141159
sptr<LocalSearch<XES>> h = method.first;

include/OptFrame/Heuristics/ILS/ILS.hpp

+1-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ import optframe.concepts;
2626

2727
namespace optframe {
2828

29-
class ILS {
29+
MOD_EXPORT class ILS {
3030
public:
3131
static std::string family() { return "ILS:"; }
3232

0 commit comments

Comments
 (0)