Skip to content

Commit

Permalink
no sat should not override the rest of visualization output (#22)
Browse files Browse the repository at this point in the history
  • Loading branch information
mbellotti committed Feb 17, 2023
1 parent 853751c commit cfff092
Show file tree
Hide file tree
Showing 2 changed files with 24 additions and 15 deletions.
14 changes: 8 additions & 6 deletions execute/format.go
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,15 @@ import (
*/

func (mc *ModelChecker) Mermaid() {
var out bytes.Buffer
out.WriteString("flowchart LR\n")
for k, l := range mc.Results {
out.WriteString(mc.writeObjects(k, l))
out.WriteString("\n")
if len(mc.Results) > 0 {
var out bytes.Buffer
out.WriteString("flowchart LR\n")
for k, l := range mc.Results {
out.WriteString(mc.writeObjects(k, l))
out.WriteString("\n")
}
fmt.Println(out.String())
}
fmt.Println(out.String())
}

func (mc *ModelChecker) writeObjects(k string, objects []*smt.VarChange) string {
Expand Down
25 changes: 16 additions & 9 deletions main.go
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ func probability(smt string, uncertains map[string][]float64, unknowns []string,
}
if !ok {
fmt.Println("Fault could not find a failure case.")
os.Exit(0)
return ex, nil
}
scenario, err := ex.Solve()
if err != nil {
Expand Down Expand Up @@ -159,9 +159,12 @@ func run(filepath string, mode string, input string, reach bool) {
mc.Mermaid()
return
}
mc.LoadMeta(generator.GetForks())
fmt.Println("~~~~~~~~~~\n Fault found the following scenario\n~~~~~~~~~~")
mc.Format(data)

if data != nil {
mc.LoadMeta(generator.GetForks())
fmt.Println("~~~~~~~~~~\n Fault found the following scenario\n~~~~~~~~~~")
mc.Format(data)
}
case "ll":
generator := smt2(d, 0, uncertains, unknowns, nil, nil)
if mode == "smt" {
Expand All @@ -174,18 +177,22 @@ func run(filepath string, mode string, input string, reach bool) {
mc.Mermaid()
return
}
mc.LoadMeta(generator.GetForks())
fmt.Println("~~~~~~~~~~\n Fault found the following scenario\n~~~~~~~~~~")
mc.Format(data)
if data != nil {
mc.LoadMeta(generator.GetForks())
fmt.Println("~~~~~~~~~~\n Fault found the following scenario\n~~~~~~~~~~")
mc.Format(data)
}
case "smt2":
mc, data := probability(d, uncertains, unknowns, make(map[string][]*smt.VarChange))

if mode == "visualize" {
mc.Mermaid()
return
}
fmt.Println("~~~~~~~~~~\n Fault found the following scenario\n~~~~~~~~~~")
mc.Format(data)
if data != nil {
fmt.Println("~~~~~~~~~~\n Fault found the following scenario\n~~~~~~~~~~")
mc.Format(data)
}
}
}

Expand Down

0 comments on commit cfff092

Please sign in to comment.