Skip to content

Commit

Permalink
Merge pull request #579 from conjure-cp/fix-copy-solution-in-subdir
Browse files Browse the repository at this point in the history
Fix copy solution in subdir
  • Loading branch information
ozgurakgun authored Jun 30, 2023
2 parents 8d28897 + 22516b8 commit 5392b11
Show file tree
Hide file tree
Showing 6 changed files with 40 additions and 14 deletions.
30 changes: 16 additions & 14 deletions src/Conjure/UI/MainHelper.hs
Original file line number Diff line number Diff line change
Expand Up @@ -407,20 +407,22 @@ mainWithArgs config@Solve{..} = do
]
<.> ext
-- parameterised, with solution numbers
(False, False, singleSolution, [_model, param, (stripPrefix "solution" -> Just solnum)]) | param `elem` params ->
if singleSolution
then when (solnum == "000001") $ -- only copy the first solution
copySolution file $ essenceDir
</> intercalate "-" [ essenceBasename
, param
]
<.> ext
else copySolution file $ essenceDir
</> intercalate "-" [ essenceBasename
, param
, solnum
]
<.> ext
(False, False, singleSolution, [_model, param, (stripPrefix "solution" -> Just solnum)])
| or [ param `elem` params
, or [('/' : param) `isSuffixOf` p | p <- params] ] ->
if singleSolution
then when (solnum == "000001") $ -- only copy the first solution
copySolution file $ essenceDir
</> intercalate "-" [ essenceBasename
, param
]
<.> ext
else copySolution file $ essenceDir
</> intercalate "-" [ essenceBasename
, param
, solnum
]
<.> ext
_ -> return () -- ignore, we don't know how to handle this file

liftIO stopGlobalPool
Expand Down
1 change: 1 addition & 0 deletions tests/custom/issues/578/d/p.param
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
letting a be 50
3 changes: 3 additions & 0 deletions tests/custom/issues/578/e.essence
Original file line number Diff line number Diff line change
@@ -0,0 +1,3 @@
given a : int(1..)
find b : bool
such that b = (a < 100)
1 change: 1 addition & 0 deletions tests/custom/issues/578/q.param
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
letting a be 50
5 changes: 5 additions & 0 deletions tests/custom/issues/578/run.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
rm -rf conjure-output *.solution
conjure solve e.essence q.param
rm -rf conjure-output *.solution
conjure solve e.essence d/p.param
rm -rf conjure-output *.solution
14 changes: 14 additions & 0 deletions tests/custom/issues/578/stdout.expected
Original file line number Diff line number Diff line change
@@ -0,0 +1,14 @@
Generating models for e.essence
Generated models: model000001.eprime
Saved under: conjure-output
Savile Row: model000001.eprime q.param
Running minion for domain filtering.
Running solver: minion
Copying solution to: e-q.solution
Generating models for e.essence
Generated models: model000001.eprime
Saved under: conjure-output
Savile Row: model000001.eprime d/p.param
Running minion for domain filtering.
Running solver: minion
Copying solution to: e-p.solution

0 comments on commit 5392b11

Please sign in to comment.