为什么这个MiniZinc声明“出乎意料”?

时间:2017-03-16 01:19:27

标签: arrays minizinc

我是一名MiniZinc新手试图通过使用数组在MiniZinc教程中概括玩具程序,为澳大利亚地图着色。

以下是包含我的2个数组声明的程序:

% Colouring Australia using nc colours

int: nc = 3;   /* number of colours */
int: ns = 7;  % number of states

  % I added these 2 lines, and changed nothing else so far
array[1..ns] of string: names = ["wa","nt","sa","q","nsw","v","t"]; 
var array[1..ns] of 1..nc: colours;

var 1..nc: wa;  % the color assigned to each state, to be calculated
var 1..nc: nt;
var 1..nc: sa;
var 1..nc: q;
var 1..nc: nsw;
var 1..nc: v;
var 1..nc: t;

constraint wa != nt;  % adjacent states
constraint wa != sa;
constraint nt != sa;
constraint nt != q;
constraint sa != q;
constraint sa != nsw;
constraint sa != v;
constraint q != nsw;
constraint nsw != v;

solve satisfy;

编译器接受了第一个数组语句,没有任何抱怨。 第二个数组语句给出了语法错误消息:“意外数组”,但没有抱怨语法本身。

声明顺序应该是无关紧要的,所以不可能。 用int替换1..nc仍会出错。

是什么让它“意外”?为什么第一个数组不出意外?

应该我如何定义一系列决策变量?

1 个答案:

答案 0 :(得分:1)

声明决策变量数组的语法是

    $this->validate($request, [
                'token' => 'required',
                'email' => 'required|email|max:35',
                'password' => 'required|confirmed|min:6|max:15',
            ]);

            $credentials = $request->only(
                'email', 'password', 'password_confirmation', 'token'
            );

            $response = Password::reset($credentials, function ($user, $password) {
                $this->resetPassword($user, $password);
            });
 switch ($response) {
            case Password::PASSWORD_RESET:
                return redirect($this->redirectPath())->with('status', trans($response));

            default:
                return redirect()->back()
                            ->withInput($request->only('email'))
                            ->withErrors(['email' => trans($response)]);
        }

即。 "无功"放在域之前(而不是在"数组"之前)。