Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
C
cool
Manage
Activity
Members
Labels
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Container Registry
Model registry
Operate
Environments
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Terms and privacy
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Hans-Peter Deifel
cool
Commits
93d587d0
Commit
93d587d0
authored
11 years ago
by
Thorsten Wißmann
Browse files
Options
Downloads
Patches
Plain Diff
Add gmlmip files
parent
fb3f56bf
No related branches found
No related tags found
No related merge requests found
Changes
3
Hide whitespace changes
Inline
Side-by-side
Showing
3 changed files
gmlmip.ml
+7
-0
7 additions, 0 deletions
gmlmip.ml
gmlmip.mli
+5
-0
5 additions, 0 deletions
gmlmip.mli
gmlmip_stub.cc
+76
-0
76 additions, 0 deletions
gmlmip_stub.cc
with
88 additions
and
0 deletions
gmlmip.ml
0 → 100644
+
7
−
0
View file @
93d587d0
(* transforms list of gml formulas (diamond?,number,formula)
to list of consequences (positive?,formula),
here positive? means that the formula must be true in order to make the
given conjunct of modalities true *)
external
gml_rules
:
(
bool
*
int
*
int
)
list
->
(
int
*
bool
)
list
list
=
"gmlRules_stub"
This diff is collapsed.
Click to expand it.
gmlmip.mli
0 → 100644
+
5
−
0
View file @
93d587d0
(* transforms list of gml formulas (diamond?,number,formula)
to list of consequences (positive?,formula),
here positive? means that the formula must be true in order to make the
given conjunct of modalities true *)
val
gml_rules
:
(
bool
*
int
*
int
)
list
->
(
int
*
bool
)
list
list
This diff is collapsed.
Click to expand it.
gmlmip_stub.cc
0 → 100644
+
76
−
0
View file @
93d587d0
#define __STDC_LIMIT_MACROS
#define __STDC_FORMAT_MACROS
#include
<utility>
// for pair
#include
<vector>
extern
"C"
{
#include
<caml/mlvalues.h>
#include
<caml/alloc.h>
#include
<caml/memory.h>
#include
<caml/custom.h>
}
#include
"GMLMIP-0.1/onestep.h"
//
using
namespace
std
;
extern
"C"
{
CAMLprim
value
gmlRules_stub
(
value
modalities
);
}
template
<
class
T
>
value
vector2CamlList
(
const
vector
<
T
>&
vec
,
value
(
*
f
)(
const
T
&
))
{
CAMLlocal2
(
cli
,
cons
);
cli
=
Val_emptylist
;
for
(
int
i
=
vec
.
size
()
-
1
;
i
>=
0
;
i
--
)
{
cons
=
caml_alloc
(
2
,
0
);
Store_field
(
cons
,
0
,
f
(
vec
[
i
])
);
// head
Store_field
(
cons
,
1
,
cli
);
// tail
cli
=
cons
;
}
return
cli
;
}
static
CAMLprim
value
pair2caml
(
const
pair
<
int
,
bool
>&
t
)
{
CAMLlocal1
(
abc
);
abc
=
caml_alloc
(
2
,
0
);
Store_field
(
abc
,
0
,
Val_int
(
t
.
first
));
Store_field
(
abc
,
1
,
Val_bool
(
t
.
second
));
return
abc
;
}
static
CAMLprim
value
vector2caml
(
const
vector
<
pair
<
int
,
bool
>
>&
vt
)
{
return
vector2CamlList
(
vt
,
pair2caml
);
}
CAMLprim
value
gmlRules_stub
(
value
modalities
)
{
// parse caml-modalities to a C++ vector
CAMLparam1
(
modalities
);
value
block
=
modalities
;
vector
<
pair
<
pair
<
bool
,
int
>
,
int
>
>
modvec
;
while
(
Is_block
(
block
))
{
CAMLlocal3
(
vpos
,
vcnt
,
vformula
);
vpos
=
Field
(
Field
(
block
,
0
),
0
);
vcnt
=
Field
(
Field
(
block
,
0
),
1
);
vformula
=
Field
(
Field
(
block
,
0
),
2
);
modvec
.
push_back
(
make_pair
(
make_pair
(
Bool_val
(
vpos
),
Int_val
(
vcnt
)),
Int_val
(
vformula
)));
}
// Do one rule step and save result in rulevec
GMLConclusion
rulevec
=
gmlmip_onestep_gml
(
modvec
);
// convert rulevec into ocaml list of pairs
CAMLlocal1
(
res
);
res
=
vector2CamlList
(
rulevec
,
vector2caml
);
CAMLreturn
(
res
);
}
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment