Skip to content

Commit 52d4636

Browse files
committed
progress towards compiling
1 parent d5fb01d commit 52d4636

File tree

6 files changed

+102
-70
lines changed

6 files changed

+102
-70
lines changed

.gitignore

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -22,3 +22,4 @@
2222
*.settings
2323
*ioss.doxygen.warn
2424
*ioss.tags
25+
UserInterfaceState.xcuserstate

Source/IA.cpp

Lines changed: 21 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,29 @@
11
// IA.cpp
22

33
#include "IA.h"
4-
#include "IAImplementation.h"
4+
#include "IncrementalIntervalAssignment.h"
55
#include <limits>
66

7-
8-
IAResult::IAResult() :
9-
solved(false),
10-
constraints_satisfied(false),
11-
bounds_satisfied(false),
12-
optimized(false),
13-
error(false)
14-
{}
15-
16-
IAResult::IAResult() : ia( new IAImplementation()), free_row(0)
17-
{}
18-
19-
virtual ~IAResult()
7+
namespace IIA
208
{
21-
delete IAImplementation;
22-
IAImplementation = nullptr;
9+
using IIA_Internal::IncrementalIntervalAssignment;
10+
11+
IAResult::IAResult() :
12+
solved(false),
13+
constraints_satisfied(false),
14+
bounds_satisfied(false),
15+
optimized(false),
16+
error(false)
17+
{}
18+
19+
IA::IA() : ia( new IncrementalIntervalAssignment()), free_row(0)
20+
{}
21+
22+
IA::~IA()
23+
{
24+
delete ia;
25+
ia = nullptr;
26+
}
27+
2328
}
2429

25-
26-

Source/IA.h

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,16 @@
1010
#include <vector>
1111
#include <string>
1212

13-
namespace IAInternal
13+
#include "IAEnums.h"
14+
15+
namespace IIA_Internal
1416
{
15-
class IAImplementation;
17+
class IncrementalIntervalAssignment;
1618
}
1719

20+
namespace IIA
21+
{
22+
1823
class IAResult
1924
{
2025
public:
@@ -122,9 +127,10 @@ class IA
122127
const IAResult &get_result();
123128

124129
private:
125-
IAInternal::IAImplementation *ia;
130+
IIA_Internal::IncrementalIntervalAssignment *ia;
126131
int free_row;
127132

128133
};
129134

135+
} // namespace
130136
#endif

Source/IAEnums.h

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
// IAEnums.h
2+
3+
#ifndef IA_ENUMS_H
4+
#define IA_ENUMS_H
5+
6+
namespace IIA
7+
{
8+
enum ConstraintType {EQ, LE, GE, EVEN, BAD};
9+
// ==, <=, >=, =2k,
10+
11+
}
12+
13+
#endif

Source/IncrementalIntervalAssignment.cpp

Lines changed: 29 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
#include "IncrementalIntervalAssignment.h"
33

44
// to do
5-
// move freeze_problem_size to start of solve, depending on whether solving for the first time or not
5+
// x move freeze_problem_size to start of solve, depending on whether solving for the first time or not
66
// data layout for variables with goals and slack variables and sum-even vars... probably fast enough we can just go over all of them and check the goals. maybe need something to mark vars whose column coefficients are 2
77
// sum-even constraint conversion
88
// initialize goals to 1, bounds to 1,inf, etc.
@@ -20,8 +20,10 @@
2020
#include <numeric>
2121

2222
// math utilities
23+
namespace IIA_Internal
24+
{
2325

24-
// greatest common divisor of u and v
26+
// greatest common divisor of u and v
2527
// always returns a positive number, as we take abs of u and v
2628
int gcd(int u, int v)
2729
{
@@ -5345,7 +5347,7 @@ int IncrementalIntervalAssignment::new_row(MRow &Mrow)
53455347
return used_row;
53465348
}
53475349

5348-
void IncrementalIntervalAssignment::freeze_problem_size( int /*is_equality_subprogram*/ )
5350+
void IncrementalIntervalAssignment::freeze_problem_size()
53495351
{
53505352
// zzyk to do: ensure we are told how many there are going to be
53515353
// reserve extra space for dynamic u-sub variables and rows
@@ -5632,7 +5634,7 @@ int IncrementalIntervalAssignment::solve_sub(int create_infeasible_groups)
56325634
// generate the upper/lower bounds/goals for the tied-to variables
56335635
if (!generate_tied_data())
56345636
{
5635-
return CUBIT_FALSE;
5637+
return false;
56365638
}
56375639

56385640
// adjust the initial solution for the tied-to variables
@@ -5788,7 +5790,7 @@ int IncrementalIntervalAssignment::solve_sub(int create_infeasible_groups)
57885790

57895791
if (!in_bounds)
57905792
{
5791-
return CUBIT_FALSE;
5793+
return false;
57925794
}
57935795

57945796
hasBeenSolved=true; // feasible solution
@@ -5876,6 +5878,8 @@ int IncrementalIntervalAssignment::solve(int create_groups,
58765878
double setup_time=0, map_time(0.);
58775879
if (first_time)
58785880
{
5881+
freeze_problem_size();
5882+
58795883
int num_converted=0;
58805884
for (int r = 0; r <= used_row; ++r)
58815885
{
@@ -5974,7 +5978,7 @@ int IncrementalIntervalAssignment::solve(int create_groups,
59745978
{
59755979
if (!do_pave)
59765980
{
5977-
success = CUBIT_FALSE;
5981+
success = false;
59785982
}
59795983
else
59805984
{
@@ -6049,13 +6053,13 @@ int IntervalProblem::solve_map(int create_groups,
60496053

60506054
// subdivide non-sum-even problems into independent components
60516055
std::vector<IntervalProblem*> sub_problems;
6052-
subdivide_problem( sub_problems, CUBIT_FALSE, row_min, row_max );
6056+
subdivide_problem( sub_problems, false, row_min, row_max );
60536057
const int num_subs = sub_problems.size();
60546058

60556059
double solve_time=0.;
60566060
CpuTimer solve_timer;
60576061

6058-
int success = CUBIT_TRUE;
6062+
int success = true;
60596063
for ( int i = num_subs; i--; )
60606064
{
60616065
auto *sub_problem = sub_problems.get_and_step();
@@ -6064,13 +6068,13 @@ int IntervalProblem::solve_map(int create_groups,
60646068
{
60656069
PRINT_DEBUG_121("Mapping subproblem %d of %d:\n",
60666070
num_subs - i, num_subs);
6067-
sub_problem->summarize_problem( CUBIT_FALSE, CUBIT_TRUE );
6071+
sub_problem->summarize_problem( false, true );
60686072
}
60696073
if ( !report_only )
60706074
{
60716075
if (sub_problem->solve_sub( create_infeasible_groups) != CUBIT_SUCCESS)
60726076
{
6073-
success = CUBIT_FALSE;
6077+
success = false;
60746078
if (printFlag)
60756079
{
60766080
PRINT_WARNING("Mapping subproblem %d of %d was infeasible.\n",
@@ -6116,23 +6120,23 @@ int IntervalProblem::solve_even(int create_groups,
61166120
// subdivide based on sum-even constraints.
61176121
// Some equality constraints may not be used
61186122
std::vector<IntervalProblem*> sub_problems;
6119-
subdivide_problem( sub_problems, CUBIT_TRUE, row_min, row_max );
6123+
subdivide_problem( sub_problems, true, row_min, row_max );
61206124
const int num_subs = sub_problems.size();
61216125

6122-
int success = CUBIT_TRUE;
6126+
int success = true;
61236127
for ( int i = sub_problems.size(); i--; )
61246128
{
61256129
auto *sub_problem = sub_problems.get_and_step();
61266130

61276131
if ( create_groups ) {
61286132
PRINT_DEBUG_121("Sum-even (Paving) subproblem %d of %d:\n",
61296133
num_subs - i, num_subs);
6130-
sub_problem->summarize_problem( CUBIT_FALSE, CUBIT_TRUE );
6134+
sub_problem->summarize_problem( false, true );
61316135
}
61326136
if ( !report_only ) {
61336137
if ( sub_problem->solve_sub_even() == CUBIT_FAILURE )
61346138
{
6135-
success = CUBIT_FALSE;
6139+
success = false;
61366140
// create a group for the infeasible subproblem
61376141
if (printFlag)
61386142
PRINT_WARNING("Interval Matching subproblem is infeasible\n");
@@ -6443,7 +6447,7 @@ void IntervalProblem::recursively_add_edge( int int_var_column,
64436447
assert( !sub_cols.is_in_list( int_var_column+1 ) ); //no side-effects
64446448
assert( !sub_col_array[ int_var_column ] );
64456449
sub_cols.append( int_var_column+1 );
6446-
sub_col_array[ int_var_column ] = CUBIT_TRUE;
6450+
sub_col_array[ int_var_column ] = true;
64476451

64486452
auto &non_zeros = col_rows[int_var_column];
64496453
int row, cross_column;
@@ -6455,15 +6459,15 @@ void IntervalProblem::recursively_add_edge( int int_var_column,
64556459
auto &row_non_zeros = rows[row].cols;
64566460

64576461
// should we add this row?
6458-
int do_add = CUBIT_FALSE;
6462+
int do_add = false;
64596463
if ( do_sum_even )
64606464
{
6461-
do_add = CUBIT_TRUE;
6465+
do_add = true;
64626466
}
64636467
else {
64646468

64656469
// is the row a sum-even row?
6466-
int has_sum_even_var = CUBIT_FALSE;
6470+
int has_sum_even_var = false;
64676471
row_non_zeros.last();
64686472
{
64696473
for ( int j = row_non_zeros.size(); j--; ) {
@@ -6472,15 +6476,15 @@ void IntervalProblem::recursively_add_edge( int int_var_column,
64726476
cross_column < num_int_vars() + sumEvenDummies )
64736477
{
64746478
PRINT_DEBUG(47,"IntervalProblem::recursively_add_edge: column %d is a sum-even because it's index is in [%d,%d), so skipping row %d.\n", cross_column,num_int_vars(),num_int_vars() + sumEvenDummies, row );
6475-
has_sum_even_var = CUBIT_TRUE;
6479+
has_sum_even_var = true;
64766480
break;
64776481
}
64786482
}
64796483
}
64806484
// and if is an equality constraint row
64816485
if ( !has_sum_even_var )
64826486
{
6483-
do_add = CUBIT_TRUE;
6487+
do_add = true;
64846488
}
64856489
}
64866490

@@ -6536,14 +6540,14 @@ void IntervalProblem::recursively_add_edge( int int_var_column,
65366540
// Below: can skip the row on the bet that intervals won't decrease by more than a factor of 2.
65376541
abs(expected_edge_count) <= 2*abs(sum_even_min) )
65386542
{
6539-
do_add = CUBIT_TRUE;
6543+
do_add = true;
65406544
}
65416545
}
65426546

65436547
// add row to sub problem
65446548
if ( do_add ) {
65456549
sub_rows.append( row+1 );
6546-
sub_row_array[ row ] = CUBIT_TRUE;
6550+
sub_row_array[ row ] = true;
65476551

65486552
// recursively add cross-columns
65496553
for ( int k = row_non_zeros.size(); k--; )
@@ -6722,7 +6726,7 @@ void IntervalProblem::subdivide_problem(std::vector<IntervalProblem*> &sub_probl
67226726
int sub_edges = sub_problem->num_int_vars();
67236727
sub_problem->lastCopiedCol = sub_edges + sub_problem->numDummies;
67246728

6725-
sub_problem->freeze_problem_size( !do_sum_even );
6729+
sub_problem->freeze_problem_size();
67266730

67276731
// title, for debugging
67286732
if (names_exist())
@@ -7167,3 +7171,5 @@ bool IntervalProblem::verify_full_solution(bool print_unsatisfied_constraints)
71677171
}
71687172
return rc;
71697173
}
7174+
7175+
} // namespace

0 commit comments

Comments
 (0)