Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Change WBO2IPInfo not to store weights #124

Merged
merged 1 commit into from
Nov 26, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions src/ToySolver/Converter/PB2IP.hs
Original file line number Diff line number Diff line change
Expand Up @@ -94,7 +94,7 @@ convVar x = MIP.toVar ("x" ++ show x)

-- -----------------------------------------------------------------------------

data WBO2IPInfo = WBO2IPInfo !Int [(MIP.Var, PBFile.SoftConstraint)]
data WBO2IPInfo = WBO2IPInfo !Int [(MIP.Var, PBFile.Constraint)]
deriving (Eq, Show)

instance Transformer WBO2IPInfo where
Expand All @@ -105,13 +105,13 @@ instance ForwardTransformer WBO2IPInfo where
transformForward (WBO2IPInfo _nv relaxVariables) m = Map.union m1 m2
where
m1 = Map.fromList $ [(convVar v, if val then 1 else 0) | (v,val) <- assocs m]
m2 = Map.fromList $ [(v, if SAT.evalPBConstraint m c then 0 else 1) | (v, (Just _, c)) <- relaxVariables]
m2 = Map.fromList $ [(v, if SAT.evalPBConstraint m c then 0 else 1) | (v, c) <- relaxVariables]

instance BackwardTransformer WBO2IPInfo where
transformBackward (WBO2IPInfo nv _relaxVariables) = mtrans nv

wbo2ip :: Bool -> PBFile.SoftFormula -> (MIP.Problem Integer, WBO2IPInfo)
wbo2ip useIndicator formula = (mip, WBO2IPInfo (PBFile.wboNumVars formula) relaxVariables)
wbo2ip useIndicator formula = (mip, WBO2IPInfo (PBFile.wboNumVars formula) [(r, c) | (r, (Just _, c)) <- relaxVariables])
where
mip = def
{ MIP.objectiveFunction = obj2
Expand Down
Loading